summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-01-13 18:47:15 +0100
committerLudovic Courtès <ludo@gnu.org>2017-01-13 18:49:31 +0100
commit557d9c8d7a843bf06e75b4e1a742654ccf951fa3 (patch)
treedcd96026be9c5c408ed08f9f3061962c00d0d39d
parent608a50b66c73d5bdfd224195b839e01b781c354c (diff)
etc: Support indentation of whole files.
* etc/indent-package.el.in: Rename to... * etc/indent-code.el.in: ... this. Add case for a single argument. * doc/contributing.texi (Formatting Code): Adjust accordingly. * configure.ac: Likewise.
-rw-r--r--.gitignore2
-rw-r--r--configure.ac2
-rw-r--r--doc/contributing.texi11
-rwxr-xr-xetc/indent-code.el.in (renamed from etc/indent-package.el.in)19
4 files changed, 24 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index 5bcc734ac52..c64326e60e8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -128,4 +128,4 @@ stamp-h[0-9]
128tmp 128tmp
129/doc/os-config-lightweight-desktop.texi 129/doc/os-config-lightweight-desktop.texi
130/nix/scripts/download 130/nix/scripts/download
131/etc/indent-package.el 131/etc/indent-code.el
diff --git a/configure.ac b/configure.ac
index f628fa9d0d2..9079a142dc5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -245,6 +245,6 @@ AC_CONFIG_FILES([scripts/guix], [chmod +x scripts/guix])
245AC_CONFIG_FILES([test-env:build-aux/test-env.in], [chmod +x test-env]) 245AC_CONFIG_FILES([test-env:build-aux/test-env.in], [chmod +x test-env])
246AC_CONFIG_FILES([pre-inst-env:build-aux/pre-inst-env.in], 246AC_CONFIG_FILES([pre-inst-env:build-aux/pre-inst-env.in],
247 [chmod +x pre-inst-env]) 247 [chmod +x pre-inst-env])
248AC_CONFIG_FILES([etc/indent-package.el], [chmod +x etc/indent-package.el]) 248AC_CONFIG_FILES([etc/indent-code.el], [chmod +x etc/indent-code.el])
249 249
250AC_OUTPUT 250AC_OUTPUT
diff --git a/doc/contributing.texi b/doc/contributing.texi
index 9fc1eb54d85..4454df1f983 100644
--- a/doc/contributing.texi
+++ b/doc/contributing.texi
@@ -256,12 +256,17 @@ If you do not use Emacs, please make sure to let your editor knows these
256rules. To automatically indent a package definition, you can also run: 256rules. To automatically indent a package definition, you can also run:
257 257
258@example 258@example
259./etc/indent-package.el gnu/packages/@var{file}.scm @var{package} 259./etc/indent-code.el gnu/packages/@var{file}.scm @var{package}
260@end example 260@end example
261 261
262@noindent 262@noindent
263This automatically indents the definition of @var{package} in 263This automatically indents the definition of @var{package} in
264@file{gnu/packages/@var{file}.scm} by running Emacs in batch mode. 264@file{gnu/packages/@var{file}.scm} by running Emacs in batch mode. To
265indent a whole file, omit the second argument:
266
267@example
268./etc/indent-code.el gnu/services/@var{file}.scm
269@end example
265 270
266We require all top-level procedures to carry a docstring. This 271We require all top-level procedures to carry a docstring. This
267requirement can be relaxed for simple private procedures in the 272requirement can be relaxed for simple private procedures in the
@@ -374,7 +379,7 @@ or a package update along with fixes to that package.
374 379
375@item 380@item
376Please follow our code formatting rules, possibly running the 381Please follow our code formatting rules, possibly running the
377@command{etc/indent-package.el} script to do that automatically for you 382@command{etc/indent-code.el} script to do that automatically for you
378(@pxref{Formatting Code}). 383(@pxref{Formatting Code}).
379 384
380@end enumerate 385@end enumerate
diff --git a/etc/indent-package.el.in b/etc/indent-code.el.in
index 3188809f0b4..7556b30cc84 100755
--- a/etc/indent-package.el.in
+++ b/etc/indent-code.el.in
@@ -1,7 +1,8 @@
1#!@EMACS@ --script 1#!@EMACS@ --script
2;;; indent-package.el --- Run Emacs to indent a package definition. 2;;; indent-code.el --- Run Emacs to indent a package definition.
3 3
4;; Copyright © 2017 Alex Kost <alezost@gmail.com> 4;; Copyright © 2017 Alex Kost <alezost@gmail.com>
5;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
5 6
6;; This file is part of GNU Guix. 7;; This file is part of GNU Guix.
7 8
@@ -20,8 +21,8 @@
20 21
21;;; Commentary: 22;;; Commentary:
22 23
23;; This scripts indents the given package definition in the specified file 24;; This scripts indents the given file or package definition in the specified
24;; using Emacs. 25;; file using Emacs.
25 26
26;;; Code: 27;;; Code:
27 28
@@ -35,6 +36,7 @@
35 36
36(pcase command-line-args-left 37(pcase command-line-args-left
37 (`(,file-name ,package-name) 38 (`(,file-name ,package-name)
39 ;; Indent the definition of PACKAGE-NAME in FILE-NAME.
38 (find-file file-name) 40 (find-file file-name)
39 (goto-char (point-min)) 41 (goto-char (point-min))
40 (if (re-search-forward (concat "^(define\\(-public\\) +" 42 (if (re-search-forward (concat "^(define\\(-public\\) +"
@@ -47,7 +49,14 @@
47 (message "Done!")) 49 (message "Done!"))
48 (error "Package '%s' not found in '%s'" 50 (error "Package '%s' not found in '%s'"
49 package-name file-name))) 51 package-name file-name)))
52 (`(,file-name)
53 ;; Indent all of FILE-NAME.
54 (find-file file-name)
55 (let ((indent-tabs-mode nil))
56 (indent-region (point-min) (point-max))
57 (save-buffer)
58 (message "Done!")))
50 (x 59 (x
51 (error "Usage: indent-package.el FILE PACKAGE"))) 60 (error "Usage: indent-code.el FILE [PACKAGE]")))
52 61
53;;; indent-package.el ends here 62;;; indent-code.el ends here