From: Eshel Yaron Date: Tue, 20 Feb 2024 07:40:16 +0000 (+0100) Subject: ; Remove 'minibuffer-visible-completions' and associated cruft X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9353b4a0637aeae97238e5716558d11d11d86b47;p=emacs.git ; Remove 'minibuffer-visible-completions' and associated cruft * lisp/minibuffer.el (completion-auto-deselect) (completions--deselect, completions--after-change) (minibuffer-visible-completions) (minibuffer-visible-completions-bind) (minibuffer-visible-completions-map) (minibuffer-choose-completion-or-exit): Remove. (display-completion-list, minibuffer-completion-help) (completion-in-region-mode) (minibuffer-mode, completing-read-default) (minibuffer-next-completion): Simplify. * lisp/simple.el (choose-completion-deselect-if-after): Remove. (choose-completion, completion-setup-function): Simplify. * etc/NEWS: Remove announcement. --- diff --git a/etc/NEWS b/etc/NEWS index 4e6476d5907..23aa469a8df 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -802,25 +802,6 @@ Bound to '' and '' arrow keys, respectively, they navigate the "*Completions*" buffer vertically by lines, wrapping at the top/bottom when 'completion-auto-wrap' is non-nil. -*** New user option 'minibuffer-visible-completions'. -When customized to non-nil, you can use arrow keys in the minibuffer -to navigate the completions displayed in the "*Completions*" window. -Typing 'RET' selects the highlighted candidate. 'C-g' hides the -completions window. When the completions window is not visible, -then all these keys have their usual meaning in the minibuffer. -This option is supported for in-buffer completion as well. - -*** Selected completion candidates are deselected on typing. -When you type at the minibuffer prompt, the current completion -candidate will be un-highlighted, and point in the "*Completions*" window -will be moved off that candidate. 'minibuffer-choose-completion' -('M-RET') will still choose a previously-selected completion -candidate, but the new command 'minibuffer-choose-completion-or-exit' -(bound to 'RET' by 'minibuffer-visible-completions') will exit with -the minibuffer contents instead. This deselection behavior can be -controlled with the new user option 'completion-auto-deselect', which -is t by default. - +++ *** New value 'historical' for user option 'completions-sort'. When 'completions-sort' is set to 'historical', completion candidates diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 78734ea71bc..30e898c0c3c 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -2642,19 +2642,16 @@ function as described in the documentation of `completion-metadata'." (cat (if completion-category (format " %s" completion-category) ""))) (with-current-buffer standard-output (goto-char (point-max)) - (if completions-header-format - (let ((heading - (format-spec completions-header-format - (list (cons ?s (length completions)) - (cons ?t sort-desc) - (cons ?r pred-desc) - (cons ?c cat))))) - (add-face-text-property - 0 (length heading) 'completions-heading t heading) - (insert heading)) - (unless completion-show-help - ;; Ensure beginning-of-buffer isn't a completion. - (insert (propertize "\n" 'face '(:height 0))))) + (when completions-header-format + (let ((heading + (format-spec completions-header-format + (list (cons ?s (length completions)) + (cons ?t sort-desc) + (cons ?r pred-desc) + (cons ?c cat))))) + (add-face-text-property + 0 (length heading) 'completions-heading t heading) + (insert heading))) (completion--insert-strings completions group-fun))) (run-hooks 'completion-setup-hook) @@ -2735,36 +2732,6 @@ in `completion-metadata'. (resize-temp-buffer-window win)) (fit-window-to-buffer win completions-max-height))) -(defcustom completion-auto-deselect t - "If non-nil, deselect current completion candidate when you type in minibuffer. - -A non-nil value means that after typing at the minibuffer prompt, -any completion candidate highlighted in *Completions* window (to -indicate that it is the selected candidate) will be un-highlighted, -and point in the *Completions* window will be moved off such a candidate. -This means that `RET' (`minibuffer-choose-completion-or-exit') will exit -the minubuffer with the minibuffer's current contents, instead of the -selected completion candidate." - :type '(choice (const :tag "Candidates in *Completions* stay selected as you type" nil) - (const :tag "Typing deselects any completion candidate in *Completions*" t)) - :version "30.1") - -(defun completions--deselect () - "If point is in a completion candidate, move to just after the end of it. - -The candidate will still be chosen by `choose-completion' unless -`choose-completion-deselect-if-after' is non-nil." - (when (get-text-property (point) 'completion--string) - (goto-char (or (next-single-property-change (point) 'completion--string) - (point-max))))) - -(defun completions--after-change (_start _end _old-len) - "Update displayed *Completions* buffer after change in buffer contents." - (when completion-auto-deselect - (when-let (window (get-buffer-window "*Completions*" 0)) - (with-selected-window window - (completions--deselect))))) - (defcustom minibuffer-read-sort-order-with-completion nil "Whether to use completion for reading minibuffer completions sort order. If this user options is nil (the default), @@ -2914,7 +2881,6 @@ completions list." ;; If there are no completions, or if the current input is already ;; the sole completion, then hide (previous&stale) completions. (minibuffer-hide-completions) - (remove-hook 'after-change-functions #'completions--after-change t) (if completions (completion--message "Sole completion") (completion--fail))) @@ -2975,8 +2941,6 @@ completions list." (body-function . ,#'(lambda (_window) (with-current-buffer mainbuf - (when completion-auto-deselect - (add-hook 'after-change-functions #'completions--after-change nil t)) ;; Remove the base-size tail because `sort' requires a properly ;; nil-terminated list. (when last (setcdr last nil)) @@ -3269,14 +3233,8 @@ Also respects the obsolete wrapper hook `completion-in-region-functions'. completion-in-region-mode-predicate) (setq-local minibuffer-completion-auto-choose nil) (add-hook 'post-command-hook #'completion-in-region--postch) - (let* ((keymap completion-in-region-mode-map) - (keymap (if minibuffer-visible-completions - (make-composed-keymap - (list minibuffer-visible-completions-map - keymap)) - keymap))) - (push `(completion-in-region-mode . ,keymap) - minor-mode-overriding-map-alist)))) + (push `(completion-in-region-mode . ,completion-in-region-mode-map) + minor-mode-overriding-map-alist))) ;; Define-minor-mode added our keymap to minor-mode-map-alist, but we want it ;; on minor-mode-overriding-map-alist instead. @@ -3516,43 +3474,8 @@ the mode hook of this mode." :interactive nil ;; Enable text conversion, but always make sure `RET' does ;; something. - (setq text-conversion-style 'action) - (when minibuffer-visible-completions - (setq-local minibuffer-completion-auto-choose nil))) - -(defcustom minibuffer-visible-completions nil - "Whether candidates shown in *Completions* can be navigated from minibuffer. -When non-nil, if the *Completions* buffer is displayed in a window, -you can use the arrow keys in the minibuffer to move the cursor in -the window showing the *Completions* buffer. Typing `RET' selects -the highlighted completion candidate. -If the *Completions* buffer is not displayed on the screen, or this -variable is nil, the arrow keys move point in the minibuffer as usual, -and `RET' accepts the input typed into the minibuffer." - :type 'boolean - :version "30.1") + (setq text-conversion-style 'action)) -(defun minibuffer-visible-completions-bind (binding) - "Use BINDING when completions are visible. -Return an item that is enabled only when a window -displaying the *Completions* buffer exists." - `(menu-item - "" ,binding - :filter ,(lambda (cmd) - (when-let ((window (get-buffer-window "*Completions*" 0))) - (when (eq (buffer-local-value 'completion-reference-buffer - (window-buffer window)) - (window-buffer (active-minibuffer-window))) - cmd))))) - -(defvar-keymap minibuffer-visible-completions-map - :doc "Local keymap for minibuffer input with visible completions." - "" (minibuffer-visible-completions-bind #'minibuffer-previous-completion) - "" (minibuffer-visible-completions-bind #'minibuffer-next-completion) - "" (minibuffer-visible-completions-bind #'minibuffer-previous-line-completion) - "" (minibuffer-visible-completions-bind #'minibuffer-next-line-completion) - "RET" (minibuffer-visible-completions-bind #'minibuffer-choose-completion-or-exit) - "C-g" (minibuffer-visible-completions-bind #'minibuffer-hide-completions)) ;;; Completion tables. @@ -5212,14 +5135,9 @@ See `completing-read' for the meaning of the arguments." ;; `read-from-minibuffer' uses 1-based index. (1+ (cdr initial-input))))) - (let* ((base-keymap (if require-match - minibuffer-local-must-match-map - minibuffer-local-completion-map)) - (keymap (if minibuffer-visible-completions - (make-composed-keymap - (list minibuffer-visible-completions-map - base-keymap)) - base-keymap)) + (let* ((keymap (if require-match + minibuffer-local-must-match-map + minibuffer-local-completion-map)) (buffer (current-buffer)) (c-i-c completion-ignore-case) (result @@ -5355,8 +5273,7 @@ insert the selected completion candidate to the minibuffer." (next-line-completion (or n 1)) (next-completion (or n 1))) (when auto-choose - (let ((completion-use-base-affixes t) - (completion-auto-deselect nil)) + (let ((completion-use-base-affixes t)) (choose-completion nil t t)))))) (defun minibuffer-previous-completion (&optional n) @@ -5397,17 +5314,6 @@ minibuffer, but don't quit the completions window." (let ((completion-use-base-affixes t)) (choose-completion nil no-exit no-quit)))) -(defun minibuffer-choose-completion-or-exit (&optional no-exit no-quit) - "Choose the completion from the minibuffer or exit the minibuffer. -When `minibuffer-choose-completion' can't find a completion candidate -in the completions window, then exit the minibuffer using its present -contents." - (interactive "P") - (condition-case nil - (let ((choose-completion-deselect-if-after t)) - (minibuffer-choose-completion no-exit no-quit)) - (error (minibuffer-complete-and-exit)))) - (defun minibuffer-complete-history () "Complete the minibuffer history as far as possible. Like `minibuffer-complete' but completes on the history items diff --git a/lisp/simple.el b/lisp/simple.el index b36a04c93ef..c79da7c9eeb 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -10192,11 +10192,6 @@ Also see the `completion-auto-wrap' variable." (if pos (goto-char pos)))) (setq n (1+ n))))) -(defvar choose-completion-deselect-if-after nil - "If non-nil, don't choose a completion candidate if point is right after it. - -This makes `completions--deselect' effective.") - (defun choose-completion (&optional event no-exit no-quit) "Choose the completion at point. If EVENT, use EVENT's position to determine the starting position. @@ -10217,10 +10212,6 @@ minibuffer, but don't quit the completions window." (insert-function completion-list-insert-choice-function) (completion-no-auto-exit (if no-exit t completion-no-auto-exit)) (choice - (if choose-completion-deselect-if-after - (if-let ((str (get-text-property (posn-point (event-start event)) 'completion--string))) - (substring-no-properties str) - (error "No completion here")) (save-excursion (goto-char (posn-point (event-start event))) (let (beg) @@ -10236,7 +10227,7 @@ minibuffer, but don't quit the completions window." beg 'completion--string) beg)) (substring-no-properties - (get-text-property beg 'completion--string))))))) + (get-text-property beg 'completion--string)))))) (unless (buffer-live-p buffer) (error "Destination buffer is dead")) @@ -10446,27 +10437,13 @@ Called from `temp-buffer-show-hook'." ;; Maybe insert help string. (when completion-show-help (goto-char (point-min)) - (if minibuffer-visible-completions - (let ((helps - (with-current-buffer (window-buffer (active-minibuffer-window)) - (list - (substitute-command-keys - (if (display-mouse-p) - "Click or type \\[minibuffer-choose-completion-or-exit] on a completion to select it.\n" - "Type \\[minibuffer-choose-completion-or-exit] on a completion to select it.\n")) - (substitute-command-keys - "Type \\[minibuffer-next-completion], \\[minibuffer-previous-completion], \ -\\[minibuffer-next-line-completion], \\[minibuffer-previous-line-completion] \ -to move point between completions.\n\n"))))) - (dolist (help helps) - (insert help))) - (insert (substitute-command-keys - (if (display-mouse-p) - "Click or type \\[minibuffer-choose-completion] on a completion to select it.\n" - "Type \\[minibuffer-choose-completion] on a completion to select it.\n"))) - (insert (substitute-command-keys - "Type \\[minibuffer-next-completion] or \\[minibuffer-previous-completion] \ -to move point between completions.\n\n"))))))) + (insert (substitute-command-keys + (if (display-mouse-p) + "Click or type \\[minibuffer-choose-completion] on a completion to select it.\n" + "Type \\[minibuffer-choose-completion] on a completion to select it.\n"))) + (insert (substitute-command-keys + "Type \\[minibuffer-next-completion] or \\[minibuffer-previous-completion] \ +to move point between completions.\n\n")))))) (add-hook 'completion-setup-hook #'completion-setup-function)