summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common.el34
-rw-r--r--completion-conf.el2
2 files changed, 36 insertions, 0 deletions
diff --git a/common.el b/common.el
index 7da6129..aa90a88 100644
--- a/common.el
+++ b/common.el
@@ -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
diff --git a/completion-conf.el b/completion-conf.el
index b47520d..7885943 100644
--- a/completion-conf.el
+++ b/completion-conf.el
@@ -51,11 +51,13 @@
(define-key minibuffer-local-completion-map (vector ?\C-p) #'durand-embark-scroll-up-or-go-to-completions)
(define-key minibuffer-local-completion-map (vector ?\s-v) #'durand-completion-toggle-display)
(define-key minibuffer-local-completion-map (vector 32) nil)
+(define-key minibuffer-local-completion-map (vector ?\M-o) #'durand-completion-goto-minibuffer)
(define-key minibuffer-local-must-match-map (vector 32) nil)
(define-key completion-list-mode-map (vector 'down) #'durand-completion-scroll-down-or-go-to-minibuffer)
(define-key completion-list-mode-map (vector 'up) #'durand-completion-scroll-up-or-go-to-minibuffer)
(define-key completion-list-mode-map (vector ?\C-n) #'durand-completion-scroll-down-or-go-to-minibuffer)
(define-key completion-list-mode-map (vector ?\C-p) #'durand-completion-scroll-up-or-go-to-minibuffer)
+(define-key completion-list-mode-map (vector ?\M-o) #'durand-completion-goto-minibuffer)
;;; New behaviours of emacs 29 make the default completion list more useful now