nschum / highlight-symbol.el

Emacs: automatic and manual symbol highlighting
http://nschum.de/src/emacs/highlight-symbol/
274 stars 41 forks source link

highlight-symbol permanently removes syntax highlighting #38

Closed Wilfred closed 8 years ago

Wilfred commented 8 years ago

If a major mode defines a keyword with a regular expression, highlight-symbol removes that highlighting permanently.

Here's an example major mode:

(defvar example-font-lock-keywords
  `((,(rx symbol-start "foobar" symbol-end) 0 font-lock-type-face)))

(define-derived-mode example-mode prog-mode "Example"
  (setq-local font-lock-defaults '(example-font-lock-keywords)))

If you use this major mode, and enable highlight-symbol-mode, then foobar is never longer highlighted after point has been on an instance of foobar.

I suspect font-lock-remove-keywords (called from highlight-symbol-remove-symbol) is removing the original regexp from font-lock-keywords.

nschum commented 8 years ago

Your suspicion was correct. Thank you.