GNU bug report logs -
#72425
29.2.50; substring (and other PCM styles) fails with candidates containing newlines
Previous Next
Reported by: Spencer Baugh <sbaugh <at> janestreet.com>
Date: Fri, 2 Aug 2024 16:16:02 UTC
Severity: normal
Found in version 29.2.50
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 72425 in the body.
You can then email your comments to 72425 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#72425
; Package
emacs
.
(Fri, 02 Aug 2024 16:16:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Spencer Baugh <sbaugh <at> janestreet.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 02 Aug 2024 16:16:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
1. emacs -Q
2. (let ((completion-styles '(substring)))
(completing-read ":" '("foo1bar" "foo2bar") nil nil "bar"))
3. Press TAB
4. foo1bar and foo2bar are suggested as completion candidates, because
they contain "bar" as a substring.
5. (let ((completion-styles '(substring)))
(completing-read ":" '("foo1\nbar" "foo2\nbar") nil nil "bar"))
6. Press TAB
7. Observe "[No match]" is printed.
This is due to a regex using "." when it should use a pattern which
actually matches anything, such as "[^z-a]". A patch to fix will
follow.
In GNU Emacs 29.2.50 (build 9, x86_64-pc-linux-gnu, X toolkit, cairo
version 1.15.12, Xaw scroll bars) of 2024-07-30 built on
igm-qws-u22796a
Repository revision: cd9604db959c439c5695cf79f6533b5cbd340851
Repository branch: emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Rocky Linux 8.10 (Green Obsidian)
Configured using:
'configure --with-x-toolkit=lucid --without-gpm --without-gconf
--without-selinux --without-imagemagick --with-modules --with-gif=no
--with-cairo --with-rsvg --without-compress-install
--with-native-compilation=aot --with-tree-sitter
PKG_CONFIG_PATH=/usr/local/home/garnish/libtree-sitter/0.22.6-1/lib/pkgconfig/'
Configured features:
CAIRO DBUS FREETYPE GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG
SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER X11
XDBE XIM XINPUT2 XPM LUCID ZLIB
Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
Major mode: ELisp/l
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#72425
; Package
emacs
.
(Fri, 02 Aug 2024 16:18:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 72425 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Patch to fix:
[0001-Fix-partial-completion-for-completion-candidates-con.patch (text/x-patch, inline)]
From dfac112fa23d503b671fa5f9901411a4556bf054 Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh <at> janestreet.com>
Date: Fri, 2 Aug 2024 12:15:58 -0400
Subject: [PATCH] Fix partial-completion for completion candidates containing
newlines
partial-completion tries to match a pattern containing wildcards (such
as `any' or `prefix') against completion candidates. Wildcards are
supposed to match any sequence of characters, but
completion-pcm--pattern->regex transformed the wildcards into ".*",
which won't match sequences containing newlines. Fix this to properly
match anything by using "[^z-a]*" instead. (That's (rx (* anything)))
* lisp/minibuffer.el (completion-pcm--pattern->regex): Fix
regex. (bug#72425)
---
lisp/minibuffer.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 5860c4238c2..cefd4247370 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -3896,7 +3896,7 @@ completion-pcm--pattern->regex
(t
(let ((re (if (eq x 'any-delim)
(concat completion-pcm--delim-wild-regex "*?")
- ".*?")))
+ "[^z-a]*?")))
(if (if (consp group) (memq x group) group)
(concat "\\(" re "\\)")
re)))))
--
2.39.3
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#72425
; Package
emacs
.
(Fri, 02 Aug 2024 16:26:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 72425 <at> debbugs.gnu.org (full text, mbox):
> This is due to a regex using "." when it should use a pattern which
> actually matches anything, such as "[^z-a]". A patch to fix will
> follow.
"[^z-a]" doesn't match any char.
"\\(.\\|[\n]\\)" matches any char.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#72425
; Package
emacs
.
(Fri, 02 Aug 2024 19:33:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 72425 <at> debbugs.gnu.org (full text, mbox):
Drew Adams <drew.adams <at> oracle.com> writes:
>> This is due to a regex using "." when it should use a pattern which
>> actually matches anything, such as "[^z-a]". A patch to fix will
>> follow.
>
> "[^z-a]" doesn't match any char.
>
> "\\(.\\|[\n]\\)" matches any char.
(rx anychar) expands to [^z-a], I'm just following that. File a
different bug if you think rx is wrong, and if that gets changed, I'll
change this patch as well.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#72425
; Package
emacs
.
(Fri, 02 Aug 2024 21:23:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 72425 <at> debbugs.gnu.org (full text, mbox):
> >> This is due to a regex using "." when it should use a pattern which
> >> actually matches anything, such as "[^z-a]". A patch to fix will
> >> follow.
> >
> > "[^z-a]" doesn't match any char.
> >
> > "\\(.\\|[\n]\\)" matches any char.
>
> (rx anychar) expands to [^z-a], I'm just following that. File a
> different bug if you think rx is wrong, and if that gets changed, I'll
> change this patch as well.
I guess [^z-a] does match any char.
Looks odd, but makes sense no char is in that range,
so every char is not in that range.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#72425
; Package
emacs
.
(Wed, 14 Aug 2024 00:53:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 72425 <at> debbugs.gnu.org (full text, mbox):
> Patch to fix:
>
> From dfac112fa23d503b671fa5f9901411a4556bf054 Mon Sep 17 00:00:00 2001
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Date: Fri, 2 Aug 2024 12:15:58 -0400
> Subject: [PATCH] Fix partial-completion for completion candidates containing
> newlines
>
> partial-completion tries to match a pattern containing wildcards (such
> as `any' or `prefix') against completion candidates. Wildcards are
> supposed to match any sequence of characters, but
> completion-pcm--pattern->regex transformed the wildcards into ".*",
> which won't match sequences containing newlines. Fix this to properly
> match anything by using "[^z-a]*" instead. (That's (rx (* anything)))
Looks fine to me. I find [^z-a] a bit too magical, so maybe an `rx`
pattern would be more clear.
My guess is that completion of thingies with newlines is probably going
to bump into other problems. 🙂
Stefan
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Thu, 15 Aug 2024 07:45:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Spencer Baugh <sbaugh <at> janestreet.com>
:
bug acknowledged by developer.
(Thu, 15 Aug 2024 07:45:02 GMT)
Full text and
rfc822 format available.
Message #25 received at 72425-done <at> debbugs.gnu.org (full text, mbox):
> Cc: 72425 <at> debbugs.gnu.org, Dmitry Gutov <dmitry <at> gutov.dev>
> Date: Tue, 13 Aug 2024 20:51:28 -0400
> From: Stefan Monnier via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>
> > Patch to fix:
> >
> > From dfac112fa23d503b671fa5f9901411a4556bf054 Mon Sep 17 00:00:00 2001
> > From: Spencer Baugh <sbaugh <at> janestreet.com>
> > Date: Fri, 2 Aug 2024 12:15:58 -0400
> > Subject: [PATCH] Fix partial-completion for completion candidates containing
> > newlines
> >
> > partial-completion tries to match a pattern containing wildcards (such
> > as `any' or `prefix') against completion candidates. Wildcards are
> > supposed to match any sequence of characters, but
> > completion-pcm--pattern->regex transformed the wildcards into ".*",
> > which won't match sequences containing newlines. Fix this to properly
> > match anything by using "[^z-a]*" instead. (That's (rx (* anything)))
>
> Looks fine to me. I find [^z-a] a bit too magical, so maybe an `rx`
> pattern would be more clear.
Thanks, installed on master, and closing the bug.
> My guess is that completion of thingies with newlines is probably going
> to bump into other problems. 🙂
Exciting new bugs!
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 12 Sep 2024 11:24:10 GMT)
Full text and
rfc822 format available.
This bug report was last modified 337 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.