From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master 51e7e46: Font-lock elisp macros/special forms dynamically Date: Mon, 16 Mar 2015 10:36:23 +0100 Message-ID: <878uexjnc8.fsf@gnu.org> References: <20150315082509.21193.18465@vcs.savannah.gnu.org> <55054CE9.6010702@dancol.org> <87bnjt4e00.fsf@gnu.org> <550681E3.7080407@dancol.org> <87sid52x7y.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1426498623 21080 80.91.229.3 (16 Mar 2015 09:37:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 16 Mar 2015 09:37:03 +0000 (UTC) Cc: Stefan Monnier , Artur Malabarba , emacs-devel To: Daniel Colascione Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 16 10:36:54 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YXRS9-0006uS-J5 for ged-emacs-devel@m.gmane.org; Mon, 16 Mar 2015 10:36:53 +0100 Original-Received: from localhost ([::1]:48045 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXRS8-0008TA-EQ for ged-emacs-devel@m.gmane.org; Mon, 16 Mar 2015 05:36:52 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59386) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXRRm-0008OO-Is for emacs-devel@gnu.org; Mon, 16 Mar 2015 05:36:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YXRRh-0002fg-Nw for emacs-devel@gnu.org; Mon, 16 Mar 2015 05:36:30 -0400 Original-Received: from deliver.uni-koblenz.de ([141.26.64.15]:58909) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXRRh-0002fQ-AW for emacs-devel@gnu.org; Mon, 16 Mar 2015 05:36:25 -0400 Original-Received: from thinkpad-t440p (dhcp132.uni-koblenz.de [141.26.71.132]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by deliver.uni-koblenz.de (Postfix) with ESMTPSA id B67B81A8466; Mon, 16 Mar 2015 10:36:24 +0100 (CET) Mail-Followup-To: Daniel Colascione , Stefan Monnier , Artur Malabarba , emacs-devel In-Reply-To: <87sid52x7y.fsf@gnu.org> (Tassilo Horn's message of "Mon, 16 Mar 2015 08:54:57 +0100") User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 141.26.64.15 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:183899 Archived-At: --=-=-= Content-Type: text/plain Tassilo Horn writes: >> Instead of doing it this way, why not make a font-lock matcher that >> looks at *every* initial sexp atom, calls intern-soft on it, and >> applies a face that depends on properties of the found symbol? This >> way, we'd update fontification not only after load, but also after >> eval-defun, and it'd be easy to make a `declare'-form that provided >> for exceptions from the general rule. > > Also sounds good to me, and even simpler implementation-wise. So I'm > happy to implement it that way if nobody comes up with a reason why > that's not the right way. I've just tried that out in a local branch and it works good. I went with the opt-in variant for now (but I can change that) so that you define macros which should be highlighted like so: --8<---------------cut here---------------start------------->8--- (defmacro if-let (bindings then &rest else) (declare (indent 2) (font-lock-keyword t) ;; <=================== HERE! (debug ((&rest (symbolp form)) form body))) (when (and (<= (length bindings) 2) (not (listp (car bindings)))) ;; Adjust the single binding case (setq bindings (list bindings))) `(let* ,(internal--build-bindings bindings) (if ,(car (internal--listify (car (last bindings)))) ,then ,@else))) --8<---------------cut here---------------end--------------->8--- IMHO, that's better than the regexp variant. However, when a new macro with `font-lock-keyword' declaration gets defined (or the value is changed for some existing macro), we still need to flush existing elisp buffers. Else, the effect won't be visible there. I'm not sure from where I should do that. On a very fine-granular basis, the function handling the `font-lock-keyword' declaration could do that. But that would mean many flushes when a file with many such macros gets loaded. Alternatively, an after-load-function could do that, but that would miss changes manifested with C-c C-e. Bye, Tassilo --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iF4EAREIAAYFAlUGpBcACgkQ795mVA/1wV28iAD8DjLHxYPNkngCm5uNWc6LzOoP bj+ixxEpzdk37vCdB/EBAIIj9BwdJsdepaHNeD6UzP6TvtrqYUlTHq7Al13aLkEg =uI0b -----END PGP SIGNATURE----- --=-=-=--