guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: etc: indent-code.el: Use the --quick option.


From: guix-commits
Subject: branch master updated: etc: indent-code.el: Use the --quick option.
Date: Thu, 14 May 2020 23:08:37 -0400

This is an automated email from the git hooks/post-receive script.

apteryx pushed a commit to branch master
in repository guix.

The following commit(s) were added to refs/heads/master by this push:
     new cb21ae7  etc: indent-code.el: Use the --quick option.
cb21ae7 is described below

commit cb21ae76714f1873d3b3fb40d5135f00ec104b85
Author: Maxim Cournoyer <address@hidden>
AuthorDate: Tue Mar 31 00:12:01 2020 -0400

    etc: indent-code.el: Use the --quick option.
    
    This prevents Emacs from loading the autoload definitions found in its
    profile, which needlessly clutters the output.  It also prevents Geiser (if
    installed) from blocking the script and asking the user to input the Scheme
    implementation to use.
    
    The trick for passing multiple arguments to Emacs is to use what is called a
    "sesquicolon" (see https://www.emacswiki.org/emacs/EmacsScripts).
    
    * etc/indent-code.el.in: Rename to...
    * etc/indent-code.el: ...this.  Adapt the shebang to use a sesquicolon, and
    pass the --quick option to Emacs.  Since this line is interpreted by the
    shell, simply use Emacs from the PATH instead of from a hard coded location.
    (main): New procedure, used as the entry point.
    * configure.ac: Remove the warning about Emacs.  Emacs can now be installed
    any time by the user if they want to use the script.
    * .gitignore: No longer ignore changes to etc/indent-code.el.
---
 .gitignore                                |  1 -
 configure.ac                              |  9 ------
 etc/{indent-code.el.in => indent-code.el} | 52 ++++++++++++++++---------------
 3 files changed, 27 insertions(+), 35 deletions(-)

diff --git a/.gitignore b/.gitignore
index fd2cf56..cc5ceb5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -149,7 +149,6 @@ stamp-h[0-9]
 tmp
 /doc/os-config-lightweight-desktop.texi
 /nix/scripts/download
-/etc/indent-code.el
 /.version
 /doc/stamp-[0-9]
 /gnu/packages/bootstrap
diff --git a/configure.ac b/configure.ac
index a44a605..0a20b47 100644
--- a/configure.ac
+++ b/configure.ac
@@ -286,15 +286,6 @@ dnl Documentation translation.
 AM_MISSING_PROG([PO4A_TRANSLATE], [po4a-translate])
 AM_MISSING_PROG([PO4A_UPDATEPO], [po4a-updatepo])
 
-dnl Emacs (optional), for 'etc/indent-code.el'.
-AC_PATH_PROG([EMACS], [emacs])
-if test "x$EMACS" = x; then
-    AC_MSG_WARN([Please install GNU Emacs to use etc/indent-code.el.])
-else
-    AC_SUBST([EMACS])
-    AC_CONFIG_FILES([etc/indent-code.el], [chmod +x etc/indent-code.el])
-fi
-
 case "$storedir" in
   /gnu/store)
     ;;
diff --git a/etc/indent-code.el.in b/etc/indent-code.el
similarity index 71%
rename from etc/indent-code.el.in
rename to etc/indent-code.el
index 6102b5d..255ffb1 100755
--- a/etc/indent-code.el.in
+++ b/etc/indent-code.el
@@ -1,8 +1,9 @@
-#!@EMACS@ --script
+:;exec emacs --batch --quick --load="$0" --funcall=main "$@"
 ;;; indent-code.el --- Run Emacs to indent a package definition.
 
 ;; Copyright © 2017 Alex Kost <address@hidden>
 ;; Copyright © 2017 Ludovic Courtès <address@hidden>
+;; Copyright © 2020 Maxim Cournoyer <address@hidden>
 
 ;; This file is part of GNU Guix.
 
@@ -86,29 +87,30 @@
  (with-syntax 1))
 
 
-(pcase command-line-args-left
-  (`(,file-name ,package-name)
-   ;; Indent the definition of PACKAGE-NAME in FILE-NAME.
-   (find-file file-name)
-   (goto-char (point-min))
-   (if (re-search-forward (concat "^(define\\(-public\\) +"
-                                  package-name)
-                          nil t)
-       (let ((indent-tabs-mode nil))
-         (beginning-of-defun)
-         (indent-sexp)
-         (save-buffer)
-         (message "Done!"))
-     (error "Package '%s' not found in '%s'"
-            package-name file-name)))
-  (`(,file-name)
-   ;; Indent all of FILE-NAME.
-   (find-file file-name)
-   (let ((indent-tabs-mode nil))
-     (indent-region (point-min) (point-max))
-     (save-buffer)
-     (message "Done!")))
-  (x
-   (error "Usage: indent-code.el FILE [PACKAGE]")))
+(defun main ()
+  (pcase command-line-args-left
+    (`(,file-name ,package-name)
+     ;; Indent the definition of PACKAGE-NAME in FILE-NAME.
+     (find-file file-name)
+     (goto-char (point-min))
+     (if (re-search-forward (concat "^(define\\(-public\\) +"
+                                    package-name)
+                            nil t)
+         (let ((indent-tabs-mode nil))
+           (beginning-of-defun)
+           (indent-sexp)
+           (save-buffer)
+           (message "Done!"))
+       (error "Package '%s' not found in '%s'"
+              package-name file-name)))
+    (`(,file-name)
+     ;; Indent all of FILE-NAME.
+     (find-file file-name)
+     (let ((indent-tabs-mode nil))
+       (indent-region (point-min) (point-max))
+       (save-buffer)
+       (message "Done!")))
+    (x
+     (error "Usage: indent-code.el FILE [PACKAGE]"))))
 
 ;;; indent-code.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]