From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: Re: [PATCH] emacs: devel: Highlight 'modify-phases' keywords. Date: Sat, 26 Sep 2015 22:48:59 +0300 Message-ID: <87d1x57yhg.fsf@gmail.com> References: <871tdm6i0i.fsf@gmail.com> <8737y28fss.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfvSv-0000Qc-Nw for guix-devel@gnu.org; Sat, 26 Sep 2015 15:49:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfvSs-0006t3-HH for guix-devel@gnu.org; Sat, 26 Sep 2015 15:49:01 -0400 In-Reply-To: <8737y28fss.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Fri, 25 Sep 2015 21:22:43 +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-09-25 22:22 +0300) wrote: > Alex Kost skribis: > >> From ed1c3871b81d4904d106a3ca5aadde2e1803d2a6 Mon Sep 17 00:00:00 2001 >> From: Alex Kost >> Date: Thu, 24 Sep 2015 20:10:29 +0300 >> Subject: [PATCH] emacs: devel: Highlight 'modify-phases' keywords. >> >> * emacs/guix-guile.el (guix-guile-keyword-regexp): New function. >> * emacs/guix-devel.el (guix-devel-faces): New custom group. >> (guix-devel-modify-phases-keyword): New face. >> (guix-devel-modify-phases-keyword-regexp, >> guix-devel-font-lock-keywords): New variables. >> (guix-devel-modify-phases-font-lock-matcher, >> guix-devel-modify-phases-font-lock-pre): New functions. >> (guix-devel-mode): Adjust to add/remove font-lock-keywords. > > OK! Thanks, I have pushed it. > I also have this one that I find useful: > > ;; For Guix g-expressions. > (font-lock-add-keywords 'scheme-mode > '(("#~" . font-lock-keyword-face) > ("#\\$" . font-lock-keyword-face) > ("#\\+" . font-lock-keyword-face))) Great, what about the attached patch for adding these ones? > Similarly .dir-locals.el has =E2=80=98modify-syntax-entry=E2=80=99 stuff = for gexps that > could maybe go to guix-devel.el? Yes, they could. So as you mention it, there is another thing I would like to add =E2=80=94 complex indentation rules. Specifically, inherited packages are automatically indented like this: (package (inherit foo) (name "foo") ...) or this: (package (inherit foo) (name "foo") ...) while we want it to be: (package (inherit foo) (name "foo") ...) The following code may be used to handle this indentation: --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline; filename=package-indent.el Content-Transfer-Encoding: quoted-printable (defun guix-devel-package-indent (state indent-point normal-indent) (let ((count (if (and (ignore-errors (down-list) t) (looking-at "inherit\\>")) 1 0))) (lisp-indent-specform count state indent-point normal-indent))) (put 'package 'scheme-indent-function 'guix-devel-package-indent) --=-=-= Content-Type: text/plain But it wouldn't work reliably because of ".dir-locals.el", as 'scheme-indent-function' property will be overridden every time a scheme file from git repo is visited. So my proposition is: what about moving all indentation rules from ".dir-locals.el" to "emacs/guix-devel.el"? So 'guix-devel-mode' will be responsible for all indenting, highlighting and other guix-specific things. WDYT? --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-emacs-devel-Highlight-gexp-symbols.patch Content-Transfer-Encoding: quoted-printable >From 13ebd00178d1f6139da4c1f76a2e358935ce16f0 Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Sat, 26 Sep 2015 22:42:07 +0300 Subject: [PATCH] emacs: devel: Highlight gexp symbols. 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 (guix-devel-gexp-symbol): New face. (guix-devel-font-lock-keywords): Adjust to handle gexp symbols. --- emacs/guix-devel.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/emacs/guix-devel.el b/emacs/guix-devel.el index 8a6fc1e..2e85a7e 100644 --- a/emacs/guix-devel.el +++ b/emacs/guix-devel.el @@ -43,6 +43,12 @@ "Face for a `modify-phases' keyword ('delete', 'replace', etc.)." :group 'guix-devel-faces) =20 +(defface guix-devel-gexp-symbol + '((t :inherit font-lock-keyword-face)) + "Face for gexp symbols ('#~', '#$', etc.). +See Info node `(guix) G-Expressions'." + :group 'guix-devel-faces) + (defcustom guix-devel-activate-mode t "If non-nil, then `guix-devel-mode' is automatically activated in Scheme buffers." @@ -130,7 +136,9 @@ to find 'modify-phases' keywords." (save-excursion (up-list) (point))) =20 (defvar guix-devel-font-lock-keywords - `((,(guix-guile-keyword-regexp "modify-phases") + `((,(rx (or "#~" "#$" "#$@" "#+" "#+@")) . + 'guix-devel-gexp-symbol) + (,(guix-guile-keyword-regexp "modify-phases") (1 'font-lock-keyword-face) (guix-devel-modify-phases-font-lock-matcher (guix-devel-modify-phases-font-lock-pre) --=20 2.5.0 --=-=-=--