From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: [PATCH] emacs: devel: Add indentation rules. Date: Mon, 12 Oct 2015 12:33:24 +0300 Message-ID: <87y4f8bfdn.fsf_-_@gmail.com> References: <871tdm6i0i.fsf@gmail.com> <8737y28fss.fsf@gnu.org> <87d1x57yhg.fsf@gmail.com> <87si5zwqqu.fsf@gnu.org> <878u7qybjn.fsf_-_@gmail.com> <87r3lhxchs.fsf@gnu.org> <87d1wyqoqw.fsf@gmail.com> <87wpv6l1d8.fsf@gnu.org> <87h9m9xwsf.fsf@gmail.com> <87a8s1e8mg.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZlZU8-0006DR-RP for guix-devel@gnu.org; Mon, 12 Oct 2015 05:33:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZlZU4-0008AQ-66 for guix-devel@gnu.org; Mon, 12 Oct 2015 05:33:36 -0400 In-Reply-To: <87a8s1e8mg.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Fri, 02 Oct 2015 14:51:35 +0200") 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: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s (2015-10-02 15:51 +0300) wrote: > Alex Kost skribis: > >> I thought that most people (except me) agreed that indentation rules >> should stay in ".dir-locals.el", so I don't see a reason why they also >> need to be duplicated in "guix-devel.el". > > It=E2=80=99s interesting to have them in .dir-locals.el for people who ha= ck Guix > itself. > > But it=E2=80=99s also interesting to have them in guix-devel.el for peopl= e who > maintain, say, their own package collection outside of the Guix repo. So here it is. I added indentations only for Guix stuff, as I think that general Guile things (like 'lambda*' or 'eval-when') shouldn't be handled by a Guix emacs library. BTW, all of these Guile things will be highlighted/indented properly by Geiser 0.8 (see [1], [2]). [1] https://github.com/jaor/geiser/pull/98 [2] https://github.com/jaor/geiser/pull/102 --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-emacs-devel-Add-indentation-rules.patch Content-Transfer-Encoding: quoted-printable >From a878a1fa51cb8072f7af55309ce457d1425841c6 Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Mon, 12 Oct 2015 12:06:32 +0300 Subject: [PATCH] emacs: devel: Add indentation rules. MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit Suggested by Ludovic Court=C3=A8s . * emacs/guix-devel.el: Add indentation rules for Guix macros/procedures. (guix-devel-scheme-indent): New macro. (guix-devel-indent-package): New function. --- emacs/guix-devel.el | 64 +++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 64 insertions(+) diff --git a/emacs/guix-devel.el b/emacs/guix-devel.el index b833028..a79b7b1 100644 --- a/emacs/guix-devel.el +++ b/emacs/guix-devel.el @@ -24,6 +24,7 @@ =20 ;;; Code: =20 +(require 'lisp-mode) (require 'guix-guile) (require 'guix-geiser) (require 'guix-utils) @@ -189,6 +190,69 @@ to find 'modify-phases' keywords." "A list of `font-lock-keywords' for `guix-devel-mode'.") =20 +;;; Indentation + +(defmacro guix-devel-scheme-indent (&rest rules) + "Set `scheme-indent-function' according to rules. +Each rule should have a form (SYMBOL VALUE). See `put' for details." + (declare (indent 0)) + `(progn + ,@(mapcar (lambda (rule) + `(put ',(car rule) 'scheme-indent-function ,(cadr rule))) + rules))) + +(defun guix-devel-indent-package (state indent-point normal-indent) + "Indentation rule for 'package' form." + (let* ((package-eol (line-end-position)) + (count (if (and (ignore-errors (down-list) t) + (< (point) package-eol) + (looking-at "inherit\\>")) + 1 + 0))) + (lisp-indent-specform count state indent-point normal-indent))) + +(guix-devel-scheme-indent + (bag 0) + (build-system 0) + (call-with-compressed-output-port 2) + (call-with-container 1) + (call-with-decompressed-port 2) + (call-with-error-handling 0) + (container-excursion 1) + (emacs-batch-edit-file 1) + (emacs-batch-eval 0) + (emacs-substitute-sexps 1) + (emacs-substitute-variables 1) + (file-system 0) + (graft 0) + (manifest-entry 0) + (manifest-pattern 0) + (mbegin 1) + (mlet 2) + (mlet* 2) + (modify-phases 1) + (munless 1) + (mwhen 1) + (operating-system 0) + (origin 0) + (package 'guix-devel-indent-package) + (run-with-state 1) + (run-with-store 1) + (signature-case 1) + (substitute* 1) + (substitute-keyword-arguments 1) + (test-assertm 1) + (with-atomic-file-output 1) + (with-derivation-narinfo 1) + (with-derivation-substitute 2) + (with-directory-excursion 1) + (with-error-handling 0) + (with-monad 1) + (with-mutex 1) + (with-store 1) + (wrap-program 1)) + + (defvar guix-devel-keys-map (let ((map (make-sparse-keymap))) (define-key map (kbd "b") 'guix-devel-build-package-definition) --=20 2.5.0 --=-=-=--