1

I've got a function that behaves more like a macro in that it does compile-time environment definitions. For various reasons (at this point, one of those reasons is 'because it is easier to grok in my head'), I'd like to keep it as a function. When I use the function, how can I have emacs color it like it would a macro?

(defun test-func ())
(defmacro test-macro ())

(test-func)  ; not colored
(test-macro) ; colored
1

Perhaps you want to better understand why this is the default behavior, or perhaps you want a simpler solution, but here is at least one quick solution:

Load library hl-defined and turn on minor mode hdefd-highlight-mode. To get exactly the same face for functions as you see for test-macro, customize face hdefd-functions to be the same as (i.e., just inherit from) face font-lock-keyword-face.

(If you don't want to also highlight variables, customize option hdefd-highlight-type to just the value functions.)

  • 1
    Why is that the default behaviour? Please enlighten us! – Dox Feb 24 '17 at 3:35
  • @Dox: I don't know why. That sentence was just to say that my answer might not be responding to what the OP really wants, which I'm guessing is to better understand the default font-locking or how to tweak it to get (only) what he wants as a slight modification. My answer provides, I think, the behavior requested, but I suspect that the behavior is less the point than is understanding how to get what OP wants. – Drew Feb 24 '17 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.