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#47417: Expand/fix use of completion-no-auto-exit flag Date: Sat, 12 Mar 2022 20:40:18 +0200 Organization: LINKOV.NET Message-ID: <86tuc36mvp.fsf@mail.linkov.net> References: <87pmyyqbp0.fsf@linkov.net> <86sfutzrum.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="24445"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: 47417@debbugs.gnu.org, rswgnu@gmail.com To: Robert Weiner Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Mar 12 20:14:32 2022 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 1nT7CC-0006Dq-9p for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 12 Mar 2022 20:14:32 +0100 Original-Received: from localhost ([::1]:59908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nT7CB-0004Mb-1Z for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 12 Mar 2022 14:14:31 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:47094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nT7Bj-0004J2-0O for bug-gnu-emacs@gnu.org; Sat, 12 Mar 2022 14:14:11 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46973) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nT7Bi-0005HM-OM for bug-gnu-emacs@gnu.org; Sat, 12 Mar 2022 14:14:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nT7Bi-0008Tq-De for bug-gnu-emacs@gnu.org; Sat, 12 Mar 2022 14:14:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 12 Mar 2022 19:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47417 X-GNU-PR-Package: emacs Original-Received: via spool by 47417-submit@debbugs.gnu.org id=B47417.164711241832545 (code B ref 47417); Sat, 12 Mar 2022 19:14:02 +0000 Original-Received: (at 47417) by debbugs.gnu.org; 12 Mar 2022 19:13:38 +0000 Original-Received: from localhost ([127.0.0.1]:40867 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nT7BK-0008Sr-14 for submit@debbugs.gnu.org; Sat, 12 Mar 2022 14:13:38 -0500 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:60065) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nT7BH-0008Sa-Tk for 47417@debbugs.gnu.org; Sat, 12 Mar 2022 14:13:36 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 7EB73FF803; Sat, 12 Mar 2022 19:13:28 +0000 (UTC) In-Reply-To: <86sfutzrum.fsf@mail.linkov.net> (Juri Linkov's message of "Wed, 15 Dec 2021 19:43:29 +0200") 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" Xref: news.gmane.io gmane.emacs.bugs:228259 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit >> Currently I'm developing a patch (attached below) that allows to type >> ‘M-0 RET’ on a completion to insert it to the minibuffer, and quit the window >> without exiting the minibuffer. > > Below is a better patch. It binds C-RET to insert the completion to the minibuffer. > > Regarding whether to quit the window or not, this question is currently > discussed on emacs-devel. This is a copy of the patch from emacs-devel. It adds two new arguments to 'choose-completion': 'no-exit' that doesn't exit the minibuffer and 'no-quit' that doesn't quit the completions window. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=choose-completion-no-auto-exit.patch diff --git a/lisp/simple.el b/lisp/simple.el index accc119e2b..72521b13dc 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -9039,6 +9039,7 @@ completion-list-mode-map (define-key map [follow-link] 'mouse-face) (define-key map [down-mouse-2] nil) (define-key map "\C-m" 'choose-completion) + (define-key map [C-return] 'choose-completion-no-auto-exit) (define-key map "\e\e\e" 'delete-completion-window) (define-key map [remap keyboard-quit] #'delete-completion-window) (define-key map [left] 'previous-completion) @@ -9151,10 +9159,16 @@ next-completion (when (/= 0 n) (switch-to-minibuffer)))) -(defun choose-completion (&optional event) +(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." - (interactive (list last-nonmenu-event)) +If EVENT, use EVENT's position to determine the starting position. +With prefix argument NO-EXIT, insert the completion at point to the +minibuffer, but don't exit the minibuffer. When the prefix argument +is not provided, then whether to exit the minibuffer depends on the value +of `completion-no-auto-exit'. +If NO-QUIT is non-nil, insert the completion at point to the +minibuffer, but don't quit the completions window." + (interactive (list last-nonmenu-event current-prefix-arg)) ;; In case this is run via the mouse, give temporary modes such as ;; isearch a chance to turn off. (run-hooks 'mouse-leave-buffer-hook) @@ -9162,6 +9176,7 @@ choose-completion (let ((buffer completion-reference-buffer) (base-position completion-base-position) (insert-function completion-list-insert-choice-function) + (completion-no-auto-exit (if no-exit t completion-no-auto-exit)) (choice (save-excursion (goto-char (posn-point (event-start event))) @@ -9179,7 +9195,8 @@ choose-completion (unless (buffer-live-p buffer) (error "Destination buffer is dead")) - (quit-window nil (posn-window (event-start event))) + (unless no-quit + (quit-window nil (posn-window (event-start event)))) (with-current-buffer buffer (choose-completion-string @@ -9189,6 +9206,14 @@ choose-completion (list (choose-completion-guess-base-position choice))) insert-function))))) +(defun choose-completion-no-auto-exit (&optional event) + "Insert the completion at point to the minibuffer without exiting it. +Like `choose-completion', it chooses the completion at point, +inserts it to the minibuffer, but doesn't exit the minibuffer." + (interactive (list last-nonmenu-event)) + (let ((completion-no-auto-exit t)) + (choose-completion event))) + ;; Delete the longest partial match for STRING ;; that can be found before POINT. (defun choose-completion-guess-base-position (string) --=-=-=--