unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Uday S Reddy <u.s.reddy@cs.bham.ac.uk>
Cc: 5924@debbugs.gnu.org
Subject: bug#5924: 23.1; accept-process-output switching current-buffer
Date: Sat, 24 Jul 2010 00:36:46 +0200	[thread overview]
Message-ID: <jwvd3udhlqz.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <19449.57028.88000.501191@gargle.gargle.HOWL> (Uday S. Reddy's message of "Mon, 24 May 2010 03:04:52 +0100")

> I should take back my last couple of messages.  I had a timer task
> running (after 2 second delay) which was changing buffers.
> Unfortunately, this was getting scheduled to run during the other
> process's accept-process-output.  So, I had mistakenly put the blame
> on accept-process-output.

Thanks for the heads up.  BTW, could you try the patch below (including
byte-compiling the file and re-dumping Emacs since it's a preloaded
file), to see if it would have fixed your problem, even with the
offending timer?


        Stefan


PS: BTW, I recommend to stay away from set-buffer and always use
with-current-buffer instead ;-)


=== modified file 'lisp/emacs-lisp/timer.el'
--- lisp/emacs-lisp/timer.el	2010-01-13 08:35:10 +0000
+++ lisp/emacs-lisp/timer.el	2010-07-23 22:32:44 +0000
@@ -321,7 +321,11 @@
 	  ;; 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)))






  reply	other threads:[~2010-07-23 22:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-10 21:23 bug#5924: 23.1; accept-process-output switching current-buffer Uday S Reddy
2010-04-11  2:54 ` Stefan Monnier
2010-04-11 12:22   ` Uday S Reddy
2010-04-11 16:30     ` Stefan Monnier
2010-04-12 19:13       ` Uday S Reddy
2010-04-12 20:58         ` Stefan Monnier
2010-04-12 19:39       ` Uday S Reddy
2010-05-20  9:50       ` Uday S Reddy
2010-05-24  0:07       ` Uday S Reddy
2010-05-24  2:04       ` Uday S Reddy
2010-07-23 22:36         ` Stefan Monnier [this message]
2011-09-18 20:16           ` Lars Magne Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvd3udhlqz.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=5924@debbugs.gnu.org \
    --cc=u.s.reddy@cs.bham.ac.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).