From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: Re: indent with emacs batch mode Date: Sun, 08 Jan 2017 16:32:25 +0300 Message-ID: <87zij11xue.fsf@gmail.com> References: <87y3yocil2.fsf@elephly.net> <87inpr8l6y.fsf@gmail.com> <87shovcowr.fsf@elephly.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQDaM-00074Y-OO for guix-devel@gnu.org; Sun, 08 Jan 2017 08:32:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cQDaH-0002OI-W4 for guix-devel@gnu.org; Sun, 08 Jan 2017 08:32:34 -0500 Received: from mail-lf0-x234.google.com ([2a00:1450:4010:c07::234]:36753) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cQDaH-0002Mv-Ob for guix-devel@gnu.org; Sun, 08 Jan 2017 08:32:29 -0500 Received: by mail-lf0-x234.google.com with SMTP id o140so25137595lff.3 for ; Sun, 08 Jan 2017 05:32:28 -0800 (PST) List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Ricardo Wurmus Cc: guix-devel --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ricardo Wurmus (2017-01-07 08:25 +0100) wrote: > Alex Kost wrote: > >> All that stuff can work without 'emacs-guix' (if the line with >> 'guix-devel-mode' scheme hook will be removed), but in this case the >> package may not be indented properly. > > Guix still comes with a =E2=80=9C.dir-locals.el=E2=80=9D that specifies t= he indentation > rules, doesn=E2=80=99t it? Can we use that? Oof, it took me some time to figure it out :-) So here is the version that requires only emacs and ".dir-locals.el" file from the git repo: --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline; filename=indent-package-expr.el Content-Transfer-Encoding: quoted-printable ;; Load Scheme indentation rules from "~/src/guix/.dir-locals.el". (with-temp-buffer (scheme-mode) (let ((default-directory (file-name-as-directory "~/src/guix")) (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) (progn (beginning-of-defun) (indent-sexp) (save-buffer) (message "Done!")) (error "Package '%s' not found in '%s'" package-name file-name)))) --=-=-= Content-Type: text/plain Emacs can be run like this: emacs -Q --batch -l indent-package-expr.el package-file.scm package-name The only downside of ".dir-locals.el", is that it doesn't contain indentation rules for 'modify-phases' keywords (replace, add-after, add-before). Maybe they should be added there, but OTOH "replace" looks like a too general name, so if a user has some code with "replace" procedure, (s)he wouldn't be pleased when it will be indented strangely. That's why "guix-devel.el" has a code that indents these keywords only when they are inside 'modify-phases'. -- Alex --=-=-=--