From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: [bojohan+news@dd.chalmers.se: Re: appointment display during isearch replaces buffer contents with history-element] Date: Thu, 22 Nov 2007 23:35:21 -0500 Message-ID: Reply-To: rms@gnu.org NNTP-Posting-Host: lo.gmane.org Content-Type: text/plain; charset=ISO-8859-15 X-Trace: ger.gmane.org 1195792566 31410 80.91.229.12 (23 Nov 2007 04:36:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 23 Nov 2007 04:36:06 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 23 05:36:12 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IvQGx-00016g-KH for ged-emacs-devel@m.gmane.org; Fri, 23 Nov 2007 05:36:11 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IvQGj-00056E-B7 for ged-emacs-devel@m.gmane.org; Thu, 22 Nov 2007 23:35:57 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IvQGB-0004rs-Mb for emacs-devel@gnu.org; Thu, 22 Nov 2007 23:35:23 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IvQGB-0004rV-A2 for emacs-devel@gnu.org; Thu, 22 Nov 2007 23:35:23 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IvQGA-0004rO-U4 for emacs-devel@gnu.org; Thu, 22 Nov 2007 23:35:22 -0500 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IvQGA-0006Rj-Eo for emacs-devel@gnu.org; Thu, 22 Nov 2007 23:35:22 -0500 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.60) (envelope-from ) id 1IvQG9-0007He-A0; Thu, 22 Nov 2007 23:35:21 -0500 X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:83924 Archived-At: Would someone please fix this, then ack? ------- Start of forwarded message ------- X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_HELO_PASS,SPF_PASS, UNPARSEABLE_RELAY autolearn=failed version=3.1.0 Mail-Followup-To: bug-gnu-emacs@gnu.org To: bug-gnu-emacs@gnu.org From: bojohan+news@dd.chalmers.se (Johan =?utf-8?Q?Bockg=C3=A5rd?=) Date: Mon, 19 Nov 2007 01:37:28 +0100 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Mail-Copies-To: never Subject: Re: appointment display during isearch replaces buffer contents with history-element Martin Fischer writes: > Start isearch-forward, type M-p and scroll the history buffer with > (previous-history-element). > > If at the same time emacs tries to display an appointment in the > same frame, the contents of the buffer, where you wanted to isearch, > is replaced by one of the history elements. > > The buffer may be restored by undo. Ok. Here's a condensed recipe. $ emacs -Q (defun foo () (save-excursion (other-window 1))) (push "foo" extended-command-history) (run-with-timer 5 nil 'foo) M-x Wait 5 seconds Press The contents of the *scratch* buffer are replaced with "foo"; that is, the key binding is looked up in the minibuffer's keymap but executed in *scratch*. In contrast, executing emacsclient --eval '(save-excursion (other-window 1))' while Emacs is waiting at the M-x prompt doesn't confuse the keymaps. Using this definition for foo also works correctly (defun foo () (interactive) (other-window 1)) So the problem is when a timer changes the selected window, but not the current buffer. This is what I found * read_process_output (and similar code in exec_sentinel); call record_asynch_buffer_change unconditionally (processes): #if 0 /* Call record_asynch_buffer_change unconditionally, because we might have changed minor modes or other things that affect key bindings. */ if (! EQ (Fcurrent_buffer (), obuffer) || ! EQ (current_buffer->keymap, okeymap)) #endif /* But do it only if the caller is actually going to read events. Otherwise there's no need to make him wake up, and it could cause trouble (for example it would make sit_for return). */ if (waiting_for_user_input_p == -1) record_asynch_buffer_change (); * wait_reading_process_output; (2 places) call record_asynch_buffer_change only if buffer has changed (timers): /* If a timer has run, this might have changed buffers an alike. Make read_key_sequence aware of that. */ if (timers_run != old_timers_run && waiting_for_user_input_p == -1 && old_buffer != current_buffer) record_asynch_buffer_change (); * read_key_sequence; look for a BUFFER_SWITCH_EVENT (from record_asynch_buffer_change): if (BUFFERP (key)) { timer_resume_idle (); mock_input = t; /* Reset the current buffer from the selected window in case something changed the former and not the latter. This is to be more consistent with the behavior of the command_loop_1. */ if (fix_current_buffer) { if (! FRAME_LIVE_P (XFRAME (selected_frame))) Fkill_emacs (Qnil); if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) Fset_buffer (XWINDOW (selected_window)->buffer); } orig_local_map = get_local_map (PT, current_buffer, Qlocal_map); orig_keymap = get_local_map (PT, current_buffer, Qkeymap); goto replay_sequence; } * command_loop_1; set selected window's buffer as current between looking up and executing command: /* Read next key sequence; i gets its length. */ i = read_key_sequence (keybuf, sizeof keybuf / sizeof keybuf[0], Qnil, 0, 1, 1); /* A filter may have run while we were reading the input. */ if (! FRAME_LIVE_P (XFRAME (selected_frame))) Fkill_emacs (Qnil); if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer)); - -- Johan Bockgård ------- End of forwarded message -------