emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: address@hidden: Re: jit lock sit-for provokes redisplay provokes ime


From: Chong Yidong
Subject: Re: address@hidden: Re: jit lock sit-for provokes redisplay provokes imenu]
Date: Mon, 28 Aug 2006 12:22:52 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Richard Stallman <address@hidden> 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]))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]