Emacs lisp backlight

I wrote a simple macro to define an interactive function and bind it to a key at the same time (As for my previous question) The only thing that annoys me is that it looks ugly without highlighting. He called this method:

(define-and-bind-command foo "C-x £" (message "Hello world"))

I want to highlight define-and-bind-commandand foo. Well, to highlight define-and-bind-command, I can use a wrapper around defmacro, altho is not so pretty, and I have no idea about foo. I know this is possible because the argument is requirehighlighted with the const side.

Or maybe I'm reinventing the wheel, and is there another lisp mode with a lot of extended highlighting?

+3
source share
2 answers

"define-and-bind-command" , "font-lock-add-keywords",

(defun my-elisp-mode-keywords()
  (font-lock-add-keywords nil
    '(
      ("\\<\\(define-and-bind-command\\)" . 'font-lock-keyword-face)
    )
  )
)

, "font-lock-keyword-face" . , , () , , "-", .

Edit2: , , , defun , elisp, :

(add-hook 'emacs-lisp-mode-hook 'my-elisp-mode-keywords)

foo . , , , , "define-and-bind-command", .
:, "define-and-bind-command", foo , . , , ?
Edit3: , stackoverflow ...
Edit4: , , , , , . foo , ( , ), , a-zA-z0-9 "-", . , foo,

("\\bdefine-and-bind-command\s\\([^\s]*\\)" 1 'font-lock-function-name-face t)

font-lock , . "define-and-bind-command", ( \b), , ( ) , , ,

, !

+3

font-lock-add-keywords , . ,

(font-lock-add-keywords 
 'emacs-lisp-mode
 '(("\\<\\(define-and-bind-command\\)" . 'font-lock-keyword-face)))

, ; , , emacs-lisp-mode, .

+2

All Articles