From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: [PATCH] emacs: devel: Add indentation rules for 'modify-phases' keywords. Date: Sat, 17 Oct 2015 19:39:45 +0300 Message-ID: <87d1wdsb3i.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59145) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnUWK-0001Eu-Me for guix-devel@gnu.org; Sat, 17 Oct 2015 12:39:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZnUWF-0000ih-JV for guix-devel@gnu.org; Sat, 17 Oct 2015 12:39:48 -0400 Received: from mail-lb0-x22f.google.com ([2a00:1450:4010:c04::22f]:36621) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnUWF-0000ic-Aw for guix-devel@gnu.org; Sat, 17 Oct 2015 12:39:43 -0400 Received: by lbcao8 with SMTP id ao8so117681541lbc.3 for ; Sat, 17 Oct 2015 09:39:42 -0700 (PDT) Received: from leviafan ([217.107.192.146]) by smtp.gmail.com with ESMTPSA id y204sm3820592lfd.6.2015.10.17.09.39.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Oct 2015 09:39:41 -0700 (PDT) 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-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org --=-=-= Content-Type: text/plain Hello, currently Emacs indents our 'modify-phases' macro like this: --=-=-= Content-Type: text/x-scheme Content-Disposition: inline (modify-phases %standard-phases (add-before 'build 'foo-phase (lambda _ 'foo))) --=-=-= Content-Type: text/plain or this: --=-=-= Content-Type: text/x-scheme Content-Disposition: inline (modify-phases %standard-phases (add-before 'build 'foo-phase (lambda _ 'foo))) --=-=-= Content-Type: text/plain While IMHO it is better to have it indented like this: --=-=-= Content-Type: text/x-scheme Content-Disposition: inline (modify-phases %standard-phases (add-before 'build 'foo-phase (lambda _ 'foo))) --=-=-= Content-Type: text/plain This patch will do it. Of course we can just use: (put 'replace 'scheme-indent-function 1) (put 'add-after 'scheme-indent-function 2) (put 'add-before 'scheme-indent-function 2) But potentially these keywords may also be used outside 'modify-phases'. So with the attached more complex rules, 'replace', 'add-before' and 'add-after' keywords will be indented specially only when they are inside 'modify-phases', otherwise they will be indented as usual: --=-=-= Content-Type: text/x-scheme Content-Disposition: inline (modify-phases %standard-phases (replace 'build (lambda _ (zero? 0)))) (do-something (replace 'this 'that 'and-that)) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-emacs-devel-Add-indentation-rules-for-modify-phases-.patch >From 092dbb4460cf140c628eb4aeb4c5fff8f0083b3c Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Sat, 17 Oct 2015 19:02:39 +0300 Subject: [PATCH] emacs: devel: Add indentation rules for 'modify-phases' keywords. * emacs/guix-devel.el: Add indentation rules for 'modify-phases' keywords. (guix-devel-indent-modify-phases-keyword, guix-devel-indent-modify-phases-keyword-1, guix-devel-indent-modify-phases-keyword-2): New functions. --- emacs/guix-devel.el | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/emacs/guix-devel.el b/emacs/guix-devel.el index f3ad4b9..170ce1a 100644 --- a/emacs/guix-devel.el +++ b/emacs/guix-devel.el @@ -254,6 +254,20 @@ Each rule should have a form (SYMBOL VALUE). See `put' for details." 0))) (lisp-indent-specform count state indent-point normal-indent))) +(defun guix-devel-indent-modify-phases-keyword (count) + "Return indentation function for 'modify-phases' keywords." + (lambda (state indent-point normal-indent) + (when (ignore-errors + (goto-char (nth 1 state)) ; start of keyword sexp + (backward-up-list) + (looking-at "(modify-phases\\>")) + (lisp-indent-specform count state indent-point normal-indent)))) + +(defalias 'guix-devel-indent-modify-phases-keyword-1 + (guix-devel-indent-modify-phases-keyword 1)) +(defalias 'guix-devel-indent-modify-phases-keyword-2 + (guix-devel-indent-modify-phases-keyword 2)) + (guix-devel-scheme-indent (bag 0) (build-system 0) @@ -293,7 +307,12 @@ Each rule should have a form (SYMBOL VALUE). See `put' for details." (with-monad 1) (with-mutex 1) (with-store 1) - (wrap-program 1)) + (wrap-program 1) + + ;; 'modify-phases' keywords: + (replace 'guix-devel-indent-modify-phases-keyword-1) + (add-after 'guix-devel-indent-modify-phases-keyword-2) + (add-before 'guix-devel-indent-modify-phases-keyword-2)) (defvar guix-devel-keys-map -- 2.5.0 --=-=-=--