[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Emacs-diffs] master 51e7e46: Font-lock elisp macros/special forms d
From: |
Tassilo Horn |
Subject: |
Re: [Emacs-diffs] master 51e7e46: Font-lock elisp macros/special forms dynamically |
Date: |
Mon, 16 Mar 2015 08:07:11 +0100 |
User-agent: |
Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) |
Stefan Monnier <address@hidden> writes:
>> Finally, I'm positively surprised at how fast the update function is.
>> I would have expected some lag, but haven't found any (even though I'm
>> looking).
>
> Loading Elisp files should be fairly rare. But there might be cases
> where it can be done repeatedly, but if/when faced with such a situation
> we should be able to handle it efficiently e.g. by checking the
> load-history (make sure the file did include some definitions before we
> bother to scan symbols and rebuild the regexp) since such "run-time
> loading" probably won't define new functions.
Like so?
--8<---------------cut here---------------start------------->8---
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index b4f87fd..f8591aa 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -198,9 +198,21 @@ Return non-nil only if the old and new value are
different."
(concat "(" (regexp-opt elisp-macros t) "\\_>"))
(not (string= old-regex lisp--el-macro-regexp))))
-(defun lisp--el-update-after-load (_file)
+(defun lisp--el-update-after-load (file)
"Update `lisp--el-macro-regexp' and adjust font-lock in existing buffers."
- (when (lisp--el-update-macro-regexp)
+ (when (and
+ ;; Don't trigger when a file gets reloaded.
+ (string= file (caar load-history))
+ ;; Test if the recently loaded file defined any new macros.
+ (let ((load-entries (cdar load-history)))
+ (catch 'found
+ (while load-entries
+ (when (and (consp (car load-entries))
+ (eq 'defun (caar load-entries))
+ (macrop (cdar load-entries)))
+ (throw 'found t))
+ (setq load-entries (cdr load-entries)))))
+ (lisp--el-update-macro-regexp))
(dolist (buf (buffer-list))
(when (derived-mode-p 'emacs-lisp-mode)
(font-lock-flush)))))
--8<---------------cut here---------------end--------------->8---
Bye,
Tassilo
- Re: [Emacs-diffs] master 51e7e46: Font-lock elisp macros/special forms dynamically, Daniel Colascione, 2015/03/15
- Re: [Emacs-diffs] master 51e7e46: Font-lock elisp macros/special forms dynamically, Artur Malabarba, 2015/03/15
- RE: [Emacs-diffs] master 51e7e46: Font-lock elisp macros/special forms dynamically, Drew Adams, 2015/03/15
- Re: [Emacs-diffs] master 51e7e46: Font-lock elisp macros/special forms dynamically, Stefan Monnier, 2015/03/15
- Re: [Emacs-diffs] master 51e7e46: Font-lock elisp macros/special forms dynamically, Artur Malabarba, 2015/03/15
- Re: [Emacs-diffs] master 51e7e46: Font-lock elisp macros/special forms dynamically, Stefan Monnier, 2015/03/16
- Re: [Emacs-diffs] master 51e7e46: Font-lock elisp macros/special forms dynamically, Tassilo Horn, 2015/03/16
- Re: [Emacs-diffs] master 51e7e46: Font-lock elisp macros/special forms dynamically, Stefan Monnier, 2015/03/16
- Re: [Emacs-diffs] master 51e7e46: Font-lock elisp macros/special forms dynamically, Tassilo Horn, 2015/03/16
- Re: [Emacs-diffs] master 51e7e46: Font-lock elisp macros/special forms dynamically, Daniel Colascione, 2015/03/16
- Re: [Emacs-diffs] master 51e7e46: Font-lock elisp macros/special forms dynamically, Stefan Monnier, 2015/03/16
- Re: [Emacs-diffs] master 51e7e46: Font-lock elisp macros/special forms dynamically, Tassilo Horn, 2015/03/17