unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [bojohan+news@dd.chalmers.se: Re: appointment display during isearch replaces buffer contents with history-element]
@ 2007-11-23  4:35 Richard Stallman
  0 siblings, 0 replies; only message in thread
From: Richard Stallman @ 2007-11-23  4:35 UTC (permalink / raw)
  To: emacs-devel

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: <yoijmytbul2v.fsf@remote4.student.chalmers.se>
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 <parozusa@web.de> writes:

>   Start isearch-forward, type M-p and scroll the history buffer with
>   <up> (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 <up>

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 -------

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-11-23  4:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-23  4:35 [bojohan+news@dd.chalmers.se: Re: appointment display during isearch replaces buffer contents with history-element] Richard Stallman

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).