mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
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.
This commit is contained in:
parent
b6d18fbdf6
commit
cb21ae7671
3 changed files with 27 additions and 35 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -149,7 +149,6 @@ stamp-h[0-9]
|
||||||
tmp
|
tmp
|
||||||
/doc/os-config-lightweight-desktop.texi
|
/doc/os-config-lightweight-desktop.texi
|
||||||
/nix/scripts/download
|
/nix/scripts/download
|
||||||
/etc/indent-code.el
|
|
||||||
/.version
|
/.version
|
||||||
/doc/stamp-[0-9]
|
/doc/stamp-[0-9]
|
||||||
/gnu/packages/bootstrap
|
/gnu/packages/bootstrap
|
||||||
|
|
|
@ -286,15 +286,6 @@ dnl Documentation translation.
|
||||||
AM_MISSING_PROG([PO4A_TRANSLATE], [po4a-translate])
|
AM_MISSING_PROG([PO4A_TRANSLATE], [po4a-translate])
|
||||||
AM_MISSING_PROG([PO4A_UPDATEPO], [po4a-updatepo])
|
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
|
case "$storedir" in
|
||||||
/gnu/store)
|
/gnu/store)
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
#!@EMACS@ --script
|
:;exec emacs --batch --quick --load="$0" --funcall=main "$@"
|
||||||
;;; indent-code.el --- Run Emacs to indent a package definition.
|
;;; indent-code.el --- Run Emacs to indent a package definition.
|
||||||
|
|
||||||
;; Copyright © 2017 Alex Kost <alezost@gmail.com>
|
;; Copyright © 2017 Alex Kost <alezost@gmail.com>
|
||||||
;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
|
;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
|
||||||
|
;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
||||||
|
|
||||||
;; This file is part of GNU Guix.
|
;; This file is part of GNU Guix.
|
||||||
|
|
||||||
|
@ -86,29 +87,30 @@
|
||||||
(with-syntax 1))
|
(with-syntax 1))
|
||||||
|
|
||||||
|
|
||||||
(pcase command-line-args-left
|
(defun main ()
|
||||||
(`(,file-name ,package-name)
|
(pcase command-line-args-left
|
||||||
;; Indent the definition of PACKAGE-NAME in FILE-NAME.
|
(`(,file-name ,package-name)
|
||||||
(find-file file-name)
|
;; Indent the definition of PACKAGE-NAME in FILE-NAME.
|
||||||
(goto-char (point-min))
|
(find-file file-name)
|
||||||
(if (re-search-forward (concat "^(define\\(-public\\) +"
|
(goto-char (point-min))
|
||||||
package-name)
|
(if (re-search-forward (concat "^(define\\(-public\\) +"
|
||||||
nil t)
|
package-name)
|
||||||
(let ((indent-tabs-mode nil))
|
nil t)
|
||||||
(beginning-of-defun)
|
(let ((indent-tabs-mode nil))
|
||||||
(indent-sexp)
|
(beginning-of-defun)
|
||||||
(save-buffer)
|
(indent-sexp)
|
||||||
(message "Done!"))
|
(save-buffer)
|
||||||
(error "Package '%s' not found in '%s'"
|
(message "Done!"))
|
||||||
package-name file-name)))
|
(error "Package '%s' not found in '%s'"
|
||||||
(`(,file-name)
|
package-name file-name)))
|
||||||
;; Indent all of FILE-NAME.
|
(`(,file-name)
|
||||||
(find-file file-name)
|
;; Indent all of FILE-NAME.
|
||||||
(let ((indent-tabs-mode nil))
|
(find-file file-name)
|
||||||
(indent-region (point-min) (point-max))
|
(let ((indent-tabs-mode nil))
|
||||||
(save-buffer)
|
(indent-region (point-min) (point-max))
|
||||||
(message "Done!")))
|
(save-buffer)
|
||||||
(x
|
(message "Done!")))
|
||||||
(error "Usage: indent-code.el FILE [PACKAGE]")))
|
(x
|
||||||
|
(error "Usage: indent-code.el FILE [PACKAGE]"))))
|
||||||
|
|
||||||
;;; indent-code.el ends here
|
;;; indent-code.el ends here
|
Loading…
Reference in a new issue