From 0798a8d85cbb4c6d5948243869bfb137782eaeeb Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 2 Aug 2010 11:00:46 +0200 Subject: * lisp/emacs-lisp/timer.el (timer-event-handler): Protect against timers that change current buffer. --- lisp/emacs-lisp/timer.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lisp/emacs-lisp/timer.el') 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))) -- cgit v1.2.3