ErgoEmacsEmacsLispBlogEmacsLispBuy Tutorial
Web Hosting by 1&1

25.1.1 Mouse Commands for Editing

Mouse-1
Move point to where you click (mouse-set-point).
Drag-Mouse-1
Activate the region around the text selected by dragging, and copy it to the kill ring (mouse-set-region).
Mouse-2
Yank the last killed text at the click position (mouse-yank-at-click).
Mouse-3
If the region is active, move the nearer end of the region to the click position; otherwise, set mark at the current value of point and point at the click position. Save the resulting region in the kill ring; on a second click, kill it (mouse-save-then-kill).

The most basic mouse command is mouse-set-point, which is called by clicking with the left mouse button, Mouse-1, in the text area of a window. This moves point to the position where you clicked.

Normally, Emacs does not distinguish between ordinary mouse clicks and clicks that select a frame. When you click on a frame to select it, that also changes the selected window and cursor position according to the mouse click position. On the X window system, you can change this behavior by setting the variable x-mouse-click-focus-ignore-position to t. Then the first click selects the frame, but does not affect the selected window or cursor position. If you click again in the same place, that click will be in the selected frame, so it will change the window or cursor position.

Holding down Mouse-1 and “dragging” the mouse over a stretch of text activates the region around that text (mouse-set-region). See Mark. Emacs places the mark where you started holding down the mouse button, and point where you release it. In addition, the region is copied into the kill ring (see Kill Ring). If you don't want Emacs to copy the region, change the variable mouse-drag-copy-region to nil.

If you move the mouse off the top or bottom of the window while dragging, the window scrolls at a steady rate until you move the mouse back into the window. This way, you can select regions that don't fit entirely on the screen. The number of lines scrolled per step depends on how far away from the window edge the mouse has gone; the variable mouse-scroll-min-lines specifies a minimum step size.

Clicking with the middle mouse button, Mouse-2, moves point to the position where you clicked and performs a yank (mouse-yank-at-click). See Yanking. If you change the variable mouse-yank-at-point to a non-nil value, Mouse-2 does not move point. Then it does not matter where you click, or even which of the frame's windows you click on; the yank occurs at the existing point. This variable also affects yanking the primary and secondary selections (see Cut/Paste Other App).

Clicking with the right mouse button, Mouse-3, runs the command mouse-save-then-kill. This performs several actions depending on where you click and the status of the region:

Whenever you set the region using any of the mouse commands described above, the mark will be deactivated by any subsequent unshifted cursor motion command, in addition to the usual ways of deactivating the mark. See Shift Selection. While the region remains active, typing <Backspace> or <Delete> deletes the text in that region and deactivates the mark; this behavior follows a convention established by other graphical programs, and it does not apply when you set the region any other way, including shift-selection (see Shift Selection).

Many graphical applications also follow the convention that insertion while text is selected deletes the selected text. You can make Emacs behave this way by enabling Delete Selection mode. See Using Region.

blog comments powered by Disqus