From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master 51e7e46: Font-lock elisp macros/special forms dynamically Date: Mon, 16 Mar 2015 08:07:11 +0100 Message-ID: <87bnjt4e00.fsf@gnu.org> References: <20150315082509.21193.18465@vcs.savannah.gnu.org> <55054CE9.6010702@dancol.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1426489660 7616 80.91.229.3 (16 Mar 2015 07:07:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 16 Mar 2015 07:07:40 +0000 (UTC) Cc: Daniel Colascione , Artur Malabarba , emacs-devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 16 08:07:26 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YXP7S-0000NR-JX for ged-emacs-devel@m.gmane.org; Mon, 16 Mar 2015 08:07:22 +0100 Original-Received: from localhost ([::1]:47605 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXP7R-00025p-Hy for ged-emacs-devel@m.gmane.org; Mon, 16 Mar 2015 03:07:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXP7O-00025h-1e for emacs-devel@gnu.org; Mon, 16 Mar 2015 03:07:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YXP7I-0006Ci-TN for emacs-devel@gnu.org; Mon, 16 Mar 2015 03:07:17 -0400 Original-Received: from deliver.uni-koblenz.de ([141.26.64.15]:55100) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXP7I-0006Ca-N9 for emacs-devel@gnu.org; Mon, 16 Mar 2015 03:07:12 -0400 Original-Received: from thinkpad-t440p (dhcp132.uni-koblenz.de [141.26.71.132]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by deliver.uni-koblenz.de (Postfix) with ESMTPSA id 42C681A8456; Mon, 16 Mar 2015 08:07:12 +0100 (CET) Mail-Followup-To: Stefan Monnier , Artur Malabarba , Daniel Colascione , emacs-devel In-Reply-To: (Stefan Monnier's message of "Sun, 15 Mar 2015 23:07:02 -0400") User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 141.26.64.15 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:183895 Archived-At: Stefan Monnier 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