* 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
* Re: beginning-of-thing-pos, end-of-thing-pos
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
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Röhler @ 2007-08-19 15:02 UTC (permalink / raw)
To: emacs-devel
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
> Emacs-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: beginning-of-thing-pos, end-of-thing-pos
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
1 sibling, 0 replies; 3+ messages in thread
From: Karl Fogel @ 2007-08-19 21:21 UTC (permalink / raw)
To: Andreas Röhler; +Cc: emacs-devel
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 <andreas.roehler@online.de> 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
> Emacs-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-devel
^ 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.