diff options
author | JSDurand <mmemmew@gmail.com> | 2023-01-09 15:44:19 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2023-01-09 15:44:19 +0800 |
commit | 53d5d8fd235b99d20a9fade158483f4603fefc2b (patch) | |
tree | d57ef64d3711090ea40da5c3d31c3551a92155d3 /common.el | |
parent | 9329125383e2329ac75432a62f5a81d50db4d78b (diff) |
completion: add functions to jump between minibuffer and completions
* common.el (durand-completion-goto-minibuffer): Go to the
*Completions* buffer or the minibuffer, depending on whether we are
*in the minibuffer or the *Completions* buffer and the target buffer
*exists.
* completion-conf.el (minibuffer-local-completion-map)
(completion-list-mode-map): Bind the function in the right map.
Diffstat (limited to 'common.el')
-rw-r--r-- | common.el | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -156,6 +156,40 @@ ARG means do this command ARG times." ((< arg 0) (goto-char (point-max)))))))) +(defun durand-completion-goto-minibuffer () + "Go to the minibuffer." + (interactive) + (let ((active-minibuffer-window (active-minibuffer-window)) + (completion-windows + (delq nil + (mapcar + (lambda (w) + (and (consp + (delq nil + (mapcar + (lambda (name) + (string-match-p + name + (buffer-name (window-buffer w)))) + durand-completion-buffer-names))) + w)) + (window-list nil 'nomini)))) + (in-completion-p (consp + (delq nil + (mapcar + (lambda (name) + (string-equal name (buffer-name))) + durand-completion-buffer-names)))) + (in-minibuffer-p + (minibuffer-window-active-p (selected-window)))) + (cond + ((and active-minibuffer-window + (not in-minibuffer-p)) + (select-window active-minibuffer-window)) + ((and (consp completion-windows) + (not in-completion-p)) + (select-window (car completion-windows)))))) + ;; This can be optimized by not duplicating an element on the stack. ;;;###autoload |