Sunday, 15 April 2012

font lock - EMACS, Function call highlight -



font lock - EMACS, Function call highlight -

(emacs 24.2 ) need highliight function call. found on internet

(add-hook 'c-mode-hook (lambda () (font-lock-add-keywords nil '( ("\\<\\(\\sw+\\) ?(" . 'font-lock-function-name-face))t)))

it works highlight next open parenthesis. non confident regular expression, please, how can modify match string avoid parenthesis highlighting?

the regular look fine, need highlight first grouping in match, not whole of it. replace . 'font-lock-function-name-face 1 'font-lock-function-name-face.

another thing change, recommendation, font-lock-add-keywords accepts mode name first argument. don't need utilize hook.

result:

(font-lock-add-keywords 'c-mode '(("\\<\\(\\sw+\\) ?(" 1 'font-lock-function-name-face)))

emacs font-lock emacs-faces

No comments:

Post a Comment