* Confusing doc string of list-or-string at point
@ 2021-09-23 17:06 Eli Zaretskii
2021-09-23 17:11 ` Juri Linkov
0 siblings, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2021-09-23 17:06 UTC (permalink / raw)
To: Juri Linkov; +Cc: emacs-devel
The doc string says:
Like `thing-at-point-bounds-of-list-at-point', but also
prefer to find of any enclosing string."
"Prefer to find of" is clearly a typo of sorts, but I don't have a
clear idea what you wanted to say there. The same problem is with the
NEWS entry.
Thanks.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Confusing doc string of list-or-string at point
2021-09-23 17:06 Confusing doc string of list-or-string at point Eli Zaretskii
@ 2021-09-23 17:11 ` Juri Linkov
2021-09-23 17:33 ` Eli Zaretskii
0 siblings, 1 reply; 16+ messages in thread
From: Juri Linkov @ 2021-09-23 17:11 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
> The doc string says:
>
> Like `thing-at-point-bounds-of-list-at-point', but also
> prefer to find of any enclosing string."
>
> "Prefer to find of" is clearly a typo of sorts, but I don't have a
> clear idea what you wanted to say there. The same problem is with the
> NEWS entry.
I tried to copy the meaning of the arg NO-SYNTAX-CROSSING of 'up-list'
that uses such words in the docstring:
If NO-SYNTAX-CROSSING is non-nil (as it is interactively), prefer
to break out of any enclosing string instead of moving to the
end of a list broken across multiple strings.
The idea is that when this arg is non-nil, and point is inside a string,
then 'up-list' prefers to move out of string, instead of moving out
of parentheses.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Confusing doc string of list-or-string at point
2021-09-23 17:11 ` Juri Linkov
@ 2021-09-23 17:33 ` Eli Zaretskii
2021-09-23 17:55 ` Juri Linkov
2021-09-23 17:56 ` Eli Zaretskii
0 siblings, 2 replies; 16+ messages in thread
From: Eli Zaretskii @ 2021-09-23 17:33 UTC (permalink / raw)
To: Juri Linkov; +Cc: emacs-devel
> From: Juri Linkov <juri@linkov.net>
> Cc: emacs-devel@gnu.org
> Date: Thu, 23 Sep 2021 20:11:45 +0300
>
> > Like `thing-at-point-bounds-of-list-at-point', but also
> > prefer to find of any enclosing string."
> >
> > "Prefer to find of" is clearly a typo of sorts, but I don't have a
> > clear idea what you wanted to say there. The same problem is with the
> > NEWS entry.
>
> I tried to copy the meaning of the arg NO-SYNTAX-CROSSING of 'up-list'
> that uses such words in the docstring:
>
> If NO-SYNTAX-CROSSING is non-nil (as it is interactively), prefer
> to break out of any enclosing string instead of moving to the
> end of a list broken across multiple strings.
>
> The idea is that when this arg is non-nil, and point is inside a string,
> then 'up-list' prefers to move out of string, instead of moving out
> of parentheses.
I understand the documentation of NO-SYNTAX-CROSSING, which talks
about "breaking out of string". But I still don't understand what you
meant by "prefer to find of string".
If the list is enclosed in a string, does it mean this will return the
string, not the list? IOW, what will it return in these two cases:
(foo "bar baz" quux)
"foo (bar baz) guux"
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Confusing doc string of list-or-string at point
2021-09-23 17:33 ` Eli Zaretskii
@ 2021-09-23 17:55 ` Juri Linkov
2021-09-23 17:56 ` Eli Zaretskii
1 sibling, 0 replies; 16+ messages in thread
From: Juri Linkov @ 2021-09-23 17:55 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
> I understand the documentation of NO-SYNTAX-CROSSING, which talks
> about "breaking out of string". But I still don't understand what you
> meant by "prefer to find of string".
I meant that if point is inside a string that is inside a list
then it will prefer to find boundaries of the string, not the list.
> If the list is enclosed in a string, does it mean this will return the
> string, not the list?
For a string enclosed in a list it returns the string. For a list
enclosed in a string it returns the list.
> IOW, what will it return in these two cases:
>
> (foo "bar baz" quux)
> "foo (bar baz) guux"
You can type 'C-M-u' (backward-up-list) on different positions
(in a prog mode where strings are highlighted) to see its effect.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Confusing doc string of list-or-string at point
2021-09-23 17:33 ` Eli Zaretskii
2021-09-23 17:55 ` Juri Linkov
@ 2021-09-23 17:56 ` Eli Zaretskii
2021-09-23 17:59 ` Juri Linkov
1 sibling, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2021-09-23 17:56 UTC (permalink / raw)
To: juri; +Cc: emacs-devel
> Date: Thu, 23 Sep 2021 20:33:28 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: emacs-devel@gnu.org
>
> If the list is enclosed in a string, does it mean this will return the
> string, not the list? IOW, what will it return in these two cases:
>
> (foo "bar baz" quux)
> "foo (bar baz) guux"
It looks like it prefers the innermost thing, whether it's a list or a
string. Is that correct? If so, why/when/where is this kind of
"thing" useful in practice?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Confusing doc string of list-or-string at point
2021-09-23 17:56 ` Eli Zaretskii
@ 2021-09-23 17:59 ` Juri Linkov
2021-09-23 18:43 ` Eli Zaretskii
0 siblings, 1 reply; 16+ messages in thread
From: Juri Linkov @ 2021-09-23 17:59 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
>> If the list is enclosed in a string, does it mean this will return the
>> string, not the list? IOW, what will it return in these two cases:
>>
>> (foo "bar baz" quux)
>> "foo (bar baz) guux"
>
> It looks like it prefers the innermost thing, whether it's a list or a
> string. Is that correct? If so, why/when/where is this kind of
> "thing" useful in practice?
It's useful to just click inside either a list or string,
and choose "Select>List" or "Select>String" from the context menu,
and it will select the right thing, either a list when clicked inside list,
or string when clicked inside a string.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Confusing doc string of list-or-string at point
2021-09-23 17:59 ` Juri Linkov
@ 2021-09-23 18:43 ` Eli Zaretskii
2021-09-23 18:58 ` Eli Zaretskii
2021-09-23 19:44 ` Juri Linkov
0 siblings, 2 replies; 16+ messages in thread
From: Eli Zaretskii @ 2021-09-23 18:43 UTC (permalink / raw)
To: Juri Linkov; +Cc: emacs-devel
> From: Juri Linkov <juri@linkov.net>
> Cc: emacs-devel@gnu.org
> Date: Thu, 23 Sep 2021 20:59:18 +0300
>
> > It looks like it prefers the innermost thing, whether it's a list or a
> > string. Is that correct? If so, why/when/where is this kind of
> > "thing" useful in practice?
>
> It's useful to just click inside either a list or string,
> and choose "Select>List" or "Select>String" from the context menu,
> and it will select the right thing, either a list when clicked inside list,
> or string when clicked inside a string.
But the same can happen with a slit/string enclosed within a defun, or
a word enclosed withing a string or a list. Do we also need
defun-or-string or list-or-string-or-word or any other combinations?
Is this really the correct and useful analysis of this kind of
problems?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Confusing doc string of list-or-string at point
2021-09-23 18:43 ` Eli Zaretskii
@ 2021-09-23 18:58 ` Eli Zaretskii
2021-09-23 19:44 ` Juri Linkov
1 sibling, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2021-09-23 18:58 UTC (permalink / raw)
To: juri; +Cc: emacs-devel
> Date: Thu, 23 Sep 2021 21:43:29 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: emacs-devel@gnu.org
>
> But the same can happen with a slit/string enclosed within a defun, or
^^^^
Should be "list", sorry.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Confusing doc string of list-or-string at point
2021-09-23 18:43 ` Eli Zaretskii
2021-09-23 18:58 ` Eli Zaretskii
@ 2021-09-23 19:44 ` Juri Linkov
2021-09-24 6:32 ` Juri Linkov
1 sibling, 1 reply; 16+ messages in thread
From: Juri Linkov @ 2021-09-23 19:44 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
>> > It looks like it prefers the innermost thing, whether it's a list or a
>> > string. Is that correct? If so, why/when/where is this kind of
>> > "thing" useful in practice?
>>
>> It's useful to just click inside either a list or string,
>> and choose "Select>List" or "Select>String" from the context menu,
>> and it will select the right thing, either a list when clicked inside list,
>> or string when clicked inside a string.
>
> But the same can happen with a list/string enclosed within a defun, or
> a word enclosed withing a string or a list. Do we also need
> defun-or-string or list-or-string-or-word or any other combinations?
An alternative would be to add a new thing-at-point target 'string'
instead of 'list-or-string'. But since there is no such function as
'up-string' that would work like 'up-list' but only to go out of the
enclosing string and not out of a list, so what remains to do is
to use 'up-list' with the non-nil arg NO-SYNTAX-CROSSING, therefore
the new target 'list-or-string'.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Confusing doc string of list-or-string at point
2021-09-23 19:44 ` Juri Linkov
@ 2021-09-24 6:32 ` Juri Linkov
2021-09-24 7:14 ` Eli Zaretskii
` (2 more replies)
0 siblings, 3 replies; 16+ messages in thread
From: Juri Linkov @ 2021-09-24 6:32 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
>> But the same can happen with a list/string enclosed within a defun, or
>> a word enclosed withing a string or a list. Do we also need
>> defun-or-string or list-or-string-or-word or any other combinations?
>
> An alternative would be to add a new thing-at-point target 'string'
> instead of 'list-or-string'. But since there is no such function as
> 'up-string' that would work like 'up-list' but only to go out of the
> enclosing string and not out of a list, so what remains to do is
> to use 'up-list' with the non-nil arg NO-SYNTAX-CROSSING, therefore
> the new target 'list-or-string'.
So now I reverted 'list-or-string', and added 'string' instead.
BTW, it seems there is a bug in thing-at-point--end-of-sexp,
but I'm not sure if this is a correct fix:
diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el
index efe33982c3..3d2ea9dedf 100644
--- a/lisp/thingatpt.el
+++ b/lisp/thingatpt.el
@@ -241,7 +261,7 @@ in-string-p
(defun thing-at-point--end-of-sexp ()
"Move point to the end of the current sexp."
- (let ((char-syntax (syntax-after (point))))
+ (let ((char-syntax (char-syntax (char-after))))
(if (or (eq char-syntax ?\))
(and (eq char-syntax ?\") (nth 3 (syntax-ppss))))
(forward-char 1)
--
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: Confusing doc string of list-or-string at point
2021-09-24 6:32 ` Juri Linkov
@ 2021-09-24 7:14 ` Eli Zaretskii
2021-09-24 17:14 ` [External] : " Drew Adams
2021-09-24 17:41 ` Stefan Monnier
2 siblings, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2021-09-24 7:14 UTC (permalink / raw)
To: Juri Linkov; +Cc: emacs-devel
> From: Juri Linkov <juri@linkov.net>
> Cc: emacs-devel@gnu.org
> Date: Fri, 24 Sep 2021 09:32:18 +0300
>
> >> But the same can happen with a list/string enclosed within a defun, or
> >> a word enclosed withing a string or a list. Do we also need
> >> defun-or-string or list-or-string-or-word or any other combinations?
> >
> > An alternative would be to add a new thing-at-point target 'string'
> > instead of 'list-or-string'. But since there is no such function as
> > 'up-string' that would work like 'up-list' but only to go out of the
> > enclosing string and not out of a list, so what remains to do is
> > to use 'up-list' with the non-nil arg NO-SYNTAX-CROSSING, therefore
> > the new target 'list-or-string'.
>
> So now I reverted 'list-or-string', and added 'string' instead.
Thanks, I think this is a cleaner solution.
^ permalink raw reply [flat|nested] 16+ messages in thread
* RE: [External] : Re: Confusing doc string of list-or-string at point
2021-09-24 6:32 ` Juri Linkov
2021-09-24 7:14 ` Eli Zaretskii
@ 2021-09-24 17:14 ` Drew Adams
2021-09-24 17:59 ` Stefan Kangas
2021-09-24 17:41 ` Stefan Monnier
2 siblings, 1 reply; 16+ messages in thread
From: Drew Adams @ 2021-09-24 17:14 UTC (permalink / raw)
To: Juri Linkov, Eli Zaretskii; +Cc: emacs-devel@gnu.org
> BTW, it seems there is a bug in thing-at-point--end-of-sexp,
> but I'm not sure if this is a correct fix:
>
> diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el
> index efe33982c3..3d2ea9dedf 100644
> --- a/lisp/thingatpt.el
> +++ b/lisp/thingatpt.el
> @@ -241,7 +261,7 @@ in-string-p
>
> (defun thing-at-point--end-of-sexp ()
> "Move point to the end of the current sexp."
> - (let ((char-syntax (syntax-after (point))))
> + (let ((char-syntax (char-syntax (char-after))))
> (if (or (eq char-syntax ?\))
> (and (eq char-syntax ?\") (nth 3 (syntax-ppss))))
> (forward-char 1)
That looks right to me.
BTW2:
Why is function `in-string-p' even defined?
It doesn't seem to be used anywhere (but I'm
using Emacs 26.3, so ignore if it's used now).
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Confusing doc string of list-or-string at point
2021-09-24 6:32 ` Juri Linkov
2021-09-24 7:14 ` Eli Zaretskii
2021-09-24 17:14 ` [External] : " Drew Adams
@ 2021-09-24 17:41 ` Stefan Monnier
2021-09-25 19:03 ` Juri Linkov
2 siblings, 1 reply; 16+ messages in thread
From: Stefan Monnier @ 2021-09-24 17:41 UTC (permalink / raw)
To: Juri Linkov; +Cc: Eli Zaretskii, emacs-devel
> (defun thing-at-point--end-of-sexp ()
> "Move point to the end of the current sexp."
> - (let ((char-syntax (syntax-after (point))))
> + (let ((char-syntax (char-syntax (char-after))))
Splitting the work between `char-after` and `char-syntax` means that we
can't obey any `syntax-table` text properties placed on that char.
So I think the above change would be a regression in this sense (tho
I understand it fixes or circumvents a bug elsewhere).
Stefan
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Confusing doc string of list-or-string at point
2021-09-24 17:41 ` Stefan Monnier
@ 2021-09-25 19:03 ` Juri Linkov
2021-09-27 16:56 ` Stefan Monnier
0 siblings, 1 reply; 16+ messages in thread
From: Juri Linkov @ 2021-09-25 19:03 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Eli Zaretskii, emacs-devel
>> (defun thing-at-point--end-of-sexp ()
>> "Move point to the end of the current sexp."
>> - (let ((char-syntax (syntax-after (point))))
>> + (let ((char-syntax (char-syntax (char-after))))
>
> Splitting the work between `char-after` and `char-syntax` means that we
> can't obey any `syntax-table` text properties placed on that char.
> So I think the above change would be a regression in this sense (tho
> I understand it fixes or circumvents a bug elsewhere).
No bugs prompted this patch, just noticed the difference between
this function and its counterpart thing-at-point--beginning-of-sexp
that uses `(char-syntax (char-before))`.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Confusing doc string of list-or-string at point
2021-09-25 19:03 ` Juri Linkov
@ 2021-09-27 16:56 ` Stefan Monnier
0 siblings, 0 replies; 16+ messages in thread
From: Stefan Monnier @ 2021-09-27 16:56 UTC (permalink / raw)
To: Juri Linkov; +Cc: Eli Zaretskii, emacs-devel
>> Splitting the work between `char-after` and `char-syntax` means that we
>> can't obey any `syntax-table` text properties placed on that char.
>> So I think the above change would be a regression in this sense (tho
>> I understand it fixes or circumvents a bug elsewhere).
>
> No bugs prompted this patch, just noticed the difference between
> this function and its counterpart thing-at-point--beginning-of-sexp
> that uses `(char-syntax (char-before))`.
My point was just that `syntax-after` is almost always the better choice
over (char-syntax (char-after)) because it has access to more
information, so the better fix to unify the two would be to use
`syntax-after` in both cases ;-)
Stefan
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2021-09-27 16:56 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-23 17:06 Confusing doc string of list-or-string at point Eli Zaretskii
2021-09-23 17:11 ` Juri Linkov
2021-09-23 17:33 ` Eli Zaretskii
2021-09-23 17:55 ` Juri Linkov
2021-09-23 17:56 ` Eli Zaretskii
2021-09-23 17:59 ` Juri Linkov
2021-09-23 18:43 ` Eli Zaretskii
2021-09-23 18:58 ` Eli Zaretskii
2021-09-23 19:44 ` Juri Linkov
2021-09-24 6:32 ` Juri Linkov
2021-09-24 7:14 ` Eli Zaretskii
2021-09-24 17:14 ` [External] : " Drew Adams
2021-09-24 17:59 ` Stefan Kangas
2021-09-24 17:41 ` Stefan Monnier
2021-09-25 19:03 ` Juri Linkov
2021-09-27 16:56 ` Stefan Monnier
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).