all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* beginning-of-thing-pos, end-of-thing-pos
@ 2007-08-19 14:46 Andreas Röhler
  2007-08-19 15:02 ` Andreas Röhler
  2007-08-19 21:21 ` Karl Fogel
  0 siblings, 2 replies; 3+ messages in thread
From: Andreas Röhler @ 2007-08-19 14:46 UTC (permalink / raw)
  To: emacs-devel


Hi,

at several occasions I needed the buffer-position of a
string (thing).

As I wrote my own thingatpt-utils, already have that. 

But would prefer to keep every code as much
as possible conform with distribution.

Therefore my request for a (very) simple addition:

thingatpt.el knows about THING's position:

(defun beginning-of-thing (thing)
  (let ((bounds (bounds-of-thing-at-point thing)))
    (or bounds (error "No %s here" thing))
    (goto-char (car bounds))))

(defun end-of-thing (thing)
  (let ((bounds (bounds-of-thing-at-point thing)))
    (or bounds (error "No %s here" thing))
    (goto-char (cdr bounds))))

As visible, these functions move point rather than
returning the pos. Simply need some reduction:

(defun beginning-of-thing-pos (thing)
  (let ((bounds (bounds-of-thing-at-point thing)))
    (or bounds (error "No %s here" thing))
    (car bounds)))

(defun end-of-thing-pos (thing)
  (let ((bounds (bounds-of-thing-at-point thing)))
    (or bounds (error "No %s here" thing))
    (cdr bounds)))

Afterwards things like that are possible:

(defun end-of-word-at-point ()
  " "
  (interactive)
  (message "%s" (end-of-thing-pos 'word)))

May `beginning-of-thing-pos' and `end-of-thing-pos'
be included?

Thanks

Andreas Roehler

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

end of thread, other threads:[~2007-08-19 21:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-19 14:46 beginning-of-thing-pos, end-of-thing-pos Andreas Röhler
2007-08-19 15:02 ` Andreas Röhler
2007-08-19 21:21 ` Karl Fogel

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.