Subject: Re: bug#12761: cl-lib.el functions do not get font-locked like cl.el ones

From: Christopher Schmidt <[email-masked]>
Date: Sat, 15 Dec 2012 16:54:24 +0000 (GMT)

Stefan Monnier <[email-masked]> writes:
>> So maybe that special treatment (lexical-let, letf, etc)
>> should be removed, to make everyone equally miserable.
>
> Right.  But then the "cl-*" versions could be fine choices (tho I'd
> much rather not hard code those things in the font-lock rules.
> Couldn't we build those dynamically by loading cl-lib.el, then going
> through the obarray, keeping all macros whose name starts with "cl-"
> but not "cl--"?).

+1.

I think it might be a good idea to remove CL font lock support in
emacs-lisp-mode and its deviates by default.  A function that adds
keyword highlighting on the fly could be added, though.

    (require 'cl-lib)

    (defun add-cl-font-lock-keywords ()
      (font-lock-add-keywords
       'emacs-lisp-mode
       (eval-when-compile
         (cl-loop
          for s being the symbols
          for n = (symbol-name s)
          when (and (string-match-p "^cl-[^-]" n)
                    (condition-case nil
                        (eq (car (symbol-function s)) 'macro)
                      (error)))
          collect (list (concat "(\\(?:[ \t]*\\)\\<\\("
                                (regexp-quote n)
                                "\\)\\>")
                        1
                        font-lock-keyword-face)
          end))))

An user just needs to put (add-cl-font-lock-keywords) in his init.el in
case he really wants CL font lock support.

I am just brainstorming here.  This does not take care of
lisp-interaction-mode, *scratch*, etc.

        Christopher