emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: beginning-of-thing-pos, end-of-thing-pos


From: Andreas Röhler
Subject: Re: beginning-of-thing-pos, end-of-thing-pos
Date: Sun, 19 Aug 2007 17:02:46 +0200
User-agent: KMail/1.8.2

Am Sonntag, 19. August 2007 16:46 schrieb Andreas Röhler:
> 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. 

No, sorry. I see "The return value is position".
So question is reduced to avoid the move.

> 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
>
>
>
>
>
> _______________________________________________
> Emacs-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/emacs-devel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]