1 :;exec emacs --batch --quick --load="$0" --funcall=main "$@"
2 ;;; indent-code.el --- Run Emacs to indent a package definition.
4 ;; Copyright © 2017 Alex Kost <alezost@gmail.com>
5 ;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
6 ;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
7 ;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;; This file is part of GNU Guix.
11 ;; GNU Guix is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Guix is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
26 ;; This scripts indents the given file or package definition in the specified
31 ;; Load Scheme indentation rules from ".dir-locals.el".
34 (let ((default-directory (file-name-as-directory load-file-name
))
35 (enable-local-variables :all
))
36 (hack-dir-local-variables)
37 (hack-local-variables-apply)))
39 ;; Add indentation info for Scheme constructs that are not Guix-specific.
40 ;; This is normally provided by Geiser but this file is for people who may not
41 ;; be running Geiser, so we just copy it here (from 'geiser-syntax.el').
42 (defmacro guix-syntax--scheme-indent
(&rest pairs
)
43 `(progn ,@(mapcar (lambda (p)
44 `(put ',(car p
) 'scheme-indent-function
',(cadr p
)))
47 (guix-syntax--scheme-indent
61 (match-let scheme-let-indent
)
75 (test-group-with-cleanup 1)
76 (test-runner-on-bad-count! 1)
77 (test-runner-on-bad-end-name! 1)
78 (test-runner-on-final! 1)
79 (test-runner-on-group-begin! 1)
80 (test-runner-on-group-end! 1)
81 (test-runner-on-test-begin! 1)
82 (test-runner-on-test-end! 1)
87 (with-exception-handler 1)
92 (pcase command-line-args-left
93 (`(,file-name
,package-name
)
94 ;; Indent the definition of PACKAGE-NAME in FILE-NAME.
96 (goto-char (point-min))
97 (if (re-search-forward (concat "^(define\\(\\|-public\\) +"
100 (let ((indent-tabs-mode nil
))
105 (error "Package '%s' not found in '%s'"
106 package-name file-name
)))
108 ;; Indent all of FILE-NAME.
109 (find-file file-name
)
110 (let ((indent-tabs-mode nil
))
111 (indent-region (point-min) (point-max))
115 (error "Usage: indent-code.el FILE [PACKAGE]"))))
117 ;;; indent-code.el ends here