emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

address@hidden: Re: appointment display during isearch replaces buffer c


From: Richard Stallman
Subject: address@hidden: Re: appointment display during isearch replaces buffer contents with history-element]
Date: Thu, 22 Nov 2007 23:35:21 -0500

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: address@hidden
To: address@hidden
From: address@hidden (Johan =?utf-8?Q?Bockg=C3=A5rd?=)
Date: Mon, 19 Nov 2007 01:37:28 +0100
Message-ID: <address@hidden>
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 <address@hidden> 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 -------




reply via email to

[Prev in Thread] Current Thread [Next in Thread]