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: Tue, 29 Aug 2006 22:43:13 -0400 Message-ID: <878xl754fy.fsf@furball.mit.edu> References: <8764gcde3n.fsf@stupidchicken.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1156905836 19615 80.91.229.2 (30 Aug 2006 02:43:56 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 30 Aug 2006 02:43:56 +0000 (UTC) Cc: Stefan Monnier , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Aug 30 04:43:53 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 1GIG3V-0006Fu-4O for ged-emacs-devel@m.gmane.org; Wed, 30 Aug 2006 04:43:53 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GIG3U-0006Ew-ND for ged-emacs-devel@m.gmane.org; Tue, 29 Aug 2006 22:43:52 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GIG3B-00060t-GE for emacs-devel@gnu.org; Tue, 29 Aug 2006 22:43:33 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GIG36-0005tu-Lf for emacs-devel@gnu.org; Tue, 29 Aug 2006 22:43:29 -0400 Original-Received: from [18.72.1.2] (helo=south-station-annex.mit.edu) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GIGCL-0006tt-EZ; Tue, 29 Aug 2006 22:53:01 -0400 Original-Received: from grand-central-station.mit.edu (GRAND-CENTRAL-STATION.MIT.EDU [18.7.21.82]) by south-station-annex.mit.edu (8.13.6/8.9.2) with ESMTP id k7U2hNUQ024206; Tue, 29 Aug 2006 22:43:23 -0400 (EDT) Original-Received: from outgoing-legacy.mit.edu (OUTGOING-LEGACY.MIT.EDU [18.7.22.104]) by grand-central-station.mit.edu (8.13.6/8.9.2) with ESMTP id k7U2hK0x002860; Tue, 29 Aug 2006 22:43:20 -0400 (EDT) Original-Received: from furball.mit.edu (SYDNEYPACIFIC-FOUR-EIGHTY-EIGHT.MIT.EDU [18.95.6.233]) ) by outgoing-legacy.mit.edu (8.13.6/8.12.4) with ESMTP id k7U2hDUq026762; Tue, 29 Aug 2006 22:43:13 -0400 (EDT) Original-Received: from cyd by furball.mit.edu with local (Exim 3.36 #1 (Debian)) id 1GIG2r-0001Tb-00; Tue, 29 Aug 2006 22:43:13 -0400 Original-To: rms@gnu.org In-Reply-To: (Richard Stallman's message of "Tue, 29 Aug 2006 07:47:40 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-Spam-Score: 1.217 X-Scanned-By: MIMEDefang 2.42 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:59092 Archived-At: Richard Stallman writes: > > + (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)) > > Won't work if font-lock-mode is enabled after imenu is used. > > Could that be solved by making jit-lock-mode also enable these hooks? How about this? It adds jit-lock-pre-stealth-fontify-hook and jit-lock-post-stealth-fontify-hook, which are normal hooks run before and after each chunk of stealth fontification. Then imenu can use this to avoid menu bar updates resulting from stealth fontification. The only disadvantage is adding two `run-hook' called to the jit-lock-stealth-fontify timer function, but hopefully the performance impact isn't too bad. *** emacs/lisp/imenu.el.~1.118.~ 2006-08-29 18:14:09.000000000 -0400 --- emacs/lisp/imenu.el 2006-08-29 22:38:21.000000000 -0400 *************** *** 953,958 **** --- 953,962 ---- (define-key newmap [menu-bar index] `(menu-item ,name ,(make-sparse-keymap "Imenu"))) (use-local-map newmap) + (add-hook 'jit-lock-pre-stealth-fontify-hook + 'imenu-pre-stealth-fontify-fn nil t) + (add-hook 'jit-lock-post-stealth-fontify-hook + 'imenu-post-stealth-fontify-fn nil t) (add-hook 'menu-bar-update-hook 'imenu-update-menubar)) (error "The mode `%s' does not support Imenu" mode-name))) *************** *** 970,980 **** --- 974,1000 ---- "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-stealth-fontify nil) + (make-variable-buffer-local 'imenu-unmodified-before-stealth-fontify) + + (defun imenu-pre-stealth-fontify-fn () + (setq imenu-unmodified-before-stealth-fontify + (eq (buffer-modified-tick) imenu-menubar-modified-tick))) + + (defun imenu-post-stealth-fontify-fn () + (if imenu-unmodified-before-stealth-fontify + (setq imenu-menubar-modified-tick (buffer-modified-tick) + imenu-unmodified-before-stealth-fontify nil))) + + (setq foo 0) + (defun imenu-update-menubar () (when (and (current-local-map) (keymapp (lookup-key (current-local-map) [menu-bar index])) (not (eq (buffer-modified-tick) imenu-menubar-modified-tick))) + (setq foo (% (1+ foo) 10)) + (message (format "Foo %d" foo)) (setq imenu-menubar-modified-tick (buffer-modified-tick)) (let ((index-alist (imenu--make-index-alist t))) ;; Don't bother updating if the index-alist has not changed *** emacs/lisp/jit-lock.el.~1.55.~ 2006-08-29 18:14:09.000000000 -0400 --- emacs/lisp/jit-lock.el 2006-08-29 22:33:28.000000000 -0400 *************** *** 182,187 **** --- 182,192 ---- "List of buffers with pending deferred fontification.") (defvar jit-lock-stealth-buffers nil "List of buffers that are being fontified stealthily.") + + (defvar jit-lock-pre-stealth-fontify-hook nil + "Normal hook run before performing each chunk of stealth fontification.") + (defvar jit-lock-post-stealth-fontify-hook nil + "Normal hook run after performing each chunk of stealth fontification.") ;;; JIT lock mode *************** *** 488,495 **** --- 493,502 ---- (with-temp-message (if jit-lock-stealth-verbose (concat "JIT stealth lock " (buffer-name))) + (run-hooks 'jit-lock-pre-stealth-fontify-hook) (jit-lock-fontify-now start (+ start jit-lock-chunk-size)) + (run-hooks 'jit-lock-post-stealth-fontify-hook) ;; Run again after `jit-lock-stealth-nice' seconds. (setq delay (or jit-lock-stealth-nice 0))) ;; Nothing to fontify here. Remove this buffer from *************** *** 503,509 **** (timer-set-idle-time jit-lock-stealth-repeat-timer (current-idle-time)) (timer-inc-time jit-lock-stealth-repeat-timer delay) (timer-activate-when-idle jit-lock-stealth-repeat-timer t))))) - ;;; Deferred fontification. --- 510,515 ----