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: Wed, 15 Dec 2021 19:43:29 +0200 Organization: LINKOV.NET Message-ID: <86sfutzrum.fsf@mail.linkov.net> References: <87pmyyqbp0.fsf@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="35141"; 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 Wed Dec 15 20:10:19 2021 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 1mxZfO-0008yg-T6 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 15 Dec 2021 20:10:18 +0100 Original-Received: from localhost ([::1]:56292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxZfN-0007dd-R2 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 15 Dec 2021 14:10:17 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:48548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxYKt-0001zs-00 for bug-gnu-emacs@gnu.org; Wed, 15 Dec 2021 12:45:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50293) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mxYKs-0001CT-Ms for bug-gnu-emacs@gnu.org; Wed, 15 Dec 2021 12:45:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mxYKs-0004Nt-JT for bug-gnu-emacs@gnu.org; Wed, 15 Dec 2021 12:45: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: Wed, 15 Dec 2021 17:45: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.163959028916820 (code B ref 47417); Wed, 15 Dec 2021 17:45:02 +0000 Original-Received: (at 47417) by debbugs.gnu.org; 15 Dec 2021 17:44:49 +0000 Original-Received: from localhost ([127.0.0.1]:33606 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mxYKf-0004NE-7Y for submit@debbugs.gnu.org; Wed, 15 Dec 2021 12:44:49 -0500 Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]:41061) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mxYKd-0004N0-DE for 47417@debbugs.gnu.org; Wed, 15 Dec 2021 12:44:47 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 5EE4FC0004; Wed, 15 Dec 2021 17:44:39 +0000 (UTC) In-Reply-To: <87pmyyqbp0.fsf@linkov.net> (Juri Linkov's message of "Tue, 13 Apr 2021 22:30:35 +0300") 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:222437 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. --=-=-= 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 84928caa31..73c5840e02 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -8979,6 +8992,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 [left] 'previous-completion) (define-key map [right] 'next-completion) @@ -9060,10 +9074,12 @@ next-completion (point) 'mouse-face nil beg)) (setq n (1+ n)))))) -(defun choose-completion (&optional event) +(defun choose-completion (&optional event arg) "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 the prefix ARG, insert the completion at point to the minibuffer +and quit the completion window without exiting the minibuffer." + (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) @@ -9071,6 +9087,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 arg t completion-no-auto-exit)) (choice (save-excursion (goto-char (posn-point (event-start event))) @@ -9098,6 +9116,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) --=-=-=--