ErgoEmacsEmacsLispBlogEmacsLispBuy Tutorial

11.2 Commands to Mark Textual Objects

Here are the commands for placing point and the mark around a textual object such as a word, list, paragraph or page:

M-@
Set mark after end of next word (mark-word). This does not move point.
C-M-@
Set mark after end of following balanced expression (mark-sexp). This does not move point.
M-h
Move point to the beginning of the current paragraph, and set mark at the end (mark-paragraph).
C-M-h
Move point to the beginning of the current defun, and set mark at the end (mark-defun).
C-x C-p
Move point to the beginning of the current page, and set mark at the end (mark-page).
C-x h
Move point to the beginning of the buffer, and set mark at the end (mark-whole-buffer).

M-@ (mark-word) puts the mark at the end of the next word, while C-M-@ (mark-sexp) puts it at the end of the next balanced expression (see Expressions). These commands handle arguments just like M-f and C-M-f.

The other commands in the above list set both point and mark, so as to delimit an object in the buffer. M-h (mark-paragraph) moves point to the beginning of the paragraph that surrounds or follows point, and sets the mark at the end of that paragraph (see Paragraphs). As a special exception, repeated invocations of M-h extend the region to subsequent paragraphs. This is convenient for indenting, case-converting, or killing entire paragraphs.

The M-h command accepts prefix arguments. If the argument's value is positive, M-h marks that many paragraphs starting with the one surrounding point; therefore, C-u M-h is equivalent to M-h M-h M-h M-h. If the prefix argument is −n, M-h marks n paragraphs running back from the one surrounding point; in this case, point moves forward to the end of that paragraph, and the mark goes at the start of the region.

Similarly, C-M-h (mark-defun) sets mark and point around major top-level definitions (see Moving by Defuns), and C-x C-p (mark-page) does the same for pages (see Pages). These treat repeated invocations and prefix arguments similarly to mark-paragraph.

Finally, C-x h (mark-whole-buffer) sets up the entire buffer as the region, by putting point at the beginning and the mark at the end. (In some programs this is called “select all.”)

blog comments powered by Disqus