ThingAtPointCommands

Last edit

Changed:

< * '''`C-M-U'''' (aka `C-M-S-u') -- `<tt>[[#mark-enclosing-sexp]]</tt>'
< * '''`C-M-F'''' (aka `C-M-S-f') -- `<tt>[[#mark-enclosing-sexp-forward]]</tt>'
< * '''`C-M-B'''' (aka `C-M-S-b') -- `<tt>[[#mark-enclosing-sexp-backward]]</tt>'

to

> * '''`C-M-U'''' (aka `C-M-S-u') -- `<tt>[[#mark-enclosing-list]]</tt>'
> * '''`C-M-F'''' (aka `C-M-S-f') -- `<tt>[[#mark-enclosing-list-forward]]</tt>'
> * '''`C-M-B'''' (aka `C-M-S-b') -- `<tt>[[#mark-enclosing-list-backward]]</tt>'

Changed:

< [:mark-enclosing-sexp]
< [:mark-enclosing-sexp-backward]
< [:mark-enclosing-sexp-forward]
< == `mark-enclosing-sexp', `mark-enclosing-sexp-forward', `mark-enclosing-sexp-backward' ==
< Command '''`mark-enclosing-sexp'''' selects a [[sexp]] that surrounds the cursor. If you repeat the command it selects a wider enclosing sexp each time you repeat it.
< If you use a numeric [[prefix argument]] then the selection is that many sexps up, surrounding point. 1 means select
< the immediately enclosing sexp. 2 means select the sexp immediately enclosing that first enclosing sexp, and so on. A negative prefix argument puts point at the beginning of the new region

to

> [:mark-enclosing-list]
> [:mark-enclosing-list-backward]
> [:mark-enclosing-list-forward]
> == `mark-enclosing-list', `mark-enclosing-list-forward', `mark-enclosing-list-backward' ==
> Command '''`mark-enclosing-list'''' selects a list that surrounds the cursor. If you repeat the command it selects a wider enclosing list each time you repeat it.
> If you use a numeric [[prefix argument]] then the selection is that many lists up, surrounding point. 1 means select
> the immediately enclosing list. 2 means select the list immediately enclosing that first enclosing list, and so on. A negative prefix argument puts point at the beginning of the new region

Changed:

< Commands '''`mark-enclosing-sexp-backward'''' and '''`mark-enclosing-sexp-forward'''' are the same, but they specifically put point at the end and beginning of the region, respectively.

to

> Commands '''`mark-enclosing-list-backward'''' and '''`mark-enclosing-list-forward'''' are the same, but they specifically put point at the end and beginning of the region, respectively.


This page describes library thing-cmds.el, which defines various commands that use ThingAtPoint things.

The commands select various Lisp objects and text entities that are at or near point (cursor position), or they move point to such an object or text entity. The commands are described individually below.

Completion or cycling is available to choose the type of thing to use. Pretty much all thing types are completion candidates. User option ‘thing-types’ determines the types that are available for cycling.

Key Bindings

If you invoke command ‘thgcmd-bind-keys’ (e.g. in your init file) then the following key bindings are created:

`mark-thing'

Command ‘mark-thing’ marks, that is selects, successive things, starting at point. Point is moved to the beginning of the enclosing thing (or to the end, if you use a negative prefix argument). Mark is put at the same place that command ‘forward-’thing would put it using the same prefix argument.

If the region is not active, you are prompted for the type of thing to use – completion is available. The default type for completion is the first element in user option ‘thing-types’ (which, by default, is `sexp’).

If the region is active, you are not prompted, and the last-used type of thing is used again. On consecutive uses of ‘mark-thing’, the region is active, so you are not prompted, and the region is extended to successive things of the same type.

This is true even if the region is empty – as long as it is active, it is extended using the last-used type of thing, without any prompting. You can thus just hit ‘C-SPC’ to set mark and activate an empty region, then use ‘mark-thing’ to select successive things of the last type used.

`cycle-thing-region'

Command ‘cycle-thing-region’ selects a single thing near the cursor. You are not prompted for the type of thing. Instead, successive uses of the command select a different type of thing. The first type of thing selected is determined by the first element in option ‘thing-types’ (which, by default, is `sexp’).

In TransientMarkMode, you can follow this with ‘mark-thing’ to select successive things of the same type, but to do that you must first use ‘C-x C-x’ (‘exchange-point-and-mark’): Using the bindings created by command ‘thgcmd-bind-keys’, this becomes `M-@ C-x C-x C-M-SPC’. This command has an alias: ‘select-thing-near-point’.

`thing-region'

Like ‘cycle-thing-region’, command ‘thing-region’ selects a single thing near the cursor. Unlike ‘cycle-thing-region’, you are prompted for the type of thing – completion is available. The cursor is placed at the end of the region. You can return it to the original location by using ‘C-u C-SPC’ (once or twice, depending on the thing type).

`mark-enclosing-list', `mark-enclosing-list-forward', `mark-enclosing-list-backward'

Command ‘mark-enclosing-list’ selects a list that surrounds the cursor. If you repeat the command it selects a wider enclosing list each time you repeat it.

If you use a numeric prefix argument then the selection is that many lists up, surrounding point. 1 means select the immediately enclosing list. 2 means select the list immediately enclosing that first enclosing list, and so on. A negative prefix argument puts point at the beginning of the new region instead of the end.

This command moves point, and the starting position is added to the mark ring before doing anything else, so you can easily return to that position (e.g. using ‘C-u C-SPC’).

Commands ‘mark-enclosing-list-backward’ and ‘mark-enclosing-list-forward’ are the same, but they specifically put point at the end and beginning of the region, respectively.

`next-visible-thing', `previous-visible-thing', `next-visible-thing-repeat', `previous-visible-thing-repeat'

Command ‘next-visible-thing’ moves point to the start of the next visible thing of a given type. Things that are currently invisible (using text property ‘invisible’) are ignored.

If user option ‘ignore-comments-flag’ is non-‘nil’ then things that are commented out are also ignored. They are, in effect, temporarily hidden while scanning for the next thing. If you also use library Icicles then you can use `C-M-;’ in the minibuffer to toggle this option.

Command ‘previous-visible-thing’ is the same, except that it moves backward, to the first visible thing before point.

These commands prompt you for the type of thing to use, but only the first time they are invoked in succession. So if you bind them to simple repeatable keys, such as ‘f11’ and ‘f12’, then you can hit those keys over and over to move forward and back successive things.

Library thing-cmds.el does not bind these two commands, because simple repeatable keys are rare (mostly taken already).

However, if you invoke command thgcmd-bind-keys (e.g. in your init file) then similar commands, ‘next-visible-thing-repeat’, ‘previous-visible-thing’, are bound to keys ‘C-x up’ and ‘C-x down’, respectively.

You can repeat movement in either direction without being prompted for the thing type after the first invocation: `C-x up up up up...’. However, unlike bindings for ‘next-visible-thing’ and ‘previous-visible-thing’, if you change direction you are prompted again for the thing type. That’s simply due to definition of command ‘repeat’, which is used for the implementation.


Libraries referenced here: Lisp:thing-cmds.el

CategoryCode CategoryComments CategoryRegion