From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Re: [rudalics@gmx.at: Re: jit lock sit-for provokes redisplay provokes imenu] Date: Mon, 28 Aug 2006 12:22:52 -0400 Message-ID: <8764gcde3n.fsf@stupidchicken.com> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1156782116 28488 80.91.229.2 (28 Aug 2006 16:21:56 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 28 Aug 2006 16:21:56 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 28 18:21:52 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GHjrf-0000fF-3w for ged-emacs-devel@m.gmane.org; Mon, 28 Aug 2006 18:21:33 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GHjre-0000Gv-8I for ged-emacs-devel@m.gmane.org; Mon, 28 Aug 2006 12:21:30 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GHjrS-0000GM-1N for emacs-devel@gnu.org; Mon, 28 Aug 2006 12:21:18 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GHjrQ-0000G3-HG for emacs-devel@gnu.org; Mon, 28 Aug 2006 12:21:17 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GHjrQ-0000G0-AM for emacs-devel@gnu.org; Mon, 28 Aug 2006 12:21:16 -0400 Original-Received: from [18.19.1.138] (helo=cyd) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GHk0O-0001BK-Ln; Mon, 28 Aug 2006 12:30:32 -0400 Original-Received: by cyd (Postfix, from userid 1000) id 4D9B04E2FE; Mon, 28 Aug 2006 12:22:52 -0400 (EDT) Original-To: rms@gnu.org In-Reply-To: (Richard Stallman's message of "Mon, 28 Aug 2006 05:52:17 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:59009 Archived-At: Richard Stallman writes: > This is what we're thinking of using instead of > buffer-chars-modified-tick. It is a smaller change and more modular; > presuming it solves the problem well enough, it is definitely > preferable for installation now. > > So, what do people think of this change? Here is another idea which is even more modular: make imenu register jit-lock functions to check buffer-modified-tick before the actual jit-lock fontification takes place, and update imenu-menubar-modified-tick afterwards if necessary. I've checked that this works. *** emacs/lisp/jit-lock.el.~1.55.~ 2006-08-25 14:00:27.000000000 -0400 --- emacs/lisp/jit-lock.el 2006-08-28 12:05:32.000000000 -0400 *************** *** 279,290 **** (remove-hook 'after-change-functions 'jit-lock-after-change t) (remove-hook 'fontification-functions 'jit-lock-function)))) ! (defun jit-lock-register (fun &optional contextual) "Register FUN as a fontification function to be called in this buffer. FUN will be called with two arguments START and END indicating the region that needs to be (re)fontified. If non-nil, CONTEXTUAL means that a contextual fontification would be useful." ! (add-hook 'jit-lock-functions fun nil t) (when (and contextual jit-lock-contextually) (set (make-local-variable 'jit-lock-contextually) t)) (jit-lock-mode t)) --- 279,292 ---- (remove-hook 'after-change-functions 'jit-lock-after-change t) (remove-hook 'fontification-functions 'jit-lock-function)))) ! (defun jit-lock-register (fun &optional contextual append) "Register FUN as a fontification function to be called in this buffer. FUN will be called with two arguments START and END indicating the region that needs to be (re)fontified. + FUN is called before all other previously-registered fontification functions + unless the optional argument APPEND is non-nil, in which case it is called last. If non-nil, CONTEXTUAL means that a contextual fontification would be useful." ! (add-hook 'jit-lock-functions fun append t) (when (and contextual jit-lock-contextually) (set (make-local-variable 'jit-lock-contextually) t)) (jit-lock-mode t)) *** emacs/lisp/imenu.el.~1.118.~ 2006-07-09 16:52:14.000000000 -0400 --- emacs/lisp/imenu.el 2006-08-28 12:18:28.000000000 -0400 *************** *** 953,958 **** --- 953,962 ---- (define-key newmap [menu-bar index] `(menu-item ,name ,(make-sparse-keymap "Imenu"))) (use-local-map newmap) + (when jit-lock-mode + ;; Avoid updating the menubar after each stealth fontification. + (jit-lock-register 'imenu-save-tick-before-jit-lock nil nil) + (jit-lock-register 'imenu-update-tick-after-jit-lock nil t)) (add-hook 'menu-bar-update-hook 'imenu-update-menubar)) (error "The mode `%s' does not support Imenu" mode-name))) *************** *** 970,975 **** --- 974,991 ---- "The value of (buffer-modified-tick) as of last call to `imenu-update-menubar'.") (make-variable-buffer-local 'imenu-menubar-modified-tick) + (defvar imenu-unmodified-before-jit nil) + (make-variable-buffer-local 'imenu-unmodified-before-jit) + + (defun imenu-update-tick-for-jit-lock (start end) + (if (eq (buffer-modified-tick) imenu-menubar-modified-tick) + (setq imenu-unmodified-before-jit t))) + + (defun imenu-update-tick-after-jit-lock (start end) + (when imenu-unmodified-before-jit + (setq imenu-menubar-modified-tick (buffer-modified-tick)) + (setq imenu-unmodified-before-jit nil))) + (defun imenu-update-menubar () (when (and (current-local-map) (keymapp (lookup-key (current-local-map) [menu-bar index]))