lang/emacs-lisp: optimize var/face highlighting
A slight performance improvement in files with a lot of comments and strings, by skipping ahead a line if in a comment and to the next double quote if in a string. Otherwise, this function would visit every symbol in between, and syntax-ppss calls are relatively expensive here.
This commit is contained in:
parent
08bfd5879a
commit
3e15b71568
1 changed files with 25 additions and 23 deletions
|
@ -43,11 +43,13 @@ to a pop up buffer."
|
||||||
Functions are differentiated into special forms, built-in functions and
|
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 "\\(?:\\sw\\|\\s_\\)+" end t)
|
||||||
(unless (save-excursion
|
(let ((ppss (save-excursion (syntax-ppss))))
|
||||||
(let ((ppss (syntax-ppss)))
|
(cond ((nth 3 ppss) ; strings
|
||||||
(or (nth 3 ppss) (nth 4 ppss))))
|
(search-forward "\"" end t))
|
||||||
(let ((symbol (intern-soft (match-string-no-properties 0))))
|
((nth 4 ppss) ; comments
|
||||||
|
(forward-line +1))
|
||||||
|
((let ((symbol (intern-soft (match-string-no-properties 0))))
|
||||||
(and (cond ((null symbol) nil)
|
(and (cond ((null symbol) nil)
|
||||||
((eq symbol t) nil)
|
((eq symbol t) nil)
|
||||||
((special-variable-p symbol)
|
((special-variable-p symbol)
|
||||||
|
@ -65,7 +67,7 @@ library/userland functions"
|
||||||
(if (subrp unaliased)
|
(if (subrp unaliased)
|
||||||
'font-lock-constant-face
|
'font-lock-constant-face
|
||||||
'font-lock-function-name-face))))))
|
'font-lock-function-name-face))))))
|
||||||
(throw 'matcher t)))))
|
(throw 'matcher t)))))))
|
||||||
nil))
|
nil))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue