summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2010-08-02 11:00:46 +0200
committerStefan Monnier <monnier@iro.umontreal.ca>2010-08-02 11:00:46 +0200
commit0798a8d85cbb4c6d5948243869bfb137782eaeeb (patch)
tree320b2978be6c40d9598da2ade6de2e2e94a68a54 /lisp/emacs-lisp
parent9a747ba6507e64e26f87c5173d25428c99b70adb (diff)
downloademacs-0798a8d85cbb4c6d5948243869bfb137782eaeeb.tar.gz
emacs-0798a8d85cbb4c6d5948243869bfb137782eaeeb.tar.bz2
emacs-0798a8d85cbb4c6d5948243869bfb137782eaeeb.zip
* lisp/emacs-lisp/timer.el (timer-event-handler): Protect against timers
that change current buffer.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/timer.el6
1 files changed, 5 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el
index f3b8ddcd123..94f39940b66 100644
--- a/lisp/emacs-lisp/timer.el
+++ b/lisp/emacs-lisp/timer.el
@@ -321,7 +321,11 @@ This function is called, by name, directly by the C code."
;; We do this after rescheduling so that the handler function
;; can cancel its own timer successfully with cancel-timer.
(condition-case nil
- (apply (timer--function timer) (timer--args timer))
+ ;; 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 nil))
(if retrigger
(setf (timer--triggered timer) nil)))