* bug#47417: Expand/fix use of completion-no-auto-exit flag @ 2021-03-26 19:18 Robert Weiner 2021-04-13 19:30 ` Juri Linkov 0 siblings, 1 reply; 5+ messages in thread From: Robert Weiner @ 2021-03-26 19:18 UTC (permalink / raw) To: 47417 [-- Attachment #1: Type: text/plain, Size: 989 bytes --] It seems to me a high-level view of completion-no-auto-exit is to allow code outside of choose-completion and choose-completion-string to finish the completion selection process. Presently, this flag does inhibit closure of the minibuffer when choosing a completion but it does not inhibit closure of the list of completions if '?' has been used. I think the two are connected and that whatever external code is used to utilize the finalized completion should also handle the closure of the completion window. This can be accomplished by simply wrapping the call to 'quit-window' within 'choose-completion' with an '(unless completion-no-auto-exit...)' like so: (unless completion-no-auto-exit (quit-window nil (posn-window (event-start event)))) Please consider adding this as a quick fix. Then packages like Hyperbole which requires 2 clicks/presses to finalize a completion selection could use choose-completion without having to replace the whole function. Thanks, Bob [-- Attachment #2: Type: text/html, Size: 2406 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#47417: Expand/fix use of completion-no-auto-exit flag 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 0 siblings, 1 reply; 5+ messages in thread From: Juri Linkov @ 2021-04-13 19:30 UTC (permalink / raw) To: Robert Weiner; +Cc: 47417, rswgnu [-- Attachment #1: Type: text/plain, Size: 1931 bytes --] > It seems to me a high-level view of completion-no-auto-exit is to allow > code outside of choose-completion and choose-completion-string to finish > the completion selection process. Presently, this flag does inhibit > closure of the minibuffer when choosing a completion but it does not > inhibit closure of the list of completions if '?' has been used. I think > the two are connected and that whatever external code is used to utilize > the finalized completion should also handle the closure of the completion > window. 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. So to keep backward-compatibility of completion-no-auto-exit, its behavior should not be changed. Then there are two options: create a new variable, e.g. completion-no-auto-quit - to not quit the completion window. Or better to support a new value of the existing variable completion-no-auto-exit, e.g. 'no-quit-window'. > This can be accomplished by simply wrapping the call to 'quit-window' > within 'choose-completion' with an '(unless completion-no-auto-exit...)' > like so: > (unless completion-no-auto-exit (quit-window nil (posn-window > (event-start event)))) > > Please consider adding this as a quick fix. Then packages like Hyperbole > which requires 2 clicks/presses to finalize a completion selection could > use choose-completion without having to replace the whole function. Please describe the use cases in more details. When I tried to use the aforementioned condition, then after selecting a completion, the selected window is not switched to the minibuffer window. The completion window says selected. I'm not sure if this is what is needed. It seems after selecting a completion without quitting the completion window, it's expected that the minibuffer window should be selected. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: completion-no-auto-exit.patch --] [-- Type: text/x-diff, Size: 1274 bytes --] diff --git a/lisp/simple.el b/lisp/simple.el index 12435a0680..fd17749451 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -8850,10 +8850,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. +When the prefix ARG is 0, 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) @@ -8861,6 +8863,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 (eq arg 0) t completion-no-auto-exit)) (choice (save-excursion (goto-char (posn-point (event-start event))) ^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#47417: Expand/fix use of completion-no-auto-exit flag 2021-04-13 19:30 ` Juri Linkov @ 2021-12-15 17:43 ` Juri Linkov 2022-03-12 18:40 ` Juri Linkov 0 siblings, 1 reply; 5+ messages in thread From: Juri Linkov @ 2021-12-15 17:43 UTC (permalink / raw) To: Robert Weiner; +Cc: 47417, rswgnu [-- 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) ^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#47417: Expand/fix use of completion-no-auto-exit flag 2021-12-15 17:43 ` Juri Linkov @ 2022-03-12 18:40 ` Juri Linkov 2022-04-05 18:22 ` Juri Linkov 0 siblings, 1 reply; 5+ messages in thread From: Juri Linkov @ 2022-03-12 18:40 UTC (permalink / raw) To: Robert Weiner; +Cc: 47417, rswgnu [-- Attachment #1: Type: text/plain, Size: 583 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. 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. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: choose-completion-no-auto-exit.patch --] [-- Type: text/x-diff, Size: 2922 bytes --] 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) ^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#47417: Expand/fix use of completion-no-auto-exit flag 2022-03-12 18:40 ` Juri Linkov @ 2022-04-05 18:22 ` Juri Linkov 0 siblings, 0 replies; 5+ messages in thread From: Juri Linkov @ 2022-04-05 18:22 UTC (permalink / raw) To: Robert Weiner; +Cc: 47417, rswgnu close 47417 29.0.50 thanks > 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. Now pushed to master. I guess this implements the request, so closing now. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-04-05 18:22 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2022-03-12 18:40 ` Juri Linkov 2022-04-05 18:22 ` Juri Linkov
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.