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-thingxah-get-bounds-of-thing-or-regionxah-get-thing-or-regionxah-get-thing-at-pointxah-get-bounds-of-blockxah-get-bounds-of-block-or-regionxah-get-pos-of-blockxah-get-pos-of-block-orxah-get-pos-of-wordxah-get-pos-of-word-orxah-get-pos-of-symbolxah-get-pos-of-symbol-orxah-get-pos-of-glyphsxah-get-pos-of-glyphs-orxah-get-pos-of-urlxah-get-pos-of-url-orxah-get-pos-of-filepathxah-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: Get Text at Cursor (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-setqandseq-let. 〔see Elisp: Destructure Binding (seq-setq, seq-let)〕