Skip to content

Commit 70fc653

Browse files
monnierxuhdev
andauthored
bin/editorconfig-el: Use --script (#385)
Emacs's `master` has been changed so as to avoid emitting the lexical binding warning when using `--script`, so we can use that instead of the ugly hack. This also gives us `--batch` for free. (main): Oh, and simplify it while we're at it. Co-authored-by: Hong Xu <[email protected]>
1 parent 946c09f commit 70fc653

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

bin/editorconfig-el

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
:;#-*- mode: emacs-lisp; lexical-binding:t -*-
33
:;test -n "$EMACS_BIN" || EMACS_BIN=emacs
4-
:;exec "$EMACS_BIN" -batch -Q --eval '(setq debug-on-error t internal--get-default-lexical-binding-function `always)' -l "$0" -- "$@"
4+
:;exec "$EMACS_BIN" -Q --script "$0" -- "$@"
55

66
;; editorconfig-el --- EditorConfig Core executable in Emacs Lisp
77

@@ -36,6 +36,8 @@
3636

3737
;;; Code:
3838

39+
(setq debug-on-error t) ;; Not sure why we do that, but let's keep it.
40+
3941
(when (getenv "EDITORCONFIG_CORE_LIBRARY_PATH")
4042
(setq load-path
4143
(append (split-string (getenv "EDITORCONFIG_CORE_LIBRARY_PATH")
@@ -99,29 +101,17 @@ with required output."
99101
(defun main (argv)
100102
;; TODO: Read file list from stdin if - is given as FILENAME
101103
(let ((parsed (editorconfig-bin-parse-args argv)))
102-
(cl-case (length (car parsed))
103-
(0
104-
nil)
105-
(1
106-
(dolist (p (editorconfig-core-get-properties (caar parsed)
107-
(nth 1 parsed)
108-
(nth 2 parsed)))
109-
(princ (format "%s=%s\n"
110-
(car p)
111-
(cdr p)))))
112-
(otherwise
113-
(dolist (file (car parsed))
114-
(princ (format "[%s]\n"
115-
file))
116-
(dolist (p (editorconfig-core-get-properties file
117-
(nth 1 parsed)
118-
(nth 2 parsed)))
119-
(princ (format "%s=%s\n"
120-
(car p)
121-
(cdr p))))))))
122-
0)
123-
124-
;; car of command-line-args-left is "--"
125-
(kill-emacs (main (cdr command-line-args-left)))
104+
(dolist (file (car parsed))
105+
(unless (eq 1 (length (car parsed)))
106+
(princ (format "[%s]\n"
107+
file)))
108+
(dolist (p (editorconfig-core-get-properties file
109+
(nth 1 parsed)
110+
(nth 2 parsed)))
111+
(princ (format "%s=%s\n"
112+
(car p)
113+
(cdr p)))))))
114+
115+
(kill-emacs (main (cdr (member "--" command-line-args-left))))
126116

127117
;;; editorconfig-el ends here

0 commit comments

Comments
 (0)