ThingAtPointPlus

Difference between revision 12 and revision 13

No diff available.

This page describes library ThingAtPoint+ (thingatpt+.el). This is an extension of standard library thingatpt.el (See ThingAtPoint). It provides various functions for determining (returning) different objects at or near point.

The objects are THINGs for which there is either a corresponding ‘forward-’THING operation, or corresponding ‘beginning-of-’THING and ‘end-of-’THING operations.

Examples of THING are ‘word’, ‘sentence’, and ‘defun’. For example, words have Emacs Lisp functions ‘forward-word’, ‘beginning-of-word’, and ‘end-of-word’ functions. Library thingatpt+.el uses such functions to return the word at or nearest the cursor.

Library thingatpt+.el also provides functions to pick up things that are near the cursor, not just things that are exactly under the cursor. For this feature, you can customize two user options that control what “near” means, that is, how far from the cursor to look.

In addition, the code in thingatpt+.el respects Emacs field boundaries. This means, for example, that if you pick up a thing near the minibuffer prompt you won’t get “Text is read-only” errors etc.

The following categories are detailed below:

See Also: ThingAtPointCommands, for commands to select different kinds of things at or near point.

Things

Forms

A form is a particular kind of Lisp thing that optionally satisfies a particular predicate. The default kind of form is a Lisp S-expression (sexp).

Symbols and Symbol Names

Lists

The ThingAtPt+ list functions all accept an optional argument ‘UP’, which is the number of list levels to go up to start with. IOW, ‘UP’ lets you retrieve a wider list than the one immediately surrounding point.

In addition, the ThingAtPt+ redefinition of standard function ‘list-at-point’ provides better and more consistent behavior: it does what you would expect.

The ‘unquoted-’ functions remove any quote or backquote, so that, e.g., 'bar and `(foo a b) gives you bar and (foo a b) instead of (quote bar) and (backquote-backquote-symbol(foo a b)), which is `(foo a b).

See also: ThingAtPointCommands, for commands such as ‘mark-enclosing-sexp’, to select successively larger lists surroundig point.

Other: Words, Sentences, Sexps, Numbers, Colors

Color means either a defined color name or an RGB hex color code prefixed by `#’.

Gotcha: Vanilla ‘number-at-point’ returns the char value, not ‘nil’, when point is on a char: when on ?A it returns 65; when on ?\A-\^@ it returns 4194304. See Emacs bug 8634.

See also: ThingAtPointCommands, for commands such as ‘mark-enclosing-sexp’, to select successively larger sexps surroundig point.


CategoryCode