emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: flyspell.el: down-mouse-2 leads to unwanted text insertion


From: Stefan Monnier
Subject: Re: flyspell.el: down-mouse-2 leads to unwanted text insertion
Date: Fri, 01 Apr 2005 15:31:59 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> Hm, it now was surprisingly hard for me to reproduce it.  Surprising
> because when I wrote the bug report I was annoyed by it happening so
> often.  It seems to happen only when there is an active selection,
> e.g. a part of the buffer marked by dragging with mouse-1.  (I
> normally have transient-mark-mode enabled; maybe this is related.)
> Then when I press down-mouse-2, nothing happens and the menu pops up
> only when the mouse button is released.  After selecting the "Save
> word" menu item, the menu is closed and the text from the marked
> region is inserted.

Oh, I can reproduce it:
The problem seems to be in the mouse-drag-region code.

You have to do:

    - press mouse-1 somewhwere
    - drag to select a region
    - release mouse-1
    - move mouse to the word with bad spelling
    - press mouse-2
      !! the menu does not appear yet !!
    - release mouse-2
      !! the menu now appears !!
    - select something in the menu (or nothing)
    - when you finally exit the menu with a mouse click,
      the menu is popped down (on the release event) and then
      the mouse-yank-at-click command is called

Yes, I think I see the problem.  It's in the dreadful
mouse-show-mark function: it does

      (while (progn (setq event (read-event))
                    ...
                        (and (memq 'down (event-modifiers event))
                             (not (key-binding key))
                             (not (mouse-undouble-last-event events))
                             (not (member key mouse-region-delete-keys)))))

I'm not sure what this loop is intended to do or what the purpose of this
mouse-show-mark function is (e.g. why it's not implemented using a one-time
pre-command-hook), but the above code awry here because key-binding does not
pay attention to keymaps on overlays under the mouse.

So basically the loop sees the down-mouse-2, decides not to exit yet because
it can't find a binding for it, then it sees the mouse-2 event which is
bound, so it pushes both events back on the unread-command-events, at which
point the down-mouse-2 is processed and pops up the menu and when the menu
is popped the remaining mouse-2 event causes the yank.

My take on it: kill mouse-show-mark.


        Stefan




reply via email to

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