Provide the 'frame-height' call with the frame of the window where
the *Completions* buffer is displayed for the case when the minibuffer
window uses a dedicated frame (bug#79635).
When completion-ignore-case is non-nil, if all completions share
a common prefix ignoring case, try-completion has always
returned that. Now, if all completions also share a common
prefix including case, try-completion includes that common
prefix in its return value (bug#79377).
* lisp/minibuffer.el (completion-pcm--merge-completions): Always
use return value from try-completion, which may change case.
* src/minibuf.c (Ftry_completion): Return the common prefix
which changes case.
* test/lisp/minibuffer-tests.el (completion-pcm-bug4219)
(completion-substring-test-5): New tests.
(completion--lazy-insert-strings-on-scroll): Don't move to the last
completion candidate since this is what happens when scrolling without
truncated completions buffer (bug#79506).
* lisp/minibuffer.el (minibuffer-nonselected): Rewrite
doc-string.
(minibuffer--nonselected-overlay): Define it global. Rewrite
doc-string.
(minibuffer--nonselected-check): Rewrite by comparing the active
minibuffer window with the selected window.
(minibuffer--nonselected-setup): Globally add
'minibuffer--nonselected-check' to list of functions called by
'window-state-change-functions'.
(minibuffer--nonselected-exit): Remove
'minibuffer--nonselected-check' from list of functions called by
'window-state-change-functions' when exiting last recursive
minibuffer.
(minibuffer-nonselected-mode): Globally add/remove
'minibuffer--nonselected-setup' to/from list of functions called
by 'minibuffer-setup-hook' and 'minibuffer--nonselected-exit'
to/from list of functions called by 'minibuffer-exit-hook' when
activating/deactivating 'minibuffer-nonselected-mode'. Rewrite
doc-string.
In completion--do-completion, check if completion-try-completion
moved point out of the old completion boundaries. If that
happened, then we did non-trivial completion even if the string
is otherwise unchanged.
For example,
~/src/emacs/trunk/lisp|/progmodes/project.el
hitting TAB moves us to:
~/src/emacs/trunk/lisp/|progmodes/project.el
then hitting TAB again moves us to
~/src/emacs/trunk/lisp/progmodes/|project.el
Both of these completions are successful, but we previously ran
code for completion failure (the t branch of the cond in
completion--do-completion) in the second case. In particular,
we would always run minibuffer-completion-help, ignoring the
specific value of completion-auto-help which controls whether or
not to run minibuffer-completion-help. Now we correctly run
code for successful completion for both cases.
We also always have checked that we're in the same boundaries
before doing completion cycling; that check is now more
accurate (bug#79238).
* lisp/minibuffer.el (completion--in-boundaries-p): Add.
(completion--do-completion): Check completion--in-boundaries-p.
* lisp/simple.el (completion-setup-function):
Add 'completion--lazy-insert-strings-on-scroll'
to buffer-local hook 'window-scroll-functions'.
* lisp/minibuffer.el (completion--lazy-insert-strings-on-scroll):
New function.
(completion--in-region-1): Remove calls to the function
'completion--lazy-insert-strings' that now are handled
by the scroll hook.
Use private names. Use hashed function symbols. Do not restrict the
overlay to the miniwindow, since the minibuffer can be displayed by
other windows, for example by packages using child frames or by
vertico-buffer-mode (bug#79490).
* lisp/minibuffer.el (minibuffer-nonselected-setup): Rename to
minibuffer--nonselected-setup. Use hashed function symbols.
Add docstring.
(minibuffer-nonselected-check): Rename to
minibuffer--nonselected-check. Use hashed function symbols.
Do not restrict overlay to miniwindow.
(minibuffer-nonselected-overlay): Rename to
minibuffer--nonselected-overlay.
(minibuffer-nonselected-mode): Use hashed function symbol for
custom-initialize-delay.
This patch makes 'next-completion' and 'previous-completion' work
in the vertical completions format analogously to how they work in
the default horizontal format (bug#78959). It also fixes wrapping
in the vertical format and confines navigation (including
wrapping) in column-wise movement in the vertical format to the
current line, analogously to how navigation (including wrapping)
in line-wise movement in the horizontal format is confined to the
current column.
* doc/emacs/mini.texi (Completion): Fix several typos and improve
wording is several places.
(Completion Commands): Document navigation of the *Completions*
buffer in the vertical format. Document the difference between
format-sensitive movement and strictly column-wise or line-wise
movement. Document 'minibuffer-complete-and-exit' and update the
documentation of 'minibuffer-completion-auto-choose' and
'minibuffer-choose-completion'. Document the use of a numeric
prefix argument with the navigation commands.
(Completion Options): Rearrange and improve documentation of
'completions-sort', 'completions-format' and
'completion-auto-wrap', updating the latter to document the new
behavior.
* lisp/minibuffer.el (minibuffer-visible-completions-map): Rebind
"<left>" to 'minibuffer-previous-column-completion' and "<right>"
to 'minibuffer-next-column-completion'.
(minibuffer-next-completion): Add check for whether completions
format is vertical to decide whether to call
'next-line-completion' and replace calling 'next-completion' by
'next-column-completion'.
(minibuffer-next-column-completion)
(minibuffer-previous-column-completion): New commands.
* lisp/simple.el (completion-list-mode-map): Rebind "<left>" to
'previous-column-completion' and "<right>" to 'next-column-completion'.
(last-completion): Add handling for vertical completions format.
(completion--move-to-candidate-end): Always move point to the
position immediately after the last character of the completion
candidate. This unifies the behavior, simplifies the
implementation and facilitates implementing the improved
navigation of the *Completions* buffer.
(previous-column-completion, next-column-completion): New
commands, replacing the previous definitions of
'previous-completion' and 'next-completion' to reflect their
column-wise operation. Confine navigation (including wrapping) in
vertical format to the current line.
(previous-line-completion, next-line-completion): Implement
line-wise navigation (including wrapping) through all completions
in vertical format, not just those in the current column as in
horiztonal format. Update doc strings.
(next-completion, previous-completion): Redefine to call
'{next,previous}-line-completion' when completions format is
vertical and '{next,previous}-column-completion' otherwise.
* test/lisp/minibuffer-tests.el
(completions-format-navigation--tests): New function providing a
template to define tests of the navigation and wrapping behavior
with specified numbers of completion candidates.
(completions-format-navigation-test-{2,3,4,5,10,15,16}): New tests.
* lisp/minibuffer.el (minibuffer-nonselected-setup): Use
window-buffer-change-functions in addition to
window-selection-change-functions to detect changes from one recursive
minibuffer to another within the same minibuffer-window.
(minibuffer-nonselected-check): Ensure that the target minibuffer is
current before checking/deleting the overlay (bug#79472).
* lisp/minibuffer.el (minibuffer-nonselected): New face.
(minibuffer-nonselected-overlay): New buffer-local variable.
(minibuffer-nonselected-check, minibuffer-nonselected-setup):
New functions.
(minibuffer-nonselected-mode): New command (bug#49844).
* lisp/minibuffer.el (define-completion-category): New function.
(completion-category-get): New function, implements completion
category property lookup with (multiple) inheritance.
(completion-metadata-get, completion--styles)
(completion--cycle-threshold): Use it.
(completion-category-defaults): Mention it in docstring.
Remove entry for 'project-buffer' category, and instead...
* lisp/progmodes/project.el: ...have 'project-buffer' inherit
from 'buffer'.
* test/lisp/minibuffer-tests.el
(completion-category-inheritance): New test.
* etc/NEWS: Announce support for category inheritance.
Revert "Avoid duplicating strings in pcm--merge-completions",
commit b511c38bba. It broke
existing behavior, now covered by tests adding in this commit.
* lisp/minibuffer.el (completion-pcm--merge-completions):
* test/lisp/minibuffer-tests.el (completion-pcm-test-anydelim):
(completion-pcm-bug4219):
Previously, one could select a completion via M-<up>/M-<down>,
but then RET would not actually select the chosen completion.
With the addition of completion-auto-deselect, this is not
actually necessary: we can reasonably assume that when a
completion is selected, the user wants to use that, since their
last action must have been to select it. So, just choose the
selected completion on RET. This lets us default
minibuffer-completion-auto-choose to nil.
For minibuffers with require-match completion, this can be done
by changing the existing command bound to RET. For minibuffers
with nil require-match completion, RET was previously bound to
exit-minibuffer, and changing exit-minibuffer to have this logic
is risky. We handle that case by adding a new
minibuffer-completion-exit which wraps exit-minibuffer and bind
RET to it.
* lisp/minibuffer.el (minibuffer-insert-completion-if-selected)
(minibuffer-completion-exit, completion--selected-candidate):
Add.
(minibuffer-complete-and-exit): Call
minibuffer-choose-completion. (bug#77253)
(minibuffer-local-completion-map): Bind RET to
minibuffer-completion-exit, overriding exit-minibuffer.
(completion-in-region-mode-map): Bind RET to
minibuffer-choose-completion when there's a selected candidate.
(minibuffer-completion-auto-choose): Default to nil.
(minibuffer-visible-completions--filter)
(minibuffer-visible-completions-map): Delete RET binding, no
longer necessary.
* lisp/simple.el (completion-setup-function): Update completion
help text to show more correct bindings.
* test/lisp/minibuffer-tests.el (completions-header-format-test)
(minibuffer-next-completion): Set
minibuffer-completion-auto-choose=t explicitly.
(with-minibuffer-setup, minibuffer-completion-RET-prefix)
(completion-in-region-next-completion): Add new tests.
* etc/NEWS: Announce.
* etc/NEWS: Mention the change.
* lisp/minibuffer.el (completion-category-defaults):
Add an entry for it.
* lisp/progmodes/project.el (project--buffers-completion-table):
Return category 'project-buffer'.
At various places, instead of just checking that there's any
window displaying a buffer named *Completions*, we should
additionally check that that *Completions* buffer is actually
for the current completion session.
minibuffer--completions-visible does that.
* lisp/comint.el (comint-complete-input-ring)
(comint-dynamic-list-completions): Call
minibuffer--completions-visible.
* lisp/minibuffer.el (minibuffer--completions-visible):
Add. (bug#77253)
(completion--do-completion, completions--post-command-update)
(completions--after-change, minibuffer-hide-completions)
(minibuffer-visible-completions)
(minibuffer-visible-completions--always-bind)
(minibuffer-visible-completions--filter)
(with-minibuffer-completions-window, minibuffer-complete-history)
(minibuffer-complete-defaults): Call
minibuffer--completions-visible.
* lisp/pcomplete.el (pcomplete-show-completions): Call
minibuffer--completions-visible.
* lisp/simple.el (switch-to-completions): Call
minibuffer--completions-visible.
* test/lisp/minibuffer-tests.el (completion-auto-help-test)
(completion-auto-select-test): Call
minibuffer--completions-visible.
Make completion-pcm--merge-completions operate only on the text
matched by the wildcards, instead of also the text in between
the wildcards. This improves performance and simplifies the
code by removing the need for the previous mutable variable
"fixed".
* lisp/minibuffer.el (completion-pcm--merge-completions):
Operate only on text matched by wildcards. (bug#79265)
Properly fix bug#38458, which is fundamentally an issue with
completion-ignore-case, by checking if the completions are
unique ignoring case. When the completions are unique, the
normal code to delete a wildcard naturally causes point to be
moved to the end of the minibuffer, which is the correct
behavior.
Now that the bug is fixed properly, remove a hack which
previously was used to "fix" it, which made point behave
inconsistently if it was in the middle of the minibuffer versus
at the end of the minibuffer.
* lisp/minibuffer.el (completion-pcm--merge-completions):
Respect completion-ignore-case when checking for completion
uniqueness. (bug#79265)
(completion-pcm--string->pattern)
(completion-pcm--optimize-pattern): Allow point at the end of
the pattern.
* test/lisp/minibuffer-tests.el (completion-table-test-quoting)
(completion-test--pcm-bug38458, completion-pcm-test-8): Update
tests for more correct behavior.
Add support for updating the *Completions* buffer as you type,
controlled by a new completion metadata symbol 'eager-update'
and a new defcustom 'completion-eager-update'.
You can configure a completion category to update *Completions*
as you type by setting 'completion-category-overrides'
appropriately; or set 'completion-eager-update' to t to always
update *Completions* as you type.
This is similar to the recently added 'completion-eager-display'.
* lisp/minibuffer.el (completion-eager-update): Add new
defcustom defaulting to 'auto. (Bug#77649)
(completion--eager-update-p, completions--background-update)
(completions--post-command-update): Add.
(completions--after-change): Call
'completions--post-command-update' via 'post-command-hook'.
(minibuffer-completion-help): Check 'completion-eager-update'
and install 'completions--after-change'.
(completion-help-at-point): Call 'completion--eager-update-p'
if ONLY-IF-EAGER is non-nil.
* etc/NEWS: Announce completion-eager-update. Reword the
announcement of 'completion-eager-display' for consistency.
509cbe1c35 "Improve env var handling in read-file-name"
caused 'try-completion' and 'all-completion' operations with
'completion--file-name-table' to no longer update the case of
text which was already present in the input string. That is,
completions would be returned ignoring case, but the completions
would have letter-casing which matched the input string rather
than matching the actual file names.
This was caused by unnecessarily replacing text in the returned
file name completions with text from the input string ORIG,
which in turn was caused by the desire to preserve text from
ORIG even after 'substitute-in-file-name' changed it. Fix this
by detecting when ORIG was not substantially changed by
'substitute-in-file-name'; in that case, the returned file name
completions also don't need substantial changes.
* lisp/minibuffer.el (completion--file-name-table): Use text
from the completions, not the input string. (Bug#78323)
* test/lisp/minibuffer-tests.el (completion-table-test-quoting):
Test with 'completion-ignore-case' as well.
Previously, we assumed (roughly) that substitute-in-file-name
always returns a suffix of the original string. But
substitute-in-file-name on "/ssh:user@host:/~/" returns
"/ssh:user@host:~/", preserving the TRAMP magic prefix. Weaken
the assertion in completion--sifn-boundaries to allow this; the
new assertion is more clear about the property we care about,
anyway.
* lisp/minibuffer.el (completion--sifn-boundaries): Weaken
assertion slightly.
* test/lisp/net/tramp-tests.el (tramp--test-emacs31-p)
(tramp--split-on-boundary)
(tramp-test51-file-name-completion-boundaries): Add.
Fix various bugs, including bug#77718, by rewriting the way file
name completion handles environment variable expansion. Instead
of using completion-table-with-quoting to manipulate the string
being completed on, simply make the completion table itself
understand substitute-in-file-name.
Tests are updated: partial-completion now preserves unexpanded
environment variables. However, partial-completion no longer
works across environment variables containing delimiters; that's
an acceptable sacrifice.
* lisp/minibuffer.el (completion--sifn-boundaries): Add.
(completion--file-name-table): Rewrite to use
substitute-in-file-name explicitly. (bug#77718)
* test/lisp/minibuffer-tests.el (completion-table-test-quoting):
Update.
An explicitly typed * has different semantics from automatically
inserted PCM wildcards, so it should be preserved on try-completion. We
already do this in some cases, but now we do it more.
This is especially significant for filename completion: removing an
explicit * can take us from
~/src/emacs/trunk/*/minibuf
to
~/src/emacs/trunk//minibuf
The explicit double slash is interpreted by the file name completion
table to mean "start completing from the root directory", so deleting
the * here substantially changes semantics.
* lisp/minibuffer.el (completion-pcm--merge-completions): Don't drop
important wildcards. (bug#74420)
* test/lisp/minibuffer-tests.el (completion-pcm-test-7): Add tests.
* lisp/minibuffer.el (completion--replace):
* lisp/emacs-lisp/cl-lib.el (cl--set-buffer-substring):
* lisp/subr.el (replace-string-in-region):
Use `replace-region-contents` instead of insert+delete.
* lisp/help-fns.el (help-fns--signature):
Use `replace-region-contents` instead of `cl--set-buffer-substring`.
* lisp/language/japan-util.el (japanese-replace-region):
Rewrite using `replace-region-contents` and mark obsolete.
(japanese-katakana-region, japanese-hankaku-region):
Use `replace-region-contents` instead.
* lisp/progmodes/flymake-proc.el (flymake-proc--replace-region):
Rewrite using `replace-region-contents` and mark obsolete.
(flymake-proc--check-patch-master-file-buffer):
Use `replace-region-contents` instead.
This fixes a regression introduced in b12a3a03ae, where
repeating a completion command (e.g. TAB in the minibuffer)
would no longer scroll through all available completions.
* lisp/minibuffer.el (completion--in-region-1): Call
'completion--lazy-insert-strings' before scrolling
the completions list.
* lisp/minibuffer.el: Cut lines to fit into 80 columns.
(completion--insert-strings): Simplify `if` to `or`.
(completion--insert-horizontal, completion--insert-one-column):
Fix warning about used var starting with `_`. Avoid `apply-partially`.
From profiling, the main bottleneck in completion over large
completion sets is display-completion-list, when there are many
available candidates. For example, in my large monorepo, when
completing over the 589196 files or the 73897 branches, even
with the candidates narrowed down by typing some prefix to
complete, TAB (when it shows *Completions*) or ? is slow, mostly
in display-completion-list.
However, rendering all the completion candidates is unnecessary if
the *Completions* window is never scrolled to see those candiates. By
eagerly inserting only some candidates and lazily highlighting and
inserting the remaining candidates only when necessary, performance is
much improved.
* lisp/minibuffer.el (completion--insert-strings): Insert
completions lazily. (bug#74561)
(completions--lazy-insert-button): Add.
(completion--insert-horizontal, completion--insert-one-column):
Throw a continuation when enough lines of completions are
inserted.
(completion--insert-vertical): Add ignored lines argument.
(minibuffer-completion-help): Set completion-lazy-hilit.
(with-minibuffer-completions-window): Call
completion--lazy-insert-strings.
(with-minibuffer-completions-window):
* lisp/simple.el (completion-setup-function): Preserve
buffer-locals required for lazy completion insertion.
(switch-to-completions): Call completion--lazy-insert-strings.
* etc/NEWS: Announce.
* lisp/help-fns.el (help--recommend-setopt): New function to
automatically document the need to use `setopt` to set the values of
any defcustoms with a `:set` property.
(help-fns-describe-variable-functions): Add above new function to
hook.
* lisp/follow.el (follow-mode-prefix-key):
* lisp/minibuffer.el (minibuffer-regexp-prompts):
* lisp/register.el (register-use-preview):
* lisp/savehist.el (savehist-autosave-interval):
* lisp/saveplace.el (save-place-autosave-interval):
* lisp/tab-bar.el (tab-bar-define-keys):
* lisp/textmodes/text-mode.el (text-mode-ispell-word-completion):
Delete now redundant text from docstrings.
* lisp/minibuffer.el (completion-category-defaults): Move the
'calendar-month' default value to the metadata in calendar-read-date.
* lisp/calendar/calendar.el (calendar-read-date): Add
display-sort-function moved from completion-category-defaults.