Última vez editado
< This page is about library '''<tt>[[mouse+.el]]</tt>''', which enhances standard Emacs library ##mouse.el##. Besides some minor enhancements of `mouse-choose-completion', `mouse-tear-off-window', and `mouse-yank-secondary', <tt>[[mouse+.el]]</tt> provides these new features:
> This page is about library '''[::Mouse+]''' (<tt>[[mouse+.el]]</tt>), which enhances standard Emacs library ##mouse.el##. Besides some minor enhancements of `mouse-choose-completion', `mouse-tear-off-window', and `mouse-yank-secondary', ##mouse+.el## provides these new features:
This page is about library Mouse+ (mouse+.el), which enhances standard Emacs library
mouse.el. Besides some minor enhancements of
mouse+.el provides these new features:
M-:’ when you click
‘mouse-2’in the echo area – M-xViaMouse2.
‘M-x’when you click
‘mouse-1’in the echo area and buffer
‘*Messages*’is already displayed.
Do you sometimes have trouble telling exactly where your MousePointer is pointing, and end up pasting one character to the left or right of what you wanted? Do you resort to setting
‘t’ just because of this annoyance? There’s no need to do that – no need to give up using the mouse as a pointing device!
Library mouse+.el can help. Load it, and bind
(global-set-key [down-mouse-2] 'mouse-flash-position)
Then, when you press
‘mouse-2’ to paste, you’ll see the paste position highlighted temporarily – just until you release the mouse button. You can then move the mouse to the correct location before releasing the button. As long as the mouse button is depressed, the paste-position highlight tracks the mouse movement.
If you ever want to prevent the
‘mouse-2’ up-button yank from taking place altogether, perhaps because you change your mind, you can press and hold
‘C-g’ while releasing the mouse button. That is:
Note: Although the main utility of command
‘mouse-flash-position’ is for yanking, it works for other uses of
‘mouse-2’ as well – it always shows the mouse position. So, for instance, it works in DiredMode too, where
‘mouse-2’ is bound to
Some buffers, such as DiredMode and BufferMenu (BufferMenuPlus), are essentially tables with rows and columns. Sometimes it’s difficult to see which entry in a far left column corresponds to which entry in a far right column, because you lose track of the row. What you need is a “ruler” that shows you the row alignment.
Library mouse+.el can help here too. Load it, and bind
(global-set-key [S-down-mouse-2] 'mouse-scan-lines)
When you then press and hold Shift and
‘mouse-2’, mouse movement is tracked by highlighting the line under the MousePointer. When you release the key and button, the highlighting disappears. (This highlighting is only a visual aid; it does not affect what happens if you click
‘mouse-2’ on the highlighted line.)
If you click
‘mouse-2’ in the echo area, vanilla Emacs just shows the error message “
Minibuffer window is not active”, which is informative, but otherwise not very useful.
If you bind
‘down-mouse-2’ to command
‘mouse-flash-position-or-M-x’ instead of
‘mouse-flash-position’, then clicking
‘mouse-2’ in the echo area will initiate
‘M-x’ (whatever that KeySequence is bound to – by default,
‘execute-extended-command’). In all other respects,
‘mouse-flash-position-or-M-x’ is the same as
IOW, this gives you a quick way to execute a command if your hand is already on the mouse: just click
‘mouse-2’ in the echo area.
If you also bind
‘S-down-mouse-2’ to command `
mouse-M-:’, then holding the Shift key while clicking
‘mouse-2’ in the echo area will initiate `
M-:’ (whatever that KeySequence is bound to – by default,
If you like the effect of using
‘mouse-scan-lines’ for a horizontal guide ruler (see MouseScanLines, above), then bind
‘S-down-mouse-2’ to command `
mouse-scan-lines-or-M-:’ instead. Then, if you use Shift and click
‘mouse-2’ in the echo area you get `
M-:’, and if you use Shift and drag
‘mouse-2’ elsewhere you get the horizontal-guide highlighting.
Starting with Emacs 22, clicking
‘mouse-2’) in the echo area displays buffer
‘*Messages*’. This can be useful or annoying (or both!), depending on your point of view. The idea is that users sometimes try to select text from a message displayed in the echo area, which is impossible. They forget and mistake the echo area for the minibuffer, where you can select text. Showing
‘*Messages*’ lets you select the message text in
‘*Messages*’, where it is logged. Command
‘mouse-flash-position-or-M-x’ is specifically intended for
‘mouse-2’, so it will not interfere with the
‘mouse-1’ echo-area behavior.
‘*Messages*’ is already displayed when you click
‘mouse-1’ in the echo area, then nothing happens. Nada. No error message, nothing.
Why not let
‘mouse-1’ do something in this case? Library
mouse+.el changes the behavior so that
‘mouse-1’ in the echo area still displays
‘*Messages*’ (so you can see or select message text). But if
‘*Messages*’ is already displayed, then it initiates
‘M-x’, just like
‘mouse-flash-position-or-M-x’. And it also deletes the
‘*Messages*’ window. The idea is that if you didn’t really want to see
‘*Messages*’, or if you want to get rid of it after you see it, just click again. If you don’t want to execute a command either, then just hit
‘C-g’ to exit
To take advantage of all of the features discussed on this page, load mouse+.el and make both of these bindings:
(global-set-key [down-mouse-2] 'mouse-flash-position-or-M-x) (global-set-key [S-down-mouse-2] 'mouse-scan-lines-or-M-:)
There is no need to do anything about
mouse+.el redefines the command
‘mouse-drag-region’ so that it does the right thing.
Note: If you use a good Completion library, such as Icicles, then you can use
‘mouse-flash-position-or-M-x’ to execute commands pretty much without even using the keyboard. Just click
‘mouse-2’ in the minibuffer, hit
‘S-TAB’, and pick a completion candidate with
‘mouse-2’. (Unless you bind a mouse button to replace
‘S-TAB’, you will still need the keyboard for that.) Unless you have a particular reason for avoiding use of a keyboard, you most likely won’t want to do this, but you can. See also Icicles - Key Completion#ThreeKeyEmacs.