all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* (bounds-of-thing-at-point  'number) ⇒ nil
@ 2022-02-04 12:47 Jean Louis
  2022-02-04 13:20 ` tomas
  2022-02-04 15:19 ` [External] : " Drew Adams
  0 siblings, 2 replies; 23+ messages in thread
From: Jean Louis @ 2022-02-04 12:47 UTC (permalink / raw)
  To: Help GNU Emacs


(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. 




pppppppppp
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-04 12:47 (bounds-of-thing-at-point 'number) ⇒ nil Jean Louis
@ 2022-02-04 13:20 ` tomas
  2022-02-04 14:20   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2022-02-04 14:41   ` Robert Pluim
  2022-02-04 15:19 ` [External] : " Drew Adams
  1 sibling, 2 replies; 23+ messages in thread
From: tomas @ 2022-02-04 13:20 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 745 bytes --]

On Fri, Feb 04, 2022 at 03:47:19PM +0300, Jean Louis wrote:
> 
> (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. 

Note that number isn't among the things mentioned in the function doc of
`bounds-of-thing-at-point'. It is, however in that of `thing-at-point'.

So the behaviour you describe is surprising, but it is documented :)

Perhaps both functions might want to get reconciled with each others.
But perhaps there is a deeper reason their "things" lists differ.

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-04 13:20 ` tomas
@ 2022-02-04 14:20   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2022-02-04 14:41   ` Robert Pluim
  1 sibling, 0 replies; 23+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-02-04 14:20 UTC (permalink / raw)
  To: help-gnu-emacs

tomas wrote:

> Note that number isn't among the things mentioned in the
> function doc of `bounds-of-thing-at-point'. It is, however
> in that of `thing-at-point'.

Bug. It doesn't exist - but it should - so it returns nil ...

This is what happens when/if you manually have to give data
that are the same same, twice. Only input it once, then add 2
or as many references are called for to that data ...

> So the behaviour you describe is surprising, but it is
> documented :)

Anyway the docstring also says:

  See the file ‘thingatpt.el’ for documentation on how to
  define a valid THING.

But that isn't even a clickable button.

It should be called `thing-at-point' BTW. That looks like
something out of C or Python.

> Perhaps both functions might want to get reconciled with
> each others. But perhaps there is a deeper reason their
> "things" lists differ.

*thumbs-down*

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-04 13:20 ` tomas
  2022-02-04 14:20   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-02-04 14:41   ` Robert Pluim
  2022-02-04 14:50     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2022-02-04 21:29     ` [External] : " Drew Adams
  1 sibling, 2 replies; 23+ messages in thread
From: Robert Pluim @ 2022-02-04 14:41 UTC (permalink / raw)
  To: tomas; +Cc: help-gnu-emacs

>>>>> On Fri, 4 Feb 2022 14:20:47 +0100, <tomas@tuxteam.de> said:

    tomas> On Fri, Feb 04, 2022 at 03:47:19PM +0300, Jean Louis wrote:
    >> 
    >> (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. 

    tomas> Note that number isn't among the things mentioned in the function doc of
    tomas> `bounds-of-thing-at-point'. It is, however in that of `thing-at-point'.

    tomas> So the behaviour you describe is surprising, but it is documented :)

    tomas> Perhaps both functions might want to get reconciled with each others.
    tomas> But perhaps there is a deeper reason their "things" lists differ.

I think it just means that nobody has implemented
`bounds-of-thing-at-point' for 'number. Patches welcome :-)

Robert
-- 



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-04 14:41   ` Robert Pluim
@ 2022-02-04 14:50     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2022-02-04 21:29     ` [External] : " Drew Adams
  1 sibling, 0 replies; 23+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-02-04 14:50 UTC (permalink / raw)
  To: help-gnu-emacs

Robert Pluim wrote:

> I think it just means that nobody has implemented
> `bounds-of-thing-at-point' for 'number. Patches welcome :-)

Worse than forgetting to implement the same thing twice is ...
implementing the same thing twice.

Hey, look who's talking, what about _saying_ the same thing
twice?

Are you kidding, just two times, I take it!! <euphoria>

https://www.youtube.com/watch?v=bcnWysA9gxo

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 23+ messages in thread

* RE: [External] : (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-04 12:47 (bounds-of-thing-at-point 'number) ⇒ nil Jean Louis
  2022-02-04 13:20 ` tomas
@ 2022-02-04 15:19 ` Drew Adams
  2022-02-04 15:35   ` Jean Louis
  1 sibling, 1 reply; 23+ messages in thread
From: Drew Adams @ 2022-02-04 15:19 UTC (permalink / raw)
  To: Jean Louis, Help GNU Emacs

> (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

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [External] : (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-04 15:19 ` [External] : " Drew Adams
@ 2022-02-04 15:35   ` Jean Louis
  2022-02-04 15:50     ` Drew Adams
  0 siblings, 1 reply; 23+ messages in thread
From: Jean Louis @ 2022-02-04 15:35 UTC (permalink / raw)
  To: Drew Adams; +Cc: Help GNU Emacs

* Drew Adams <drew.adams@oracle.com> [2022-02-04 18:19]:
> (eval-after-load "thingatpt"
>   '(when (require 'thingatpt+ nil t)
>      (tap-redefine-std-fns))

Thanks, that is useful and I have put it in my ~/.emacs.d/init.el

Then I expected this to work:
(bounds-of-thing-at-point 'number) on  123 and it did not  work. I did
not look into the code.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 23+ messages in thread

* RE: [External] : (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-04 15:35   ` Jean Louis
@ 2022-02-04 15:50     ` Drew Adams
  2022-02-04 16:55       ` Jean Louis
  0 siblings, 1 reply; 23+ messages in thread
From: Drew Adams @ 2022-02-04 15:50 UTC (permalink / raw)
  To: Jean Louis; +Cc: Help GNU Emacs

> > (eval-after-load "thingatpt"
> >   '(when (require 'thingatpt+ nil t)
> >      (tap-redefine-std-fns))
> 
> Thanks, that is useful and I have put it in my ~/.emacs.d/init.el
> 
> Then I expected this to work:
> (bounds-of-thing-at-point 'number) on 123 and it did not work. I did
> not look into the code.

Works for me, starting from `emacs -Q'
(no init file).

What does `C-h f bounds-of-thing-at-point'
tell you?  Does it say that it's an alias
for `tap-bounds-of-thing-at-point'?

If not, did you actually load the library?
(Put it in a dir in your `load-path'.)



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [External] : (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-04 15:50     ` Drew Adams
@ 2022-02-04 16:55       ` Jean Louis
  2022-02-04 21:29         ` Drew Adams
  0 siblings, 1 reply; 23+ messages in thread
From: Jean Louis @ 2022-02-04 16:55 UTC (permalink / raw)
  To: Drew Adams; +Cc: Help GNU Emacs

* Drew Adams <drew.adams@oracle.com> [2022-02-04 18:50]:
> > > (eval-after-load "thingatpt"
> > >   '(when (require 'thingatpt+ nil t)
> > >      (tap-redefine-std-fns))
> > 
> > Thanks, that is useful and I have put it in my ~/.emacs.d/init.el
> > 
> > Then I expected this to work:
> > (bounds-of-thing-at-point 'number) on 123 and it did not work. I did
> > not look into the code.
> 
> Works for me, starting from `emacs -Q'
> (no init file).
> 
> What does `C-h f bounds-of-thing-at-point'
> tell you?  Does it say that it's an alias
> for `tap-bounds-of-thing-at-point'?

bounds-of-thing-at-point    is   a    compiled   Lisp    function   in
‘thingatpt.el’.

(bounds-of-thing-at-point THING)

> If not, did you actually load the library?
> (Put it in a dir in your `load-path'.)

Yes,  I did.  And  I loaded  also  with M-x  load-library  and I  have
directory with your scripts in my load-path

So I do not get it why it is not loading and overwriting functions.

After  evaluating  this:  (tap-redefine-std-fns)  I  have  got  it  to
work. Just this below is not working well.

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

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 23+ messages in thread

* RE: [External] : (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-04 16:55       ` Jean Louis
@ 2022-02-04 21:29         ` Drew Adams
  2022-02-04 21:46           ` Drew Adams
  2022-02-06  6:08           ` Jean Louis
  0 siblings, 2 replies; 23+ messages in thread
From: Drew Adams @ 2022-02-04 21:29 UTC (permalink / raw)
  To: Jean Louis; +Cc: Help GNU Emacs

> > What does `C-h f bounds-of-thing-at-point'
> > tell you?  Does it say that it's an alias
> > for `tap-bounds-of-thing-at-point'?
> 
> bounds-of-thing-at-point    is   a    compiled   Lisp    function   in
> ‘thingatpt.el’.

That means thingatpt+.el wasn't loaded.

You likely need to either (1) change the file
name "thingatpt" to be absolute or relative
to where you're evaluating that sexp or (2)
use symbol `thingatpt' instead of a string.
Try the latter first.

See what `C-h f eval-after-load' says about
arg FILE.

> > If not, did you actually load the library?
> > (Put it in a dir in your `load-path'.)
> 
> Yes,  I did.  And  I loaded  also  with M-x  load-library  and I  have
> directory with your scripts in my load-path
> 
> So I do not get it why it is not loading and overwriting functions.

If you loaded it (e.g. using `load-library)
then it's loaded.  The reason it's not
overwriting the vanilla functions is no doubt
because file "thingatpt" never got loaded, so
the `eval-after-load' code never got evaluated.

I was probably too cryptic in writing just
"thingatpt".  Sorry.  Hopefully it's clear now.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* RE: [External] : Re: (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-04 14:41   ` Robert Pluim
  2022-02-04 14:50     ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-02-04 21:29     ` Drew Adams
  2022-02-06  6:12       ` Jean Louis
  2022-02-06  8:43       ` Drew Adams
  1 sibling, 2 replies; 23+ messages in thread
From: Drew Adams @ 2022-02-04 21:29 UTC (permalink / raw)
  To: Robert Pluim, tomas@tuxteam.de; +Cc: help-gnu-emacs@gnu.org

> I think it just means that nobody has implemented
> `bounds-of-thing-at-point' for 'number. Patches welcome :-)

I don't think it means that.  Here's a definition.
Add it to thingatpt.el, if you really believe it's
welcome.  (This isn't be the first time this and
similar have been offered.)

Just drop the `tap-' prefix in both places.

(defun tap-bounds-of-number-at-point ()
  "Return the bounds of the number represented by the numeral at point.
Return nil if none is found."
  (and (number-at-point)
       (tap-bounds-of-thing-at-point 'sexp)))



^ permalink raw reply	[flat|nested] 23+ messages in thread

* RE: [External] : (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-04 21:29         ` Drew Adams
@ 2022-02-04 21:46           ` Drew Adams
  2022-02-05  0:54             ` Emanuel Berg via Users list for the GNU Emacs text editor
  2022-02-06  6:08           ` Jean Louis
  1 sibling, 1 reply; 23+ messages in thread
From: Drew Adams @ 2022-02-04 21:46 UTC (permalink / raw)
  To: Drew Adams, Jean Louis; +Cc: Help GNU Emacs

> You likely need to either (1) change the file
> name "thingatpt" to be absolute or relative
> to where you're evaluating that sexp or (2)
> use symbol `thingatpt' instead of a string.
> Try the latter first.
> 
> See what `C-h f eval-after-load' says about
> arg FILE.

I've updated the Commentary of the file to make
this clear - just use 'thingatpt instead of a
string file name.

(The library works also with old Emacs versions,
where the `eval-after-load' FILE arg must be a
file name (string).  Starting with Emacs 22, it
can also be a feature name, which is a symbol.)


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [External] : (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-04 21:46           ` Drew Adams
@ 2022-02-05  0:54             ` Emanuel Berg via Users list for the GNU Emacs text editor
  2022-02-05  1:36               ` Drew Adams
  0 siblings, 1 reply; 23+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-02-05  0:54 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams wrote:

> I've updated the Commentary of the file to make this clear -
> just use 'thingatpt instead of a string file name.
>
> (The library works also with old Emacs versions, where the
> `eval-after-load' FILE arg must be a file name (string).
> Starting with Emacs 22, it can also be a feature name, which
> is a symbol.)

You got it to work with the alternative package, thingatpt+?
(yuk! the plus sign)

Should be added to the main package ...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 23+ messages in thread

* RE: [External] : (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-05  0:54             ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-02-05  1:36               ` Drew Adams
  2022-02-05  1:56                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 23+ messages in thread
From: Drew Adams @ 2022-02-05  1:36 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

[-- Attachment #1: Type: text/plain, Size: 576 bytes --]

> You got it to work with the alternative
> package, thingatpt+?

Got what to work?  thingatpt+.el isn't an
alternative in the sense that it replaces
thingatpt.el.  It fixes and extends stuff
in the latter.  It builds on it.

> (yuk! the plus sign)

In my case the + means it extends that
library, and requires it.

(I've even had a couple libraries with
suffix - instead of +, where - means
load before the library to be extended,
and + means load after it.)

> Should be added to the main package ...

Tell that to the package maintainers.
I've tried.

[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 14400 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [External] : (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-05  1:36               ` Drew Adams
@ 2022-02-05  1:56                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2022-02-05 17:27                   ` Drew Adams
  0 siblings, 1 reply; 23+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-02-05  1:56 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams wrote:

>> You got it to work with the alternative
>> package, thingatpt+?
>
> Got what to work?  thingatpt+.el isn't an
> alternative in the sense that it replaces
> thingatpt.el.  It fixes and extends stuff
> in the latter.  It builds on it.

Okay, alternative function then.

>> (yuk! the plus sign)
>
> In my case the + means it extends that
> library, and requires it.

Okay, but it still doesn't look good is all I'm saying.

As for what is `require'd no need to communicate that to
anyone since it is handled by/in library+'s source ...

> (I've even had a couple libraries with suffix - instead of
> +, where - means load before the library to be extended, and
> + means load after it.)

A clever little game in your mind and by all means, but it
doesn't look good and with the hyphen-minus it looks even
worse since that is used as our beloved
lisp-word-separator ...

And there is no need to communicate any of that, anything
should be possible to load at any time and if at that point
further loading is ... required then that is all handled in
that pack's source, nothing to bother the mere user with since
s/he isn't even doing it.

Or they are not redefining each other's stuff, are they?

>> Should be added to the main package ...
>
> Tell that to the package maintainers. I've tried.

Okay, what did they say?

Do it! Then we can remove the annoying signs as well.
Problem solved :)

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 23+ messages in thread

* RE: [External] : (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-05  1:56                 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-02-05 17:27                   ` Drew Adams
  2022-02-06 15:48                     ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 23+ messages in thread
From: Drew Adams @ 2022-02-05 17:27 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

[-- Attachment #1: Type: text/plain, Size: 2572 bytes --]

> >> You got it to work with the alternative
> >> package, thingatpt+?
> >
> > Got what to work?  thingatpt+.el isn't an
> > alternative in the sense that it replaces
> > thingatpt.el.  It fixes and extends stuff
> > in the latter.  It builds on it.
> 
> Okay, alternative function then.

I repeat, "Got what to work?"

___

> As for what is `require'd no need to communicate that to
> anyone since it is handled by/in library+'s source ...

I was explaining to you the file-name convention I
use, since you brought up the `+' in the file name.

> > (I've even had a couple libraries with suffix - instead of
> > +, where - means load before the library to be extended, and
> > + means load after it.)
> 
> A clever little game in your mind and by all means, but it
> doesn't look good and with the hyphen-minus it looks even
> worse since that is used as our beloved
> lisp-word-separator ...

File-name syntax has nothing to do with Lisp syntax.

That some file name "doesn't look good" to you is,
well, too bad.  You're not obliged to like it. ;-)

> And there is no need to communicate any of that,

No.  Users can sometimes need to know how and when
to load a library.

> anything should be possible to load at any time

Absolutely not - if the intended behavior is to
be achieved.  Load order of libraries matters, in
general.  Loading means evaluating Lisp code, and
evaluation order matters in Lisp.

> and if at that point
> further loading is ... required then that is all handled in
> that pack's source, nothing to bother the mere user with since
> s/he isn't even doing it.

I think you're wailing in the dark, here.

This is what such a file says.  Do you think users
shouldn't be told this?

;;; Commentary:
;;
;;  Extensions to library `ffap.el'.
;;
;;  To use this library, add this to your initialization file.
;;
;;      (require 'ffap-) ; Load this library.
;;
;;  You should explicitly load *only* `ffap-.el', not also
;;  `ffap.el' (this will automatically load `ffap.el').

> Or they are not redefining each other's stuff, are they?

They are.  And at specific points.

`ffap-.el', for instance, redefines variable
`ffap-bindings', to make it user option.
And it adds a variable to let you inhibit FFAP
buffer-locally.

Then it loads standard library `ffap.el'.

Then it redefines function `ffap-guesser', to
take advantage of those vars.

https://www.emacswiki.org/emacs/download/ffap-.el

See also bug #26243:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25243

[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 16004 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [External] : (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-04 21:29         ` Drew Adams
  2022-02-04 21:46           ` Drew Adams
@ 2022-02-06  6:08           ` Jean Louis
  2022-02-06  7:02             ` Drew Adams
  1 sibling, 1 reply; 23+ messages in thread
From: Jean Louis @ 2022-02-06  6:08 UTC (permalink / raw)
  To: Drew Adams; +Cc: Help GNU Emacs

* Drew Adams <drew.adams@oracle.com> [2022-02-05 00:29]:
> > > What does `C-h f bounds-of-thing-at-point'
> > > tell you?  Does it say that it's an alias
> > > for `tap-bounds-of-thing-at-point'?
> > 
> > bounds-of-thing-at-point   is   a   compiled  Lisp   function   in
> > ‘thingatpt.el’.
> 
> That means thingatpt+.el wasn't loaded.
> 
> You likely need to either (1) change the file
> name "thingatpt" to be absolute or relative
> to where you're evaluating that sexp or (2)
> use symbol `thingatpt' instead of a string.
> Try the latter first.

It  is not  solved and  it works  well with  (bounds-of-thing-at-point
'number) -- thanks

I had the  database table `pages' and I have  converted them into more
general hyperscope objects.  There were and there still  are some page
numbers referenced from other pages, so  I had to make a function that
will lookup the page number and find the new hyperdocument number, and
replace one with each other.

With standard  thingatpt.el this did work,  but I have used  'word and
manually taken care that I am on the right "word" which was 123.

(defun rcd-change-number-at-point (new-number)
  (let* ((bounds (bounds-of-thing-at-point 'word))
         (number (buffer-substring (car bounds) (cdr bounds)))
         (point (point)))
    (goto-char (car bounds))
    (delete-char (length number))
    (insert (number-to-string new-number))
    (goto-char point)))


and  now instead  of  `'word'  I can  put  `'number',  as the  library
`thingatpt+.el' is upgrading or extending the built-in one.



-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [External] : Re: (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-04 21:29     ` [External] : " Drew Adams
@ 2022-02-06  6:12       ` Jean Louis
  2022-02-06  8:44         ` Drew Adams
  2022-02-06  8:43       ` Drew Adams
  1 sibling, 1 reply; 23+ messages in thread
From: Jean Louis @ 2022-02-06  6:12 UTC (permalink / raw)
  To: Drew Adams; +Cc: Robert Pluim, help-gnu-emacs@gnu.org

* Drew Adams <drew.adams@oracle.com> [2022-02-05 00:33]:
> > I think it just means that nobody has implemented
> > `bounds-of-thing-at-point' for 'number. Patches welcome :-)
> 
> I don't think it means that.  Here's a definition.
> Add it to thingatpt.el, if you really believe it's
> welcome.  (This isn't be the first time this and
> similar have been offered.)

What was the reason  why the library is not included,  or was it maybe
rejected, to improve the built-in thingatpt.el?


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 23+ messages in thread

* RE: [External] : (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-06  6:08           ` Jean Louis
@ 2022-02-06  7:02             ` Drew Adams
  2022-02-06  8:10               ` Jean Louis
  0 siblings, 1 reply; 23+ messages in thread
From: Drew Adams @ 2022-02-06  7:02 UTC (permalink / raw)
  To: Jean Louis; +Cc: Help GNU Emacs

> > That means thingatpt+.el wasn't loaded.
> >
> > You likely need to either (1) change the file
> > name "thingatpt" to be absolute or relative
> > to where you're evaluating that sexp or (2)
> > use symbol `thingatpt' instead of a string.
> > Try the latter first.
>
> It  is not  solved and  it works  well with  (bounds-of-thing-at-point
> 'number) -- thanks
...
> and  now instead  of  `'word'  I can  put  `'number',  as the  library
> `thingatpt+.el' is upgrading or extending the built-in one.

Sorry, but I don't understand what you're saying.
I guess you're saying, by "it is not solved" that
you haven't been able to load thingatpt+.el.  It's
not clear to me why not or what you've tried.

Anyway, you seem happy with whatever you arrived at.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [External] : (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-06  7:02             ` Drew Adams
@ 2022-02-06  8:10               ` Jean Louis
  0 siblings, 0 replies; 23+ messages in thread
From: Jean Louis @ 2022-02-06  8:10 UTC (permalink / raw)
  To: Drew Adams; +Cc: Help GNU Emacs

* Drew Adams <drew.adams@oracle.com> [2022-02-06 10:51]:
> Sorry, but I don't understand what you're saying.
> I guess you're saying, by "it is not solved" that
> you haven't been able to load thingatpt+.el.  It's
> not clear to me why not or what you've tried.
> 
> Anyway, you seem happy with whatever you arrived at.

It is solved that `thingatpt+.el'  loads correctly.  I think there was
some  error when  I was  yanking lines  into init.el  and once  I have
corrected parenthesis it works well.

Now  I am  thinking to  use thing-at-point  functions to  quickly move
function definitions from one file to other file.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 23+ messages in thread

* RE: [External] : Re: (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-04 21:29     ` [External] : " Drew Adams
  2022-02-06  6:12       ` Jean Louis
@ 2022-02-06  8:43       ` Drew Adams
  1 sibling, 0 replies; 23+ messages in thread
From: Drew Adams @ 2022-02-06  8:43 UTC (permalink / raw)
  To: Drew Adams, Robert Pluim, tomas@tuxteam.de; +Cc: help-gnu-emacs@gnu.org

> > I think it just means that nobody has implemented
> > `bounds-of-thing-at-point' for 'number. Patches welcome :-)
> 
> I don't think it means that.  Here's a definition.
> Add it to thingatpt.el, if you really believe it's
> welcome.  (This isn't be the first time this and
> similar have been offered.)
> 
> Just drop the `tap-' prefix in both places.
> 
> (defun tap-bounds-of-number-at-point ()
>   "Return the bounds of the number represented by the numeral at point.
> Return nil if none is found."
>   (and (number-at-point)
>        (tap-bounds-of-thing-at-point 'sexp)))

Apropos - I offered exactly that definition in the
context of bug #21391 (I'd forgotten that I did):

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21391#136



^ permalink raw reply	[flat|nested] 23+ messages in thread

* RE: [External] : Re: (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-06  6:12       ` Jean Louis
@ 2022-02-06  8:44         ` Drew Adams
  0 siblings, 0 replies; 23+ messages in thread
From: Drew Adams @ 2022-02-06  8:44 UTC (permalink / raw)
  To: Jean Louis; +Cc: Robert Pluim, help-gnu-emacs@gnu.org

> What was the reason why the library is not included,
> or was it maybe rejected, to improve the built-in 
> thingatpt.el?

It wasn't wanted.  And in particular the fix to
return nil when there's no such thing at point
but there is such a thing at (1- point) wasn't
wanted.

The bug for that is bug #9300:

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

If someone uses thing-at-point only to get a
default value then they might not  care that
it's bugged, and they might insist that it's
good that it returns a thing when there's no
thing at point - more chance to get a default
value.

But the bug of returning non-nil when there's no
thing at point makes other uses of thing-at-point
impossible.  With that bug you have only the
forward/backward commands, but no way to define
zones of text that correspond to the presence
of things.  With that bug you can't have a
workable notion of next- or previous-thing.

With Isearch+ you can search the text of things
(sexps, lists, defuns, lines, pages, sentences,
file names, strings, comments, xml/html elements,
symbols,...)

This means search within THING search contexts.
Search through the zones of text that correspond
to a given kind of thing.  Or the complement:
search the contexts outside the things.

As mentioned in bug #9300, for that Isearch+
code to work also for vanilla thingatpt.el, it
needs a tweak to compensate for the off-by-one
bug that returns the thing at (1- point) when
there's no thing at point. 

I put it this way in bug #21391:

  I really disagree with what seems to be your view of 
  thingatpt.el functionality.

  I disagreed with it strongly in the context of bug
  #9300, where you were the lone voice proclaiming it.
  You apparently view the only use of this functionality
  as returning a string near (not at) point that can be
  used as an input default value.  thingatpt.el is much
  more than that.  It is very important that it be able
  to be used to test whether there (really) is a given
  THING _at_ point (not just somewhere near point).


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [External] : (bounds-of-thing-at-point  'number) ⇒ nil
  2022-02-05 17:27                   ` Drew Adams
@ 2022-02-06 15:48                     ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 23+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-02-06 15:48 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams wrote:

> This is what such a file says. Do you think users shouldn't
> be told this?
>
> ;;; Commentary:
> ;;
> ;;  Extensions to library `ffap.el'.
> ;;
> ;;  To use this library, add this to your initialization file.
> ;;
> ;;      (require 'ffap-) ; Load this library.
> ;;
> ;;  You should explicitly load *only* `ffap-.el', not also
> ;;  `ffap.el' (this will automatically load `ffap.el').

In general I think if they have to be told that, one hasn't
written good enough code.

If A and B don't rely on each other, obviously the order does
not matter.

If B relies on A, then whenever B is loaded it will just
`require' A so again the order won't matter, or rather, the
correct order is not an issue with A, and implicit with B.

>> Or they are not redefining each other's stuff, are they?
>
> They are.  And at specific points.

Then you ask for trouble. And not just for this reason.

But then yes, if B relies on A and B redefines stuff in A, if
one intends to use those redefined methods while still
referring to them with A's names, then one cannot load A after
loading B ...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2022-02-06 15:48 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-04 12:47 (bounds-of-thing-at-point 'number) ⇒ nil Jean Louis
2022-02-04 13:20 ` tomas
2022-02-04 14:20   ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-02-04 14:41   ` Robert Pluim
2022-02-04 14:50     ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-02-04 21:29     ` [External] : " Drew Adams
2022-02-06  6:12       ` Jean Louis
2022-02-06  8:44         ` Drew Adams
2022-02-06  8:43       ` Drew Adams
2022-02-04 15:19 ` [External] : " Drew Adams
2022-02-04 15:35   ` Jean Louis
2022-02-04 15:50     ` Drew Adams
2022-02-04 16:55       ` Jean Louis
2022-02-04 21:29         ` Drew Adams
2022-02-04 21:46           ` Drew Adams
2022-02-05  0:54             ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-02-05  1:36               ` Drew Adams
2022-02-05  1:56                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-02-05 17:27                   ` Drew Adams
2022-02-06 15:48                     ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-02-06  6:08           ` Jean Louis
2022-02-06  7:02             ` Drew Adams
2022-02-06  8:10               ` Jean Louis

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.