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: Karl Fogel
Subject: Re: beginning-of-thing-pos, end-of-thing-pos
Date: Sun, 19 Aug 2007 14:21:57 -0700
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

This sounds like a good idea to me.

You might want to call them "-point" instead of "-pos", as that seems
to be the most common convention for this sort of thing.  I did a
search of all symbols and "-point" was most common, followed by
"-pos", followed distantly by "-posn".  Also, "-point" avoids
confusion with the "position" objects returned by 'event-start' and
'event-end' and used by the 'posn-*' functions.

-Karl


Andreas Röhler <address@hidden> writes:
> 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
>
>
>
>
>
> _______________________________________________
> 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]