From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: progmodes cc: addition of builtin def-const Date: Wed, 19 Dec 2012 20:17:03 +0000 Message-ID: <20121219201703.GA3618@acm.acm> References: <80boeaaor1.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1355949413 18583 80.91.229.3 (19 Dec 2012 20:36:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 19 Dec 2012 20:36:53 +0000 (UTC) Cc: bug-cc-mode@gnu.org, emacs-devel@gnu.org To: Vincent =?iso-8859-1?Q?Bela=EFche?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Dec 19 21:37:08 2012 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 1TlQO2-0005hL-Nq for ged-emacs-devel@m.gmane.org; Wed, 19 Dec 2012 21:37:06 +0100 Original-Received: from localhost ([::1]:40150 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TlQNp-000384-6K for ged-emacs-devel@m.gmane.org; Wed, 19 Dec 2012 15:36:53 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:43056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TlQNl-00037r-It for emacs-devel@gnu.org; Wed, 19 Dec 2012 15:36:51 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TlQNj-0005lX-Cu for emacs-devel@gnu.org; Wed, 19 Dec 2012 15:36:49 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:32003 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TlQHZ-0003xL-Lt for emacs-devel@gnu.org; Wed, 19 Dec 2012 15:30:25 -0500 Original-Received: (qmail 68304 invoked by uid 3782); 19 Dec 2012 20:23:38 -0000 Original-Received: from acm.muc.de (pD951BE5E.dip.t-dialin.net [217.81.190.94]) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 19 Dec 2012 21:23:35 +0100 Original-Received: (qmail 3835 invoked by uid 1000); 19 Dec 2012 20:17:03 -0000 Content-Disposition: inline In-Reply-To: <80boeaaor1.fsf@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 8.x X-Received-From: 193.149.48.1 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:155673 Archived-At: Hi, Vincent. Sorry for the delay in answering your proposal. I've been swithering a fair bit over it. On Mon, Dec 03, 2012 at 09:01:54PM +0100, Vincent Belaïche wrote: > Hello, > DXL has a number of language specific functions which I think would be > better to fontify like builtins, similar to what is done in AWK. As a matter of interest, what is DXL? All I found on the web was a language based on XML, not C-like at all. > On the other hand DXL is more typed than AWK, so the 3 level > fontification of cc-fonts.el is better to use than do a specific > fontification like in AWK mode. OK. > In order to achieve this goal of reusing cc-fonts, I propose the > addition of a new lang constant c-builtin-kwds. This allows the > dxl-mode.el which I am elaborating to plug more readily on EMACS CC > progmode. > If nobody objects I would commit the change the patch thereof is herein > attached. My first reaction was negative - do we really want extensive use of c-preprocessor-face-name for builtin functions? I know AWK Mode does precisely this, but is it a good thing to encourage? Then, on the other hand, the new code does nothing which isn't already inside CC Mode. To answer my own question, I don't feel we really should encourage this use of c-preprocessor-face-name. As a matter of interest, have you tried using font-lock-add-keywords to get the new keywords fontified? If so, how easy/neat is it to do this? Could you try to persuade me a new general facility is better than a one-off for DXL Mode? There were one or two little things about the patch which weren't quite optimal, see below. > VBR, > Vincent. > === modified file 'lisp/ChangeLog' > --- lisp/ChangeLog 2012-12-03 17:23:42 +0000 > +++ lisp/ChangeLog 2012-12-03 19:55:20 +0000 > @@ -1,3 +1,12 @@ > +2012-12-03 Vincent Belaïche > + > + * progmodes/cc-fonts.el (c-basic-matchers-before): Use new lang > + constant `c-builtin-kwds' for handling language specific keyword > + fontification. > + > + * progmodes/cc-langs.el (c-builtin-kwds): New lang constant for > + handling language specific keyword fontification. > + > 2012-12-03 Agustín Martín Domingo > * textmodes/ispell.el (ispell-init-process) > === modified file 'lisp/progmodes/cc-langs.el' > --- lisp/progmodes/cc-langs.el 2012-09-13 18:41:21 +0000 > +++ lisp/progmodes/cc-langs.el 2012-12-03 17:24:59 +0000 > @@ -649,6 +649,15 @@ > (prefix "::") > (left-assoc "."))) > +(c-lang-defconst c-builtin-kwds > + "Keywords for builtin keywords constants." > + ;; This is for functions that are not part of a library but builtin in the > + ;; language. AWK mode does not use this constant but could have done > + ;; so. Currently this is used only as a hook for languages not yes part of > + ;; cc-xxx progmode, like DXL. > + t nil > + ) > + > (c-lang-defconst c-opt-identifier-concat-key > ;; Appendable adorned regexp matching the operators that join > ;; symbols to fully qualified identifiers, or nil in languages that c-builtin-kwds really needs a fuller doc string, since unlike c-constant-kwds, it doesn't have examples to guide other hackers in its use. The comment is really too vague - nowhere does it say what is done with the supplied functions. I don't think the offhand remark about AWK is really helpful. Something like the following would be better: "A list of keywords which will get fontified with c-preprocessor-face-name." ;; This is intended for built-in function names in modes derived from CC ;; Mode. > === modified file 'lisp/progmodes/cc-fonts.el' > --- lisp/progmodes/cc-fonts.el 2012-01-19 07:21:25 +0000 > +++ lisp/progmodes/cc-fonts.el 2012-12-03 17:26:28 +0000 > @@ -763,6 +763,12 @@ > `((eval . (list ,(concat "\\<\\(" re "\\)\\>") > 1 c-constant-face-name)))))) > + ;; Fontify builtins keyword constants. > + ,@(when (c-lang-const c-builtin-kwds) > + (let ((re (c-make-keywords-re nil (c-lang-const c-builtin-kwds)))) > + `((eval . (list ,(concat "\\<\\(" re "\\)\\>") > + 1 c-preprocessor-face-name))))) > + > ;; Fontify all keywords except the primitive types. > ,(if (c-major-mode-is 'pike-mode) > ;; No symbol is a keyword after "->" in Pike. But as I said, I'm not quite convinced that the general facility you've implemented is a good idea, as compared with each mode (how many are therre?) which needs it implementing it specially. What is your feeling about how many derived modes would benefit from it? -- Alan Mackenzie (Nuremberg, Germany).