[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Thu, 28 Feb 2008 19:57:24 -0800
> I am trying to find out how to extend thing at point for a
> personnal need.
> I have several items that are composed of a series of numbers (10
> to be precise), these items represents transaction's IDs. I want
> GNU Emacs to recognise them as this so that I can do specialised
> actions on them. All is ready *but* I do not know how to define a
> "thing" with thingatpt.el.
> On the same topic, I can have several transaction IDs on the same
> line, for exmple:
> 1234567890 0123456789 etc.
> I'd like to be able to navigate to the next/previous item using
> the TAB key, how would you do that ?
A basic idea of thingatpt is that you can just define a function that moves
forward across your thing. If you call your thing, say, transids, then you
would define a function `forward-transids'. That's all.
You can alternatively put one or more of these properties on a symbol that
names your thing, `transids': beginning-op, end-op,
bounds-of-thing-at-point, thing-at-point. The property values are functions
that determine the beginning, end, beginning and end of such a thing, or the
entire thing itself.
thingatpt.el has several examples of defining types of things: url (via
properties end-op, beginning-op, thing-at-point, and
bounds-of-thing-at-point), whitespace (via function forward-whitespace),
buffer (via properties end-op and beginning-op), symbol (via function
forward-symbol), and so on.
You can also use the function thing-at-point to define things. See the
examples of word-at-point and sentence-at-point. You can, similarly, use
function form-at-point to do the same thing - see examples number-at-point
Library thingatpt+.el has additional examples of defining things:
For more info (start here):