From 79fe6d2d6fcff68d682872810e5b4516c58172f9 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Fri, 2 Feb 2024 19:03:21 +0100 Subject: [PATCH] New command 'minibuffer-toggle-completion-ignore-case' * lisp/minibuffer.el (completion-all-sorted-completions): New command. (minibuffer-local-completion-map): Bind it to 'C-A'. * doc/emacs/mini.texi (Completion Commands): * doc/lispref/minibuf.texi (Completion Commands): Document it. * etc/NEWS: Announce it. --- doc/emacs/mini.texi | 11 +++++++++++ doc/lispref/minibuf.texi | 9 +++++++++ etc/NEWS | 7 ++++++- lisp/minibuffer.el | 8 ++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi index 9c13bc3a557..89f563ac17a 100644 --- a/doc/emacs/mini.texi +++ b/doc/emacs/mini.texi @@ -365,6 +365,9 @@ Cycle minibuffer input among possible completion candidates Restore the minibuffer input that Emacs used to compute the current set of completion candidates (@code{minibuffer-restore-completion-input}). +@item C-A +Toggle completion case-sensitivity for the current minibuffer +(@code{minibuffer-toggle-completion-ignore-case}). @item C-x C-v Change the order of the list of possible completions (@code{minibuffer-sort-completions}). @@ -443,6 +446,14 @@ For example, if you type @kbd{M-x bar} and start cycling with the minibuffer input to @samp{bar}, change it to @samp{baz} and complete again. +@kindex C-A @r{(completion)} +@kindex C-S-a @r{(completion)} +@findex minibuffer-toggle-completion-ignore-case + @kbd{C-A} (@code{minibuffer-toggle-completion-ignore-case}) toggles +completion case-sensitivity for the current minibuffer. If completion +is currently case-sensitive, after typing @kbd{C-A} it becomes +case-insensitive, and vice versa. + @anchor{Sort Completions} @cindex sort completions @cindex completions sort order diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index eff81be37cf..86fe44b90dc 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi @@ -1342,6 +1342,12 @@ This function restores the last input that a completion command, such as @code{minibuffer-complete}, expanded in the current minibuffer. @end deffn +@deffn Command minibuffer-toggle-completion-ignore-case +This function toggles the completion case-sensitivity for the current +minibuffer. This works by setting the buffer-local value of +@code{completion-ignore-case}. @xref{Basic Completion}. +@end deffn + @deffn Command minibuffer-complete-and-exit This function completes the minibuffer contents, and exits if confirmation is not required, i.e., if @@ -1468,6 +1474,9 @@ keymap makes the following bindings: @item C-l @code{minibuffer-restore-completion-input} +@item C-A +@code{minibuffer-toggle-completion-ignore-case} + @item C-x C-v @code{minibuffer-sort-completions} diff --git a/etc/NEWS b/etc/NEWS index 6d280aa2fde..b2cd80b1505 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -821,10 +821,15 @@ of 'completion-cycle-threshold' and the number of completion candidates. +++ -*** New command 'minibuffer-restore-completion-input. +*** New command 'minibuffer-restore-completion-input'. This command, bound to 'C-l' in the minibuffer, restores the (partial) input that you last used for completion in the current minibuffer. ++++ +*** New command 'minibuffer-toggle-completion-ignore-case'. +This command, bound to 'C-A' in the minibuffer, toggles completion +case-sensitivity for the current minibuffer. + *** New minor mode 'completions-auto-update-mode'. This global minor mode automatically updates the *Completions* buffer as you type in the minibuffer. diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 34d46c65b43..b33c3ece11e 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1928,6 +1928,13 @@ include as `display-sort-function' in completion metadata." (completion--cache-all-sorted-completions start end (nconc all base-size)))))) +(defun minibuffer-toggle-completion-ignore-case () + "Toggle completion case-sensitively for the current minibuffer." + (interactive "" minibuffer-mode) + (setq-local completion-ignore-case (not completion-ignore-case)) + (minibuffer-message "Completion is now case-%ssensitive" + (if completion-ignore-case "in" ""))) + (defun minibuffer-force-complete-and-exit () "Exit the minibuffer with the first matching completion. @@ -3456,6 +3463,7 @@ The completion method is determined by `completion-at-point-functions'." "" #'minibuffer-complete "C-o" #'minibuffer-cycle-completion "C-l" #'minibuffer-restore-completion-input + "C-S-a" #'minibuffer-toggle-completion-ignore-case "SPC" #'minibuffer-complete-word "?" #'minibuffer-completion-help "" #'switch-to-completions -- 2.39.5