From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:35827) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJ8ix-0006en-Ul for guix-patches@gnu.org; Tue, 31 Mar 2020 00:42:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJ8iw-0003Da-FW for guix-patches@gnu.org; Tue, 31 Mar 2020 00:42:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:52059) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jJ8iv-0003Cy-UR for guix-patches@gnu.org; Tue, 31 Mar 2020 00:42:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jJ8iv-0001f7-RY for guix-patches@gnu.org; Tue, 31 Mar 2020 00:42:01 -0400 Subject: [bug#40340] [PATCH] etc: indent-code.el: Use the --quick option. Resent-Message-ID: Received: from eggs.gnu.org ([2001:470:142:3::10]:35801) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJ8iT-0006e2-HW for guix-patches@gnu.org; Tue, 31 Mar 2020 00:41:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJ8iP-0002ih-Se for guix-patches@gnu.org; Tue, 31 Mar 2020 00:41:33 -0400 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]:36230) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jJ8iP-0002iJ-Mx for guix-patches@gnu.org; Tue, 31 Mar 2020 00:41:29 -0400 Received: by mail-qt1-x830.google.com with SMTP id m33so17281852qtb.3 for ; Mon, 30 Mar 2020 21:41:29 -0700 (PDT) Received: from hurd (dsl-159-222.b2b2c.ca. [66.158.159.222]) by smtp.gmail.com with ESMTPSA id k124sm12140660qke.108.2020.03.30.21.41.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2020 21:41:27 -0700 (PDT) From: Maxim Cournoyer Date: Tue, 31 Mar 2020 00:41:25 -0400 Message-ID: <87lfnhxhje.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 40340@debbugs.gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Hello! I noticed two small annoyances with the indent-code.el script, which are explained and fixed in the attached patch. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-etc-indent-code.el-Use-the-quick-option.patch Content-Transfer-Encoding: quoted-printable From=20ce30a6ceb76595ce0ba87eeb54f0b6624485354f Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer 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. =2D-- .gitignore | 1 - configure.ac | 9 ---- etc/{indent-code.el.in =3D> indent-code.el} | 52 ++++++++++++----------- 3 files changed, 27 insertions(+), 35 deletions(-) rename etc/{indent-code.el.in =3D> indent-code.el} (71%) diff --git a/.gitignore b/.gitignore index fd2cf56098..cc5ceb5e10 100644 =2D-- a/.gitignore +++ b/.gitignore @@ -149,7 +149,6 @@ stamp-h[0-9] tmp /doc/os-config-lightweight-desktop.texi /nix/scripts/download =2D/etc/indent-code.el /.version /doc/stamp-[0-9] /gnu/packages/bootstrap diff --git a/configure.ac b/configure.ac index 6a6a020585..5ed2cf7aa0 100644 =2D-- 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]) =20 =2Ddnl Emacs (optional), for 'etc/indent-code.el'. =2DAC_PATH_PROG([EMACS], [emacs]) =2Dif test "x$EMACS" =3D x; then =2D AC_MSG_WARN([Please install GNU Emacs to use etc/indent-code.el.]) =2Delse =2D AC_SUBST([EMACS]) =2D AC_CONFIG_FILES([etc/indent-code.el], [chmod +x etc/indent-code.el]) =2Dfi =2D 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 =2D-- a/etc/indent-code.el.in +++ b/etc/indent-code.el @@ -1,8 +1,9 @@ =2D#!@EMACS@ --script +:;exec emacs --batch --quick --load=3D"$0" --funcall=3Dmain "$@" ;;; indent-code.el --- Run Emacs to indent a package definition. =20 ;; Copyright =C2=A9 2017 Alex Kost ;; Copyright =C2=A9 2017 Ludovic Court=C3=A8s +;; Copyright =C2=A9 2020 Maxim Cournoyer =20 ;; This file is part of GNU Guix. =20 @@ -86,29 +87,30 @@ (with-syntax 1)) =20 =2D(pcase command-line-args-left =2D (`(,file-name ,package-name) =2D ;; Indent the definition of PACKAGE-NAME in FILE-NAME. =2D (find-file file-name) =2D (goto-char (point-min)) =2D (if (re-search-forward (concat "^(define\\(-public\\) +" =2D package-name) =2D nil t) =2D (let ((indent-tabs-mode nil)) =2D (beginning-of-defun) =2D (indent-sexp) =2D (save-buffer) =2D (message "Done!")) =2D (error "Package '%s' not found in '%s'" =2D package-name file-name))) =2D (`(,file-name) =2D ;; Indent all of FILE-NAME. =2D (find-file file-name) =2D (let ((indent-tabs-mode nil)) =2D (indent-region (point-min) (point-max)) =2D (save-buffer) =2D (message "Done!"))) =2D (x =2D (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]")))) =20 ;;; indent-code.el ends here =2D-=20 2.25.2 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----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----- --==-=-=--