all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* thingatpt
@ 2008-02-29  2:00 Xavier Maillard
  2008-02-29  3:29 ` thingatpt Bastien Guerry
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Xavier Maillard @ 2008-02-29  2:00 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

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 ?

Regards,

	Xavier
-- 
http://www.gnu.org
http://www.april.org
http://www.lolica.org




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: thingatpt
  2008-02-29  2:00 thingatpt Xavier Maillard
@ 2008-02-29  3:29 ` Bastien Guerry
  2008-02-29  3:57 ` thingatpt Drew Adams
  2008-02-29  7:20 ` thingatpt Andreas Röhler
  2 siblings, 0 replies; 4+ messages in thread
From: Bastien Guerry @ 2008-02-29  3:29 UTC (permalink / raw)
  To: Xavier Maillard; +Cc: help-gnu-emacs

Xavier Maillard <xma@gnu.org> writes:

> I am trying to find out how to extend thing at point for a
> personnal need.

I'm not sure you need thingatpt.  

> 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 ?

I would use something like this:

(defvar my-mouse-map (make-sparse-keymap))

(define-key my-mouse-map [(tab)] 'my-goto-next-active-string)

(defun my-goto-next-active-string ()
  (interactive)
  (let ((pos (point)))
    (re-search-forward "\\<[0-9]\\{10\\}\\>" nil t)
    (if (and (eq (match-beginning 0) pos)
	     (re-search-forward "\\<[0-9]\\{10\\}\\>" nil t))
	(goto-char (match-beginning 0))
      (goto-char pos))))

(defun my-make-active-strings ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (while (re-search-forward "\\<[0-9]\\{10\\}\\>" nil t)
      (add-text-properties (match-beginning 0) (match-end 0)
			   (list 'mouse-face 'highlight
				 'rear-nonsticky t
				 'keymap my-mouse-map)))))

You can also use `next-single-property-change' instead of the regexp 
in my-goto-next-active-string.  Hope this gives you directions.

-- 
Bastien




^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: thingatpt
  2008-02-29  2:00 thingatpt Xavier Maillard
  2008-02-29  3:29 ` thingatpt Bastien Guerry
@ 2008-02-29  3:57 ` Drew Adams
  2008-02-29  7:20 ` thingatpt Andreas Röhler
  2 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2008-02-29  3:57 UTC (permalink / raw)
  To: 'Xavier Maillard', help-gnu-emacs

> 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
and list-at-point.

Library thingatpt+.el has additional examples of defining things:
http://www.emacswiki.org/cgi-bin/wiki/thingatpt%2b.el
http://www.emacswiki.org/cgi-bin/wiki/ThingAtPointPlus

For more info (start here):
http://www.emacswiki.org/cgi-bin/wiki/ThingAtPoint

HTH.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: thingatpt
  2008-02-29  2:00 thingatpt Xavier Maillard
  2008-02-29  3:29 ` thingatpt Bastien Guerry
  2008-02-29  3:57 ` thingatpt Drew Adams
@ 2008-02-29  7:20 ` Andreas Röhler
  2 siblings, 0 replies; 4+ messages in thread
From: Andreas Röhler @ 2008-02-29  7:20 UTC (permalink / raw)
  To: Xavier Maillard; +Cc: help-gnu-emacs

Am Freitag, 29. Februar 2008 03:00 schrieb Xavier Maillard:
> Hi,
>
> 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 ?
>
> Regards,
>
> 	Xavier

thingatpt-utils 1.9

published at

http://lists.gnu.org/archive/html/gnu-emacs-sources/2008-02/msg00000.html

provides number-atpt, forward- backward-, bounds-of etc.

All things there you may quote, doublequote, trim etc.

Should you need to select a certain range of numbers
only, I could implement that.

Andreas Röhler




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-02-29  7:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-29  2:00 thingatpt Xavier Maillard
2008-02-29  3:29 ` thingatpt Bastien Guerry
2008-02-29  3:57 ` thingatpt Drew Adams
2008-02-29  7:20 ` thingatpt Andreas Röhler

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.