From: Karl Fogel <kfogel@red-bean.com>
To: "Andreas Röhler" <andreas.roehler@online.de>
Cc: emacs-devel@gnu.org
Subject: Re: beginning-of-thing-pos, end-of-thing-pos
Date: Sun, 19 Aug 2007 14:21:57 -0700 [thread overview]
Message-ID: <87mywn8bka.fsf@red-bean.com> (raw)
In-Reply-To: <200708191646.40265.andreas.roehler@online.de> ("Andreas Röhler"'s message of "Sun\, 19 Aug 2007 16\:46\:39 +0200")
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
prev parent reply other threads:[~2007-08-19 21:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mywn8bka.fsf@red-bean.com \
--to=kfogel@red-bean.com \
--cc=andreas.roehler@online.de \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.