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
|
||||
library/userland functions"
|
||||
(catch 'matcher
|
||||
(while (re-search-forward "\\_<.+?\\_>" end t)
|
||||
(unless (save-excursion
|
||||
(let ((ppss (syntax-ppss)))
|
||||
(or (nth 3 ppss) (nth 4 ppss))))
|
||||
(let ((symbol (intern-soft (match-string-no-properties 0))))
|
||||
(while (re-search-forward "\\(?:\\sw\\|\\s_\\)+" end t)
|
||||
(let ((ppss (save-excursion (syntax-ppss))))
|
||||
(cond ((nth 3 ppss) ; strings
|
||||
(search-forward "\"" end t))
|
||||
((nth 4 ppss) ; comments
|
||||
(forward-line +1))
|
||||
((let ((symbol (intern-soft (match-string-no-properties 0))))
|
||||
(and (cond ((null symbol) nil)
|
||||
((eq symbol t) nil)
|
||||
((special-variable-p symbol)
|
||||
|
@ -65,7 +67,7 @@ library/userland functions"
|
|||
(if (subrp unaliased)
|
||||
'font-lock-constant-face
|
||||
'font-lock-function-name-face))))))
|
||||
(throw 'matcher t)))))
|
||||
(throw 'matcher t)))))))
|
||||
nil))
|
||||
|
||||
;;;###autoload
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue