unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 40340@debbugs.gnu.org
Subject: [bug#40340] [PATCH] etc: indent-code.el: Use the --quick option.
Date: Tue, 31 Mar 2020 00:41:25 -0400	[thread overview]
Message-ID: <87lfnhxhje.fsf@gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 125 bytes --]

Hello!

I noticed two small annoyances with the indent-code.el script, which are
explained and fixed in the attached patch.


[-- Attachment #1.2: 0001-etc-indent-code.el-Use-the-quick-option.patch --]
[-- Type: text/x-patch, Size: 4815 bytes --]

From ce30a6ceb76595ce0ba87eeb54f0b6624485354f Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Date: Tue, 31 Mar 2020 00:12:01 -0400
Subject: [PATCH] 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(-)
 rename etc/{indent-code.el.in => indent-code.el} (71%)

diff --git a/.gitignore b/.gitignore
index fd2cf56098..cc5ceb5e10 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 6a6a020585..5ed2cf7aa0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -284,15 +284,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 6102b5d1ab..255ffb126b 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 <alezost@gmail.com>
 ;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
+;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 
 ;; This file is part of GNU Guix.
 
@@ -86,29 +87,30 @@
  (with-syntax 1))
 
 \f
-(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
-- 
2.25.2


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

             reply	other threads:[~2020-03-31  4:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-31  4:41 Maxim Cournoyer [this message]
2020-05-13  0:45 ` [bug#40340] [PATCH] etc: indent-code.el: Use the --quick option zimoun
2020-05-15  3:09   ` bug#40340: " Maxim Cournoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lfnhxhje.fsf@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=40340@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).