Emacs: xah-get-thing.el 📦
xah-get-thing.el
is a emacs lisp utility for grabbing text under cursor.
Download
Functions
xah-get-bounds-of-thing
xah-get-bounds-of-thing-or-region
xah-get-thing-or-region
xah-get-thing-at-point
xah-get-bounds-of-block
xah-get-bounds-of-block-or-region
xah-get-pos-of-block
xah-get-pos-of-block-or
xah-get-pos-of-word
xah-get-pos-of-word-or
xah-get-pos-of-symbol
xah-get-pos-of-symbol-or
xah-get-pos-of-glyphs
xah-get-pos-of-glyphs-or
xah-get-pos-of-url
xah-get-pos-of-url-or
xah-get-pos-of-filepath
xah-get-pos-of-filepath-or
Features
The package gives you the several functions to get the boundary of current word, line, glyph, text block (paragraph), filepath, url, etc, or text selection if there is active region.
This package is similar to emacs builtin thing-at-point
package
thingatpt.el
.
〔see Elisp: thing-at-point〕
The differences are:
- Is not based on syntax table. So, the “thing” are predicable in any major mode. (exception is when you get “symbol”, because different language have very different take on what chars are allowed in identifier.)
- You can get block of text, which is similar to emacs's paragraph, but strictly defined by between blank lines.
- Functions that get the text selection first, if a region is active. This saves you few lines of code.
- Getting url and filepath are not based on syntax table, but based on likely characters. Also, result is never modified version of what's in the buffer. For example, if getting url, the http prefix is not automatically added if it doesn't exist in original text.
- Getting a line never includes newline character. This avoid inconsistency when line is last line.
Return a Vector
- Has functions that return a vector, so they can be used with
seq-setq
andseq-let
. 〔see Elisp: Destructure Binding (seq-setq, seq-let)〕