all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#65137: 29.1; completion-substring-try-completion doesn't return the longest common substring
@ 2023-08-07 23:24 Spencer Baugh
  2023-08-07 23:50 ` Spencer Baugh
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Spencer Baugh @ 2023-08-07 23:24 UTC (permalink / raw)
  To: 65137


The substring completion style differs from the "basic" style by
performing completion at the start of the input string.  So for example,
both of these are valid completions for "bar":

(completion-substring-all-completions "bar" '("foobar" "foobarbaz") #'identity (length "bar"))
-> ("foobarbaz" "foobar" . 0)

However, the substring completion style's try-completion implementation
does not reflect this.  Since "foobar" is a prefix of all the valid
completions, it should be returned by try-completion.  But it is not,
regardless of the location of point:

(completion-substring-try-completion "bar" '("foobar" "foobarbaz") #'identity 0)
-> ("bar" . 3)

(completion-substring-try-completion "bar" '("foobar" "foobarbaz") #'identity (length "bar"))
-> ("bar" . 3)

This breaks completion when one completion candidate is a prefix of
other completion candidates.  The recourse is moving point to the start
of the input, so that the "basic" completion style takes over, which
will correctly insert the common prefix:

(completion-basic-try-completion "bar" '("foobar" "foobarbaz") #'identity 0)
-> ("foobar" . 6)

However, even this does not work in the project-file and xref-location
completion categories, for which the "basic" style is not included in
completion-category-defaults.  For such completion categories, there's
simply no way to use completion to insert a common prefix.  This is bad,
because a filename or identifier might easily be a prefix of another
filename or identifier.

The solution is completion-substring-try-completion to be fixed to
insert these common prefixes.  I'll try and fix this, although the code
is a bit intimidating.



In GNU Emacs 29.1 (build 3, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.15.12, Xaw scroll bars) of 2023-07-29 built on

Repository revision: cf24c7ac7608f41078fd2761c856892d5853b676
Repository branch: my-emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Rocky Linux 8.8 (Green Obsidian)

Configured using:
 'configure --config-cache --with-x-toolkit=lucid
 --with-gif=ifavailable'

Configured features:
CAIRO DBUS FREETYPE GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG
SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS 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

Memory information:
((conses 16 1210667 128287)
 (symbols 48 75558 3)
 (strings 32 305623 26170)
 (string-bytes 1 9620792)
 (vectors 16 125723)
 (vector-slots 8 2816397 195041)
 (floats 8 762 279)
 (intervals 56 32710 336)
 (buffers 976 120))





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

end of thread, other threads:[~2023-09-06 11:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-07 23:24 bug#65137: 29.1; completion-substring-try-completion doesn't return the longest common substring Spencer Baugh
2023-08-07 23:50 ` Spencer Baugh
2023-08-08  0:41   ` Spencer Baugh
2023-08-08 11:04 ` Eli Zaretskii
2023-08-08 12:40   ` sbaugh
2023-08-30  1:31     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-05 19:51       ` Spencer Baugh
2023-09-05 21:26         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-06 11:00         ` Eli Zaretskii
2023-08-25  0:40 ` Dmitry Gutov
2023-08-25  2:30   ` Drew Adams
2023-08-29 15:45   ` Spencer Baugh
2023-08-29 23:25     ` Dmitry Gutov

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.