From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#59486: completion-auto-wrap disobeyed by vertical navigation Date: Wed, 01 Nov 2023 19:45:50 +0200 Organization: LINKOV.NET Message-ID: <86a5rxwf9v.fsf@mail.linkov.net> References: <8635aayjm6.fsf@mail.linkov.net> <86zgchbj61.fsf@mail.linkov.net> <86r0lbuvrv.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11037"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) To: 59486@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 01 18:47:51 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qyFJn-0002km-JE for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 01 Nov 2023 18:47:51 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qyFJb-0000mZ-02; Wed, 01 Nov 2023 13:47:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qyFJQ-0000kU-IU for bug-gnu-emacs@gnu.org; Wed, 01 Nov 2023 13:47:30 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qyFJQ-0005d3-6I for bug-gnu-emacs@gnu.org; Wed, 01 Nov 2023 13:47:28 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qyFJy-0002iC-Bs for bug-gnu-emacs@gnu.org; Wed, 01 Nov 2023 13:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 01 Nov 2023 17:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59486 X-GNU-PR-Package: emacs Original-Received: via spool by 59486-submit@debbugs.gnu.org id=B59486.169886087410407 (code B ref 59486); Wed, 01 Nov 2023 17:48:02 +0000 Original-Received: (at 59486) by debbugs.gnu.org; 1 Nov 2023 17:47:54 +0000 Original-Received: from localhost ([127.0.0.1]:52518 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qyFJq-0002hn-1W for submit@debbugs.gnu.org; Wed, 01 Nov 2023 13:47:54 -0400 Original-Received: from relay8-d.mail.gandi.net ([2001:4b98:dc4:8::228]:59399) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qyFJn-0002hT-00 for 59486@debbugs.gnu.org; Wed, 01 Nov 2023 13:47:52 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id E1F071BF208 for <59486@debbugs.gnu.org>; Wed, 1 Nov 2023 17:47:07 +0000 (UTC) In-Reply-To: <86r0lbuvrv.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 31 Oct 2023 09:44:28 +0200") X-GND-Sasl: juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:273611 Archived-At: --=-=-= Content-Type: text/plain >> In a multi-column layout, the keys and >> wrap to the beginning/end of the completions buffer, >> but and don't. Here is a patch that supports >> completion-auto-wrap for wrapping to the top/bottom: > > Ok, here is a better patch: Pushed to master. Now here is a patch that implements the long-discussed feature of using arrow keys for navigating completions from the minibuffer only when the *Completions* buffer is visible. It's disabled by default and can be enabled by the option 'minibuffer-completion-visible'. It works nicely for the in-buffer completions as well: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=minibuffer-completion-visible.patch diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 2120e31775e..2601e705aa0 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -2707,8 +2716,14 @@ completion-in-region-mode completion-in-region-mode-predicate) (setq-local minibuffer-completion-auto-choose nil) (add-hook 'post-command-hook #'completion-in-region--postch) - (push `(completion-in-region-mode . ,completion-in-region-mode-map) - minor-mode-overriding-map-alist))) + (let* ((keymap completion-in-region-mode-map) + (keymap (if minibuffer-completion-visible + (make-composed-keymap + (list minibuffer-local-visible-completion-map + keymap)) + keymap))) + (push `(completion-in-region-mode . ,keymap) + 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. @@ -2953,7 +2972,32 @@ minibuffer-mode :interactive nil ;; Enable text conversion, but always make sure `RET' does ;; something. - (setq text-conversion-style 'action)) + (setq text-conversion-style 'action) + (when minibuffer-completion-visible + (setq-local minibuffer-completion-auto-choose nil))) + +(defcustom minibuffer-completion-visible t + "Non-nil means to navigate completions with arrows from the minibuffer. +This has effect only when the window with the *Completions* buffer +is visible on the screen." + :type 'boolean + :version "30.1") + +(defun minibuffer-bind-visible (binding) + `(menu-item + "" ,binding + :filter ,(lambda (cmd) + (when (get-buffer-window "*Completions*" 0) + cmd)))) + +(defvar-keymap minibuffer-local-visible-completion-map + :doc "Local keymap for minibuffer input with visible completions." + "" (minibuffer-bind-visible #'minibuffer-previous-completion) + "" (minibuffer-bind-visible #'minibuffer-next-completion) + "" (minibuffer-bind-visible #'minibuffer-previous-line-completion) + "" (minibuffer-bind-visible #'minibuffer-next-line-completion) + "RET" (minibuffer-bind-visible #'minibuffer-choose-completion) + "C-g" (minibuffer-bind-visible #'minibuffer-hide-completions)) ;;; Completion tables. @@ -4370,6 +4414,11 @@ completing-read-default ;; in minibuffer-local-filename-completion-map can ;; override bindings in base-keymap. base-keymap))) + (keymap (if minibuffer-completion-visible + (make-composed-keymap + (list minibuffer-local-visible-completion-map + keymap)) + keymap)) (buffer (current-buffer)) (c-i-c completion-ignore-case) (result @@ -4489,8 +4538,9 @@ minibuffer-completion-auto-choose :type 'boolean :version "29.1") -(defun minibuffer-next-completion (&optional n) +(defun minibuffer-next-completion (&optional n vertical) "Move to the next item in its completions window from the minibuffer. +When the optional argument VERTICAL is non-nil, move vertically. When `minibuffer-completion-auto-choose' is non-nil, then also insert the selected completion to the minibuffer." (interactive "p") @@ -4498,7 +4548,9 @@ minibuffer-next-completion (with-minibuffer-completions-window (when completions-highlight-face (setq-local cursor-face-highlight-nonselected-window t)) - (next-completion (or n 1)) + (if vertical + (next-line-completion (or n 1)) + (next-completion (or n 1))) (when auto-choose (let ((completion-use-base-affixes t)) (choose-completion nil t t)))))) @@ -4510,6 +4562,20 @@ minibuffer-previous-completion (interactive "p") (minibuffer-next-completion (- (or n 1)))) +(defun minibuffer-next-line-completion (&optional n) + "Move to the next completion line from the minibuffer. +When `minibuffer-completion-auto-choose' is non-nil, then also +insert the selected completion to the minibuffer." + (interactive "p") + (minibuffer-next-completion (or n 1) t)) + +(defun minibuffer-previous-line-completion (&optional n) + "Move to the previous completion line from the minibuffer. +When `minibuffer-completion-auto-choose' is non-nil, then also +insert the selected completion to the minibuffer." + (interactive "p") + (minibuffer-next-completion (- (or n 1)) t)) + (defun minibuffer-choose-completion (&optional no-exit no-quit) "Run `choose-completion' from the minibuffer in its completions window. With prefix argument NO-EXIT, insert the completion at point to the --=-=-=--