guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/01: etc: Support indentation of whole files.


From: Ludovic Courtès
Subject: 01/01: etc: Support indentation of whole files.
Date: Fri, 13 Jan 2017 17:49:47 +0000 (UTC)

civodul pushed a commit to branch master
in repository guix.

commit 557d9c8d7a843bf06e75b4e1a742654ccf951fa3
Author: Ludovic Courtès <address@hidden>
Date:   Fri Jan 13 18:47:15 2017 +0100

    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.
---
 .gitignore                                      |    2 +-
 configure.ac                                    |    2 +-
 doc/contributing.texi                           |   11 ++++++++---
 etc/{indent-package.el.in => indent-code.el.in} |   19 ++++++++++++++-----
 4 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/.gitignore b/.gitignore
index 5bcc734..c64326e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -128,4 +128,4 @@ stamp-h[0-9]
 tmp
 /doc/os-config-lightweight-desktop.texi
 /nix/scripts/download
-/etc/indent-package.el
+/etc/indent-code.el
diff --git a/configure.ac b/configure.ac
index f628fa9..9079a14 100644
--- a/configure.ac
+++ b/configure.ac
@@ -245,6 +245,6 @@ AC_CONFIG_FILES([scripts/guix], [chmod +x scripts/guix])
 AC_CONFIG_FILES([test-env:build-aux/test-env.in], [chmod +x test-env])
 AC_CONFIG_FILES([pre-inst-env:build-aux/pre-inst-env.in],
   [chmod +x pre-inst-env])
-AC_CONFIG_FILES([etc/indent-package.el], [chmod +x etc/indent-package.el])
+AC_CONFIG_FILES([etc/indent-code.el], [chmod +x etc/indent-code.el])
 
 AC_OUTPUT
diff --git a/doc/contributing.texi b/doc/contributing.texi
index 9fc1eb5..4454df1 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
 rules.  To automatically indent a package definition, you can also run:
 
 @example
-./etc/indent-package.el gnu/packages/@var{file}.scm @var{package}
+./etc/indent-code.el gnu/packages/@var{file}.scm @var{package}
 @end example
 
 @noindent
 This automatically indents the definition of @var{package} in
address@hidden/packages/@var{file}.scm} by running Emacs in batch mode.
address@hidden/packages/@var{file}.scm} by running Emacs in batch mode.  To
+indent a whole file, omit the second argument:
+
address@hidden
+./etc/indent-code.el gnu/services/@var{file}.scm
address@hidden example
 
 We require all top-level procedures to carry a docstring.  This
 requirement can be relaxed for simple private procedures in the
@@ -374,7 +379,7 @@ or a package update along with fixes to that package.
 
 @item
 Please follow our code formatting rules, possibly running the
address@hidden/indent-package.el} script to do that automatically for you
address@hidden/indent-code.el} script to do that automatically for you
 (@pxref{Formatting Code}).
 
 @end enumerate
diff --git a/etc/indent-package.el.in b/etc/indent-code.el.in
similarity index 73%
rename from etc/indent-package.el.in
rename to etc/indent-code.el.in
index 3188809..7556b30 100755
--- a/etc/indent-package.el.in
+++ b/etc/indent-code.el.in
@@ -1,7 +1,8 @@
 address@hidden@ --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 <address@hidden>
+;; Copyright © 2017 Ludovic Courtès <address@hidden>
 
 ;; 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]