branch: elpa/editorconfig
commit 70fc65334032f2c2854987869a65fc8c993e4426
Author: monnier <[email protected]>
Commit: GitHub <[email protected]>
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]>
---
bin/editorconfig-el | 40 +++++++++++++++-------------------------
1 file changed, 15 insertions(+), 25 deletions(-)
diff --git a/bin/editorconfig-el b/bin/editorconfig-el
index d6bde585af6..19335032714 100755
--- a/bin/editorconfig-el
+++ b/bin/editorconfig-el
@@ -1,7 +1,7 @@
#!/bin/sh
:;#-*- mode: emacs-lisp; lexical-binding:t -*-
:;test -n "$EMACS_BIN" || EMACS_BIN=emacs
-:;exec "$EMACS_BIN" -batch -Q --eval '(setq debug-on-error t
internal--get-default-lexical-binding-function `always)' -l "$0" -- "$@"
+:;exec "$EMACS_BIN" -Q --script "$0" -- "$@"
;; editorconfig-el --- EditorConfig Core executable in Emacs Lisp
@@ -36,6 +36,8 @@
;;; Code:
+(setq debug-on-error t) ;; Not sure why we do that, but let's keep it.
+
(when (getenv "EDITORCONFIG_CORE_LIBRARY_PATH")
(setq load-path
(append (split-string (getenv "EDITORCONFIG_CORE_LIBRARY_PATH")
@@ -99,29 +101,17 @@ with required output."
(defun main (argv)
;; TODO: Read file list from stdin if - is given as FILENAME
(let ((parsed (editorconfig-bin-parse-args argv)))
- (cl-case (length (car parsed))
- (0
- nil)
- (1
- (dolist (p (editorconfig-core-get-properties (caar parsed)
- (nth 1 parsed)
- (nth 2 parsed)))
- (princ (format "%s=%s\n"
- (car p)
- (cdr p)))))
- (otherwise
- (dolist (file (car parsed))
- (princ (format "[%s]\n"
- file))
- (dolist (p (editorconfig-core-get-properties file
- (nth 1 parsed)
- (nth 2 parsed)))
- (princ (format "%s=%s\n"
- (car p)
- (cdr p))))))))
- 0)
-
-;; car of command-line-args-left is "--"
-(kill-emacs (main (cdr command-line-args-left)))
+ (dolist (file (car parsed))
+ (unless (eq 1 (length (car parsed)))
+ (princ (format "[%s]\n"
+ file)))
+ (dolist (p (editorconfig-core-get-properties file
+ (nth 1 parsed)
+ (nth 2 parsed)))
+ (princ (format "%s=%s\n"
+ (car p)
+ (cdr p)))))))
+
+(kill-emacs (main (cdr (member "--" command-line-args-left))))
;;; editorconfig-el ends here