summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-01-12 14:56:52 +0100
committerLudovic Courtès <ludo@gnu.org>2017-01-12 14:56:52 +0100
commit7bb2b10cd01a076d7d5e964ed433e62846042859 (patch)
treed1d6958d31e2814f1969d23417e8fec8da8bf575 /etc
parenta91740655c8d18cd1b266d4d5719146cfeaf400d (diff)
downloadpatches-7bb2b10cd01a076d7d5e964ed433e62846042859.tar
patches-7bb2b10cd01a076d7d5e964ed433e62846042859.tar.gz
etc: Add 'indent-package.el' script.
* configure.ac: Check for 'emacs', substitute 'EMACS', and emit 'etc/indent-package.el'. * etc/indent-package.el.in: New file. * doc/contributing.texi (Formatting Code): Mention 'etc/indent-package.el'. (Submitting Patches): Likewise, and link to the above node. Co-authored-by: Alex Kost <alezost@gmail.com>
Diffstat (limited to 'etc')
-rwxr-xr-xetc/indent-package.el.in53
1 files changed, 53 insertions, 0 deletions
diff --git a/etc/indent-package.el.in b/etc/indent-package.el.in
new file mode 100755
index 0000000000..3188809f0b
--- /dev/null
+++ b/etc/indent-package.el.in
@@ -0,0 +1,53 @@
+#!@EMACS@ --script
+;;; indent-package.el --- Run Emacs to indent a package definition.
+
+;; Copyright © 2017 Alex Kost <alezost@gmail.com>
+
+;; This file is part of GNU Guix.
+
+;; GNU Guix is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Guix is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This scripts indents the given package definition in the specified file
+;; using Emacs.
+
+;;; Code:
+
+;; Load Scheme indentation rules from the current directory.
+(with-temp-buffer
+ (scheme-mode)
+ (let ((default-directory (file-name-as-directory "."))
+ (enable-local-variables :all))
+ (hack-dir-local-variables)
+ (hack-local-variables-apply)))
+
+(pcase command-line-args-left
+ (`(,file-name ,package-name)
+ (find-file file-name)
+ (goto-char (point-min))
+ (if (re-search-forward (concat "^(define\\(-public\\) +"
+ package-name)
+ nil t)
+ (let ((indent-tabs-mode nil))
+ (beginning-of-defun)
+ (indent-sexp)
+ (save-buffer)
+ (message "Done!"))
+ (error "Package '%s' not found in '%s'"
+ package-name file-name)))
+ (x
+ (error "Usage: indent-package.el FILE PACKAGE")))
+
+;;; indent-package.el ends here