Narrow the list of possible completions in a command-specific manner
(@code{minibuffer-narrow-completions}).
@item C-x n w
-Remove all completions restrictions (@code{minibuffer-widen-completions}).
+Remove restrictions on the list of possible completions
+(@code{minibuffer-widen-completions}).
@item ?
Display a list of completions (@code{minibuffer-completion-help}).
@end table
@kindex C-x n w @r{(completion)}
@findex minibuffer-widen-completions
- @kbd{C-x n w} (@code{minibuffer-widen-completions}) removes all
+ @kbd{C-x n w} (@code{minibuffer-widen-completions}) removes
completions restrictions that you set with @kbd{C-x n n} or with
-@kbd{C-x n m}.
+@kbd{C-x n m}. This command prompts you for one or more of the
+restrictions that you set, and removes those restrictions. If there
+is only one restriction, @kbd{C-x n w} removes it without prompting.
+If you invoke this command with a prefix argument (@kbd{C-u C-x n w}),
+it removes all restrictions without prompting, regardless of how many
+there are.
@kindex ? @r{(completion)}
@cindex completion list
shows only commands that match both @samp{foo} and @samp{bar} in the
completions list.
- You can use @kbd{C-x n w} (@code{minibuffer-widen-completions}) in
-the minibuffer to remove the restrictions on the list of possible
+ Use @kbd{C-x n w} (@code{minibuffer-widen-completions}) in the
+minibuffer to remove the restrictions on the list of possible
completions that you set with @kbd{C-x n n} or with @kbd{C-x n m}.
+@kbd{C-x n w} prompts you for the description of a current completions
+restriction, and removes the corresponding restriction. The default
+candidate is the most recent restriction, and you can use completion
+to select other restriction descriptions. You can even specify
+multiple restrictions to remove at once, by separating their
+descriptions with commas in the minibuffer. If there is only one
+restriction to begin with, @kbd{C-x n w} removes it without prompting.
+If you invoke this command with a prefix argument (@kbd{C-u C-x n w}),
+it removes all restrictions without prompting, regardless of how many
+there are.
@node Completion Options
@subsection Completion Options
[menu-bar minibuf minibuffer-widen-completions]
'(menu-item "Remove Completions Restrictions"
minibuffer-widen-completions
- :help "Remove all restrictions on completions list"
+ :help "Remove restrictions on completions list"
:enable (minibuffer-narrow-completions-p)))
(bindings--define-key map
[menu-bar minibuf minibuffer-narrow-completions]
(gethash key table)))
(concat "narrowing to " (prin1-to-string input))))))
-(defun minibuffer-widen-completions ()
- "Remove all restrictions on current completion candidates."
- (interactive "" minibuffer-mode)
- (advice-function-mapc
- (lambda (a p)
- (when (alist-get 'description p)
- (remove-function (local 'minibuffer-completion-predicate) a)))
- minibuffer-completion-predicate)
+(defun minibuffer-widen-completions (&optional all)
+ "Remove restrictions on current minibuffer completions list.
+
+Prompt for one or more restrictions that currently apply to the
+list of possible minibuffer completions, and remove those
+restrictions. You can use completion to select the restrictions
+to remove, separating each of your selections with
+`crm-separator' (usually, a comma).
+
+When there is only one restriction, remove it without prompting.
+With optional argument ALL (interactively, the prefix argument),
+remove all current restrictions without prompting."
+ (interactive "P" minibuffer-mode)
+ (let ((desc-pred-alist nil))
+ (advice-function-mapc
+ (lambda (a p)
+ (when-let ((d (alist-get 'description p)))
+ (push (cons d a) desc-pred-alist)))
+ minibuffer-completion-predicate)
+ (unless desc-pred-alist
+ (user-error "No completions restrictions"))
+ ;; Put latest restriction first.
+ (setq desc-pred-alist (reverse desc-pred-alist))
+ (mapc
+ (lambda (pair)
+ (remove-function (local 'minibuffer-completion-predicate) (cdr pair)))
+ (if (or all
+ ;; Only one restriction.
+ (not (cdr desc-pred-alist)))
+ desc-pred-alist
+ (mapcar (lambda (desc)
+ (assoc desc desc-pred-alist))
+ (completing-read-multiple
+ (format-prompt "Remove completions restriction,s"
+ (caar desc-pred-alist))
+ desc-pred-alist nil t nil nil (caar desc-pred-alist))))))
(when completion-auto-help
- (minibuffer-completion-help))
- (when-let ((completions-buffer (get-buffer "*Completions*")))
+ (let ((beg-end (minibuffer--completion-boundaries)))
+ (minibuffer-completion-help (car beg-end) (cdr beg-end))))
+ (when-let ((completions-buffer (and (not (minibuffer-narrow-completions-p))
+ (get-buffer "*Completions*"))))
(with-current-buffer completions-buffer
(completions-narrow-mode -1))))