help-gnu-emacs
[Top][All Lists]
Advanced

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

RE: [External] : (bounds-of-thing-at-point 'number) ⇒ nil


From: Drew Adams
Subject: RE: [External] : (bounds-of-thing-at-point 'number) ⇒ nil
Date: Fri, 4 Feb 2022 15:19:27 +0000

> (require 'thingatpt)
> 123
>  ^
> when I place cursor there under number 2, and evaluate
> (bounds-of-thing-at-point  'number) I get result nil.
> I am expecting to get the bounds.
> 
> When I evaluate (thing-at-point 'number) then I get
> see result being 123.

IMO, thingatpt.el and its functions, including
`bounds-of-thing-at-point', are both limited & bugged.

In particular, they suffer from the assumption that
their _only_ use is to grab something at point OR at
point-minus-1.

"Thing at point" means something better than that.
It means give me the thing at point, or give me nil
to tell me that there's no such thing at point.

It's more useful to be able to check for the presence
of a thing _at point_, and thus return nil if point
only _follows_ a thing.  That provides for lots of
use cases beyond just trying to grab some text that's
almost at point.

(And for the latter use case, there are more useful
DWIM functions for getting something _near_ point,
i.e., within a given text "distance".)

Try `thingatpt+.el'.  It does THINGs right.

It lets you or existing code still continue to use
the bugged vanilla thing-at-point functions, by
default.  (But it provides additional functions
for more THING cases.)

Or you can replace/override the vanilla functions
with those (prefix `tap-') from `thingatpt+.el',
which DTRT.  To do that:

(eval-after-load "thingatpt"
  '(when (require 'thingatpt+ nil t)
     (tap-redefine-std-fns))

If you do that then you don't need to include the
prefix `tap-' to get correct behavior for the
standard functions.

Not only does `(tap-)bounds-of-thing-at-point'
work for numbers.  You also have these number
functions and their `bounds-of-' partners:

 tap-number-at-point-decimal 
 tap-number-at-point-decimal-whole 
 tap-number-at-point-hex 
 tap-number-nearest-point

____

Description:

https://www.emacswiki.org/emacs/ThingAtPointPlus

Code:

https://www.emacswiki.org/emacs/download/thingatpt%2b.el

Bug 9300:

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=9300

reply via email to

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