Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

26.1 Mouse Commands for Editing

The mouse commands for selecting and copying a region are mostly compatible with the xterm program. You can use the same mouse commands for copying between Emacs and other window-based programs. Most of these commands also work in Emacs when you run it under an xterm terminal.

If you select a region with any of these mouse commands, and then immediately afterward type the <DELETE> function key, it deletes the region that you selected. The <BACKSPACE> function key and the ASCII character <DEL> do not do this; if you type any other key in between the mouse command and <DELETE>, it does not do this.

Mouse-1
Move point to where you click (mouse-set-point). This is normally the left button.

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, since that click will be in the selected frame, it will change the window or cursor position.

Drag-Mouse-1
Set the region to the text you select by dragging, and copy it to the kill ring (mouse-set-region). You can specify both ends of the region with this single command.

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.

If the variable mouse-drag-copy-region is nil, this mouse command does not copy the selected region into the kill ring.

Mouse-2
Yank the last killed text, where you click (mouse-yank-at-click). This is normally the middle button.
Mouse-3
This command, mouse-save-then-kill, has several functions depending on where you click and the status of the region.

The most basic case is when you click Mouse-1 in one place and then Mouse-3 in another. This selects the text between those two positions as the region. It also copies the new region to the kill ring, so that you can copy it to someplace else.

If you click Mouse-1 in the text, scroll with the scroll bar, and then click Mouse-3, it remembers where point was before scrolling (where you put it with Mouse-1), and uses that position as the other end of the region. This is so that you can select a region that doesn't fit entirely on the screen.

More generally, if you do not have a highlighted region, Mouse-3 selects the text between point and the click position as the region. It does this by setting the mark where point was, and moving point to where you click.

If you have a highlighted region, or if the region was set just before by dragging button 1, Mouse-3 adjusts the nearer end of the region by moving it to where you click. The adjusted region's text also replaces the old region's text in the kill ring.

If you originally specified the region using a double or triple Mouse-1, so that the region is defined to consist of entire words or lines, then adjusting the region with Mouse-3 also proceeds by entire words or lines.

If you use Mouse-3 a second time consecutively, at the same place, that kills the region already selected.

Double-Mouse-1
This key sets the region around the word which you click on. If you click on a character with “symbol” syntax (such as underscore, in C mode), it sets the region around the symbol surrounding that character.

If you click on a character with open-parenthesis or close-parenthesis syntax, it sets the region around the parenthetical grouping which that character starts or ends. If you click on a character with string-delimiter syntax (such as a singlequote or doublequote in C), it sets the region around the string constant (using heuristics to figure out whether that character is the beginning or the end of it).

Double-Drag-Mouse-1
This key selects a region made up of the words you drag across.
Triple-Mouse-1
This key sets the region around the line you click on.
Triple-Drag-Mouse-1
This key selects a region made up of the lines you drag across.

The simplest way to kill text with the mouse is to press Mouse-1 at one end, then press Mouse-3 twice at the other end. See Killing. To copy the text into the kill ring without deleting it from the buffer, press Mouse-3 just once—or just drag across the text with Mouse-1. Then you can copy it elsewhere by yanking it.

To yank the killed or copied text somewhere else, move the mouse there and press Mouse-2. See Yanking. However, if mouse-yank-at-point is non-nil, Mouse-2 yanks at point. Then it does not matter where you click, or even which of the frame's windows you click on. The default value is nil. This variable also affects yanking the secondary selection.

To copy text to another X window, kill it or save it in the kill ring. Under X, this also sets the primary selection. Then use the “paste” or “yank” command of the program operating the other window to insert the text from the selection.

To copy text from another X window, use the “cut” or “copy” command of the program operating the other window, to select the text you want. Then yank it in Emacs with C-y or Mouse-2.

The standard coding system for X selections is compound-text-with-extensions. To specify another coding system for X selections, use C-x <RET> x or C-x <RET> X. See Specify Coding.

When Emacs puts text into the kill ring, or rotates text to the front of the kill ring, it sets the primary selection in the X server. This is how other X clients can access the text. Emacs also stores the text in the cut buffer, but only if the text is short enough (the value of x-cut-buffer-max specifies the maximum number of characters); putting long strings in the cut buffer can be slow.

The commands to yank the first entry in the kill ring actually check first for a primary selection in another program; after that, they check for text in the cut buffer. If neither of those sources provides text to yank, the kill ring contents are used.


 
 
  Published under the terms of the GNU General Public License Design by Interspire