all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Robert Weiner <rsw@gnu.org>
Cc: 47417@debbugs.gnu.org, rswgnu@gmail.com
Subject: bug#47417: Expand/fix use of completion-no-auto-exit flag
Date: Wed, 15 Dec 2021 19:43:29 +0200	[thread overview]
Message-ID: <86sfutzrum.fsf@mail.linkov.net> (raw)
In-Reply-To: <87pmyyqbp0.fsf@linkov.net> (Juri Linkov's message of "Tue, 13 Apr 2021 22:30:35 +0300")

[-- Attachment #1: Type: text/plain, Size: 376 bytes --]

> 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: choose-completion-no-auto-exit.patch --]
[-- Type: text/x-diff, Size: 2321 bytes --]

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)

  reply	other threads:[~2021-12-15 17:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-26 19:18 bug#47417: Expand/fix use of completion-no-auto-exit flag Robert Weiner
2021-04-13 19:30 ` Juri Linkov
2021-12-15 17:43   ` Juri Linkov [this message]
2022-03-12 18:40     ` Juri Linkov
2022-04-05 18:22       ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86sfutzrum.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=47417@debbugs.gnu.org \
    --cc=rsw@gnu.org \
    --cc=rswgnu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.