lang/emacs-lisp: optimize symbol fontification

By ignoring symbols in comments and strings.
This commit is contained in:
Henrik Lissner 2018-08-20 23:47:31 +02:00
parent 97bc69b9e5
commit 1cb31d7cb5
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -64,25 +64,28 @@ Functions are differentiated into special forms, built-in functions and
library/userland functions" library/userland functions"
(catch 'matcher (catch 'matcher
(while (re-search-forward "\\_<.+?\\_>" end t) (while (re-search-forward "\\_<.+?\\_>" end t)
(let ((symbol (intern-soft (match-string-no-properties 0)))) (unless (save-excursion
(and (cond ((null symbol) nil) (let ((ppss (syntax-ppss)))
((eq symbol t) nil) (or (nth 3 ppss) (nth 4 ppss))))
((special-variable-p symbol) (let ((symbol (intern-soft (match-string-no-properties 0))))
(setq +emacs-lisp--face 'font-lock-variable-name-face)) (and (cond ((null symbol) nil)
((and (fboundp symbol) ((eq symbol t) nil)
(eq (char-before (match-beginning 0)) ?\()) ((special-variable-p symbol)
(let ((unaliased (indirect-function symbol t))) (setq +emacs-lisp--face 'font-lock-variable-name-face))
(unless (or (macrop unaliased) ((and (fboundp symbol)
(special-form-p unaliased)) (eq (char-before (match-beginning 0)) ?\())
(let (unadvised) (let ((unaliased (indirect-function symbol t)))
(while (not (eq (setq unadvised (ad-get-orig-definition unaliased)) (unless (or (macrop unaliased)
(setq unaliased (indirect-function unadvised t))))) (special-form-p unaliased))
unaliased) (let (unadvised)
(setq +emacs-lisp--face (while (not (eq (setq unadvised (ad-get-orig-definition unaliased))
(if (subrp unaliased) (setq unaliased (indirect-function unadvised t)))))
'font-lock-constant-face unaliased)
'font-lock-function-name-face)))))) (setq +emacs-lisp--face
(throw 'matcher t)))) (if (subrp unaliased)
'font-lock-constant-face
'font-lock-function-name-face))))))
(throw 'matcher t)))))
nil)) nil))
(eval-when-compile (eval-when-compile
(byte-compile #'+emacs-lisp-highlight-vars-and-faces)) (byte-compile #'+emacs-lisp-highlight-vars-and-faces))