]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/emacs-lisp/timer.el (timer-event-handler): Don't run if canceled.
authorStefan Monnier <monnier@iro.umontreal.ca>
Sun, 18 May 2014 12:58:30 +0000 (08:58 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sun, 18 May 2014 12:58:30 +0000 (08:58 -0400)
Fixes: debbugs:17392
lisp/ChangeLog
lisp/emacs-lisp/timer.el
lisp/frame.el
src/minibuf.c

index 9205d3a73ea599aebf80d4169223fac0d8109d4d..90335fda7063e540d646525d24cf40320767e8dd 100644 (file)
@@ -1,3 +1,8 @@
+2014-05-18  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * emacs-lisp/timer.el (timer-event-handler): Don't run if canceled
+       (bug#17392).
+
 2014-05-17  Michael Albinus  <michael.albinus@gmx.de>
 
        * net/tramp-sh.el (tramp-find-inline-encoding): Do not match "%%t"
index 515bbc36a06a9a9b25d090d6a15d05a8fa26638a..516ea3643d5fa119faf69b421bb4b842aef4a7d9 100644 (file)
@@ -290,42 +290,50 @@ This function is called, by name, directly by the C code."
           (cell
            ;; Delete from queue.  Record the cons cell that was used.
            (cancel-timer-internal timer)))
-      ;; Re-schedule if requested.
-      (if (timer--repeat-delay timer)
-          (if (timer--idle-delay timer)
-              (timer-activate-when-idle timer nil cell)
-            (timer-inc-time timer (timer--repeat-delay timer) 0)
-            ;; If real time has jumped forward,
-            ;; perhaps because Emacs was suspended for a long time,
-            ;; limit how many times things get repeated.
-            (if (and (numberp timer-max-repeats)
-                     (< 0 (timer-until timer (current-time))))
-                (let ((repeats (/ (timer-until timer (current-time))
-                                  (timer--repeat-delay timer))))
-                  (if (> repeats timer-max-repeats)
-                      (timer-inc-time timer (* (timer--repeat-delay timer)
-                                               repeats)))))
-            ;; Place it back on the timer-list before running
-            ;; timer--function, so it can cancel-timer itself.
-            (timer-activate timer t cell)
-            (setq retrigger t)))
-      ;; Run handler.
-      (condition-case-unless-debug err
-          ;; Timer functions should not change the current buffer.
-          ;; If they do, all kinds of nasty surprises can happen,
-          ;; and it can be hellish to track down their source.
-          (save-current-buffer
-            (apply (timer--function timer) (timer--args timer)))
-        (error (message "Error running timer%s: %S"
-                        (if (symbolp (timer--function timer))
-                            (format " `%s'" (timer--function timer)) "")
-                        err)))
-      (when (and retrigger
-                 ;; If the timer's been canceled, don't "retrigger" it
-                 ;; since it might still be in the copy of timer-list kept
-                 ;; by keyboard.c:timer_check (bug#14156).
-                 (memq timer timer-list))
-        (setf (timer--triggered timer) nil)))))
+      ;; If `cell' is nil, it means the timer was already canceled, so we
+      ;; shouldn't be running it at all.  This can happen for example with the
+      ;; following scenario (bug#17392):
+      ;; - we run timers, starting with A (and remembering the rest as (B C)).
+      ;; - A runs and a does a sit-for.
+      ;; - during sit-for we run timer D which cancels timer B.
+      ;; - timer A finally finishes, so we move on to timers B and C.
+      (unless cell
+        ;; Re-schedule if requested.
+        (if (timer--repeat-delay timer)
+            (if (timer--idle-delay timer)
+                (timer-activate-when-idle timer nil cell)
+              (timer-inc-time timer (timer--repeat-delay timer) 0)
+              ;; If real time has jumped forward,
+              ;; perhaps because Emacs was suspended for a long time,
+              ;; limit how many times things get repeated.
+              (if (and (numberp timer-max-repeats)
+                       (< 0 (timer-until timer (current-time))))
+                  (let ((repeats (/ (timer-until timer (current-time))
+                                    (timer--repeat-delay timer))))
+                    (if (> repeats timer-max-repeats)
+                        (timer-inc-time timer (* (timer--repeat-delay timer)
+                                                 repeats)))))
+              ;; Place it back on the timer-list before running
+              ;; timer--function, so it can cancel-timer itself.
+              (timer-activate timer t cell)
+              (setq retrigger t)))
+        ;; Run handler.
+        (condition-case-unless-debug err
+            ;; Timer functions should not change the current buffer.
+            ;; If they do, all kinds of nasty surprises can happen,
+            ;; and it can be hellish to track down their source.
+            (save-current-buffer
+              (apply (timer--function timer) (timer--args timer)))
+          (error (message "Error running timer%s: %S"
+                          (if (symbolp (timer--function timer))
+                              (format " `%s'" (timer--function timer)) "")
+                          err)))
+        (when (and retrigger
+                   ;; If the timer's been canceled, don't "retrigger" it
+                   ;; since it might still be in the copy of timer-list kept
+                   ;; by keyboard.c:timer_check (bug#14156).
+                   (memq timer timer-list))
+          (setf (timer--triggered timer) nil))))))
 
 ;; This function is incompatible with the one in levents.el.
 (defun timeout-event-p (event)
index f081df788ecadc3a5247059731a0515300d709c6..d699d24302374d4305b6a3c333dc9d7db58d1dad 100644 (file)
@@ -1822,9 +1822,7 @@ terminals, cursor blinking is controlled by the terminal."
   :initialize 'custom-initialize-delay
   :group 'cursor
   :global t
-  (if blink-cursor-idle-timer (cancel-timer blink-cursor-idle-timer))
-  (setq blink-cursor-idle-timer nil)
-  (blink-cursor-end)
+  (blink-cursor-suspend)
   (remove-hook 'focus-in-hook #'blink-cursor-check)
   (remove-hook 'focus-out-hook #'blink-cursor-suspend)
   (when blink-cursor-mode
index cd108d88ecc2b2cc68b44c1418e247199c931568..c3fcbeb59c7d69c3b32cab8e4f8e35f63fcdf113 100644 (file)
@@ -396,7 +396,8 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
      in previous recursive minibuffer, but was not set explicitly
      to t for this invocation, so set it to nil in this minibuffer.
      Save the old value now, before we change it.  */
-  specbind (intern ("minibuffer-completing-file-name"), Vminibuffer_completing_file_name);
+  specbind (intern ("minibuffer-completing-file-name"),
+           Vminibuffer_completing_file_name);
   if (EQ (Vminibuffer_completing_file_name, Qlambda))
     Vminibuffer_completing_file_name = Qnil;