emacs-devel
[Top][All Lists]
Advanced

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

Re: Mysterious buffer switching


From: Richard Stallman
Subject: Re: Mysterious buffer switching
Date: Mon, 28 Feb 2005 06:25:23 -0500

    Wait for around five seconds. You will see:

    Foo: .emacs

    You need to have font-lock enabled, and there has to be a long fontified
    buffer lurking around somewhere. My guess is that the font-lock engine is
    doing stuff while waiting for input, which causes current-buffer to be
    different when the timer calls the function.

It might be due to this code:

                ;; In the following code, the `sit-for' calls cause a
                ;; redisplay, so it's required that the
                ;; buffer-modified flag of a buffer that is displayed
                ;; has the right value---otherwise the mode line of
                ;; an unmodified buffer would show a `*'.
                (let (start
                      (nice (or jit-lock-stealth-nice 0))
                      (point (point-min)))
                  (while (and (setq start
                                    (jit-lock-stealth-chunk-start point))
                              (sit-for nice))

Pong ought to be fixed to avoid depending on this,
but it wouldn't hurt to remove this source of unpredictability.
Does this patch do the job?

*** jit-lock.el 26 Mar 2004 12:04:00 -0500      1.35
--- jit-lock.el 27 Feb 2005 17:09:45 -0500      
***************
*** 415,420 ****
--- 415,421 ----
    (unless (or executing-kbd-macro
              (window-minibuffer-p (selected-window)))
      (let ((buffers (buffer-list))
+         (outer-buffer (current-buffer))
          minibuffer-auto-raise
          message-log-max)
        (with-local-quit
***************
*** 449,455 ****
                      (point (point-min)))
                  (while (and (setq start
                                    (jit-lock-stealth-chunk-start point))
!                             (sit-for nice))
  
                    ;; fontify a block.
                    (jit-lock-fontify-now start (+ start jit-lock-chunk-size))
--- 450,459 ----
                      (point (point-min)))
                  (while (and (setq start
                                    (jit-lock-stealth-chunk-start point))
!                             ;; In case sit-for runs any timers,
!                             ;; give them the expected current buffer.
!                             (with-current-buffer outer-buffer
!                               (sit-for nice)))
  
                    ;; fontify a block.
                    (jit-lock-fontify-now start (+ start jit-lock-chunk-size))
***************
*** 461,467 ****
                    ;; Wait a little if load is too high.
                    (when (and jit-lock-stealth-load
                               (> (car (load-average)) jit-lock-stealth-load))
!                     (sit-for (or jit-lock-stealth-time 30)))))))))))))
  
  
  
--- 465,474 ----
                    ;; Wait a little if load is too high.
                    (when (and jit-lock-stealth-load
                               (> (car (load-average)) jit-lock-stealth-load))
!                     ;; In case sit-for runs any timers,
!                     ;; give them the expected current buffer.
!                     (with-current-buffer outer-buffer
!                       (sit-for (or jit-lock-stealth-time 30))))))))))))))
  
  
  




reply via email to

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