GNU bug report logs -
#74890
31.0.50; (thing-at-point 'string) raises error
Previous Next
Reported by: Jean Louis <bugs <at> gnu.support>
Date: Sun, 15 Dec 2024 17:54:02 UTC
Severity: normal
Found in version 31.0.50
Done: Stefan Kangas <stefankangas <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #31 received at 74890 <at> debbugs.gnu.org (full text, mbox):
> Until there's a recipe to reproduce this in "emacs -Q", I maintain
> that this is not an Emacs bug, and should be closed. Which I will do
> soon, unless a recipe is posted.
Please feel free to close this bug.
I thought that this return-nil-no-error behavior
was new in Emacs 30. But I found that it was
introduced in 28.1. All Emacs releases 20-27
return nil in the reported scenario (like Emacs
30+ will).
I've changed my mind: I think that's the right
behavior. I assume that the Emacs 28-29 behavior
wasn't introduced intentionally but was an
unintended regression - fixed in Emacs 30.
[Note that the behavior is to return nil instead
of returning the string that's just before point.
That's the correct behavior, IMO, and it was the
main point I was making earlier: Don't return a
THING that's _before_ point and not _at_ point.
At least for _string_ THINGs, vanilla Emacs is
doing the right thing.]
Jean: I've now adapted my code (thingatpt+.el)
to use the Emacs 30 definition of
`thing-at-point-bounds-of-string-at-point'.
Please download the latest thingatpt+.el.
and let me know if you see any problems
with the fix. Thx.
___
However, since we're talking now about
`thing-at-point-bounds-of-string-at-point':
1. I don't see why it should ever return a non-string
sexp. E.g., the doc string includes this:
"Prefer the enclosing string, with fallback on sexp at point."
There's no vanilla code that even calls this function,
so that return-a-non-string must have been something
for which a use case was only imagined, and not for
any existing use (?).
(It's of course used by `bound-of-thing-at-point'
when its arg is the symbol `string'. But grepping
for its name and for "(thing-at-point 'string)"
finds no hits.)
I'm not even sure what kind of non-string sexp this is
meant for. I tried lists, symbols, and numbers - just
nil was returned, always.
What's the use case for returning a non-string sexp?
IOW, why do we cater to that case, when no string
syntax is involved?
It's the "else" clause of the `if' that I question:
why include it?
;; At the beginning of the string
(if (let ((ca (char-after)))
(and ca (eq (char-syntax ca) ?\")))
(let ((bound (bounds-of-thing-at-point 'sexp)))
(and bound
(<= (car bound) (point)) (< (point) (cdr bound))
bound)))
2. (nit) I don't think it makes sense for the two
functions `thing-at-point-bounds-of-string-at-point'
and `thing-at-point-bounds-of-list-at-point' (and no
other functions) to have this in their doc string:
"[Internal function used by `bounds-of-thing-at-point'.]"
Either all such `thing-at-point-bounds-of-*-at-point'
functions should have it or none should. I think
none should, because it's misleading. These _aren't_
internal functions.
No more so than `yank' is an internal function of
`delete-selection'. They're simply functions `put'
on a THING name such as `string', for use by
`bounds-of-thing-at-point'. And they can be used
by any code that wants the bounds of a string, list,
etc. directly, and doesn't necessarily want the text
that's bounded.
This bug report was last modified 213 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.