aboutsummaryrefslogtreecommitdiff
path: root/etc
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 /etc
parent608a50b66c73d5bdfd224195b839e01b781c354c (diff)
downloadguix-557d9c8d7a843bf06e75b4e1a742654ccf951fa3.tar.gz
guix-557d9c8d7a843bf06e75b4e1a742654ccf951fa3.zip
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.
Diffstat (limited to 'etc')
-rwxr-xr-xetc/indent-code.el.in (renamed from etc/indent-package.el.in)19
1 files changed, 14 insertions, 5 deletions
diff --git a/etc/indent-package.el.in b/etc/indent-code.el.in
index 3188809f0b..7556b30cc8 100755
--- a/etc/indent-package.el.in
+++ b/etc/indent-code.el.in
@@ -1,7 +1,8 @@
#!@EMACS@ --script
-;;; indent-package.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 Ludovic Courtès <ludo@gnu.org>
;; This file is part of GNU Guix.
@@ -20,8 +21,8 @@
;;; Commentary:
-;; This scripts indents the given package definition in the specified file
-;; using Emacs.
+;; This scripts indents the given file or package definition in the specified
+;; file using Emacs.
;;; Code:
@@ -35,6 +36,7 @@
(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\\) +"
@@ -47,7 +49,14 @@
(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-package.el FILE PACKAGE")))
+ (error "Usage: indent-code.el FILE [PACKAGE]")))
-;;; indent-package.el ends here
+;;; indent-code.el ends here