[PATCH] etc: indent-code.el: Use the --quick option.

  • Done
  • quality assurance status badge
Details
2 participants
  • Maxim Cournoyer
  • zimoun
Owner
unassigned
Submitted by
Maxim Cournoyer
Severity
normal
M
M
Maxim Cournoyer wrote on 31 Mar 2020 06:41
(name . guix-patches)(address . guix-patches@gnu.org)
87lfnhxhje.fsf@gmail.com
Hello!

I noticed two small annoyances with the indent-code.el script, which are
explained and fixed in the attached patch.
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

* 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%)

Toggle diff (107 lines)
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))
-(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
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEJ9WGpPiQCFQyn/CfEmDkZILmNWIFAl6CyfUACgkQEmDkZILm
NWJeDA//W1oD7Pz8hd59dh1HZqSG2M2FlgY6I8d8iwOPDTr7bZ0TrP4qodCjlUEH
utQ54+YlaYHB7JqD0DOckTqJlcArnqap9j0QiQOE1S+b6Lz+8L72YS04ia7gx1Nd
hqO2tc9HceZvSNRkBem8CvMNOp9Ivki+Faa3GknCA2g9JXhU0A93zKgyo03V91s9
GhBKaBOqJACuBRQ1jxKsO4dOuiNuYR9VoSaeTO1Q76I7tRqIo12sE+9ew/DKRLQD
TN8vy+RgJ9mXYdzPKzAsfEZovTalfMQ+ORQ5ohmBj01B41lMvPM7m52ltUIvJqEH
L9uEGQjWATf0DGLebA7uvpp5WtP67iBIZICE+ITNo8iW1k4Gr2UWy5oQmc/FniIi
rXBGFC5cBsl0pdI7fu1aumgqbG8wWk5Ea3QsYWKQ4pAhrmumnXjWWL55IoVDvlqW
TaOLr7HEkmAYEDIDS49pjyG6PELObK8H8xvQBdmAfTWKqePB7pMrtV5ZhunCcHO2
0TCNBZ0dSjO79KW5U/5o080ecY+IudtxE0wgXU0tDIG+uu3RrAiG8FCIFC4CtYyJ
+KsI8yoSs680r2QoTfW/7qwbQTlc8kum6KVw1nLoyrlr5pWs5ThjAT182c6+YH/F
1tWQZcFjXl8vJqW0yiIuPRbJQXGnSxhxs8DekaAnlK3mxPYuAaU=
=fVXt
-----END PGP SIGNATURE-----

Z
Z
zimoun wrote on 13 May 2020 02:45
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . 40340@debbugs.gnu.org)
CAJ3okZ019sfmNRGo5K2Kb=mNsgOBGTd9rc94hLCWrQ7hPjfQhQ@mail.gmail.com
Hi Maxim,

On Tue, 31 Mar 2020 at 06:42, Maxim Cournoyer <maxim.cournoyer@gmail.com> wrote:

Toggle quote (3 lines)
> * configure.ac: Remove the warning about Emacs. Emacs can now be installed
> any time by the user if they want to use the script.

The point of this warning was to inform (teach) the user if they does
not know how to use 'etc/indent-code.el'; basically newcomers which do
not use Emacs and do not read manual cover to cover.
Well, maybe it is not useful since the manual already explains [1] and
this message is meaningful by itself:

Toggle snippet (4 lines)
./etc/indent-code.el gnu/packages/maths.scm
./etc/indent-code.el: line 1: exec: emacs: not found



Thank you for the improvement.

All the best,
simon
M
M
Maxim Cournoyer wrote on 15 May 2020 05:09
(name . zimoun)(address . zimon.toutoune@gmail.com)(address . 40340-done@debbugs.gnu.org)
87eerldhd4.fsf@gmail.com
Hello Simon,

zimoun <zimon.toutoune@gmail.com> writes:

Toggle quote (21 lines)
> Hi Maxim,
>
> On Tue, 31 Mar 2020 at 06:42, Maxim Cournoyer <maxim.cournoyer@gmail.com> wrote:
>
>> * configure.ac: Remove the warning about Emacs. Emacs can now be installed
>> any time by the user if they want to use the script.
>
> The point of this warning was to inform (teach) the user if they does
> not know how to use 'etc/indent-code.el'; basically newcomers which do
> not use Emacs and do not read manual cover to cover.
> Well, maybe it is not useful since the manual already explains [1] and
> this message is meaningful by itself:
>
> ./etc/indent-code.el gnu/packages/maths.scm
> ./etc/indent-code.el: line 1: exec: emacs: not found
>
> [1] https://guix.gnu.org/manual/devel/en/guix.html#Formatting-Code
>
>
> Thank you for the improvement.

The warning was indeed useful before this change, as the script was not
generated in the event Emacs was not found at configuration time. Now
that the script is always available, it can be removed.

I went ahead and merged this as commit cb21ae7671.

Thank you for taking a look :-).

Maxim
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 40340@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 40340
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch