Emacs: xah-get-thing.el

By Xah Lee. Date: . Last updated: .

This is the home page of the package xah-get-thing.el.

The package gives you the following functions:

They are useful for writing commands that act on text selection if there's one, or current {symbol, block, …} under cursor.

This package is similar to emac's builtin thing-at-point package thingatpt.el. 〔►see Emacs Lisp: Using thing-at-point

The main differences are:

  1. Is not based on syntax table. So, the “thing” are predicable in any major mode.
  2. provides the 'block, which is similar to emacs's 'paragraph, but strictly defined by between blank lines.
  3. xah-get-bounds-of-thing-or-region Returns the boundary of region, if active. This saves you few lines of code.
  4. Thing 'url and 'filepath, are rather different from how thingatpt.el determines them, and, again, is not based on syntax table, but based on regex of likely characters. Also, result is never modified version of what's in the buffer. For example, if 'url, the http prefix is not automatically added if it doesn't exist in buffer.
  5. Thing 'line never includes newline character. This avoid inconsistency when line is last line.

The return values of these functions is the same format as emacs's thingatpt.el, so you can just drop-in replace by changing the function names in your code.


github: https://github.com/xahlee/xah-get-thing-or-selection

On MELPA http://melpa.org/#/xah-get-thing 〔►see Emacs: How to Install Packages Using ELPA, MELPA

Deprecated Functions

  1. xah-get-thing-at-cursor is deprecated, and it was named unit-at-cursor.
  2. xah-get-thing-or-selection is deprecated, and it was named get-selection-or-unit
Like it? Buy Xah Emacs Tutorial. Thanks.

or, buy something from Best Keyboard for Emacs