From: Drew Adams via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>, Jean Louis <bugs@gnu.support>
Cc: "74890@debbugs.gnu.org" <74890@debbugs.gnu.org>
Subject: bug#74890: 31.0.50; (thing-at-point 'string) raises error
Date: Mon, 16 Dec 2024 23:39:38 +0000 [thread overview]
Message-ID: <DS7PR10MB523250486B1788A2E533B651F33B2@DS7PR10MB5232.namprd10.prod.outlook.com> (raw)
In-Reply-To: <86seqnpon5.fsf@gnu.org>
> 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.
next prev parent reply other threads:[~2024-12-16 23:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-15 8:27 bug#74890: 31.0.50; (thing-at-point 'string) raises error Jean Louis
[not found] ` <handler.74890.B.17342851868303.ack@debbugs.gnu.org>
2024-12-15 18:12 ` bug#74890: Acknowledgement (31.0.50; (thing-at-point 'string) raises error) Jean Louis
2024-12-15 20:44 ` Stefan Kangas
2024-12-15 18:31 ` bug#74890: 31.0.50; (thing-at-point 'string) raises error Eli Zaretskii
2024-12-15 22:10 ` Jean Louis
2024-12-16 0:49 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-16 6:12 ` Jean Louis
2024-12-16 16:40 ` Eli Zaretskii
2024-12-16 23:39 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-12-17 0:47 ` Stefan Kangas
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DS7PR10MB523250486B1788A2E533B651F33B2@DS7PR10MB5232.namprd10.prod.outlook.com \
--to=bug-gnu-emacs@gnu.org \
--cc=74890@debbugs.gnu.org \
--cc=bugs@gnu.support \
--cc=drew.adams@oracle.com \
--cc=eliz@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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).