[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/mct dedb62cce5 23/64: Implement next/prev candidate or
From: |
ELPA Syncer |
Subject: |
[elpa] externals/mct dedb62cce5 23/64: Implement next/prev candidate or quit completions |
Date: |
Thu, 30 Dec 2021 23:57:54 -0500 (EST) |
branch: externals/mct
commit dedb62cce5a291c62480b980f9aac0ce3c22322b
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Implement next/prev candidate or quit completions
This is for the completion-in-region scenario.
---
mct.el | 52 ++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 48 insertions(+), 4 deletions(-)
diff --git a/mct.el b/mct.el
index 80c06401be..7ecc584f42 100644
--- a/mct.el
+++ b/mct.el
@@ -1233,16 +1233,60 @@ current completion session."
(when (mct--region-p)
(mct--completions-choose-completion)))
+(defun mct--quit-completion-in-region ()
+ "Bury the Completions and terminate completion in region."
+ (quit-window nil (mct--get-completion-window))
+ ;; FIXME 2021-12-27: Ensure that we have exited the
+ ;; completion-in-region.
+ (keyboard-quit))
+
+(defun mct-next-completion-or-quit (&optional arg)
+ "Move to next completion or bury the Completions' buffer.
+
+This performs a regular motion for optional ARG candidates, but
+when point can no longer move in that direction it buries the
+Completions' buffer.
+
+This is a counterpart of `mct-next-completion-or-mini' that is
+meant for the case of completion in region (i.e. not in the
+minibuffer)."
+ (interactive nil mct-region-mode)
+ (let ((count (or arg 1)))
+ (cond
+ ((mct--bottom-of-completions-p count)
+ (mct--quit-completion-in-region))
+ (t
+ (mct--next-completion count)))))
+
+(defun mct-previous-completion-or-quit (&optional arg)
+ "Move to previous completion or bury the Completions' buffer.
+
+This performs a regular motion for optional ARG candidates, but
+when point can no longer move in that direction it buries the
+Completions' buffer.
+
+This is a counterpart of `mct-previous-completion-or-mini' that
+is meant for the case of completion in region (i.e. not in the
+minibuffer)."
+ (interactive nil mct-region-mode)
+ (let ((count (if (natnump arg) arg 1)))
+ (when (mct--region-p)
+ (cond
+ ((mct--top-of-completions-p count)
+ (mct--quit-completion-in-region))
+ (t
+ (mct--previous-completion count))))))
+
(defvar mct-region-completion-list-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "M-v") #'scroll-down-command)
(define-key map [remap goto-line] #'mct-choose-completion-number)
- ;; (define-key map [remap next-line] #'mct-next-completion-or-mini)
- ;; (define-key map (kbd "n") #'mct-next-completion-or-mini)
- ;; (define-key map [remap previous-line] #'mct-previous-completion-or-mini)
+ (define-key map [remap next-line] #'mct-next-completion-or-quit)
+ (define-key map (kbd "n") #'mct-next-completion-or-quit)
+ (define-key map [remap previous-line] #'mct-previous-completion-or-quit)
(define-key map (kbd "M-p") #'mct-previous-completion-group)
(define-key map (kbd "M-n") #'mct-next-completion-group)
- ;; (define-key map (kbd "p") #'mct-previous-completion-or-mini)
+ (define-key map (kbd "p") #'mct-previous-completion-or-quit)
(define-key map (kbd "<tab>") #'mct-choose-completion-in-region)
(define-key map (kbd "<return>") #'mct-choose-completion-in-region)
(define-key map [remap beginning-of-buffer] #'mct-beginning-of-buffer)
- [elpa] externals/mct adeddd2dfe 14/64: Write helper for "choose completion" routine, (continued)
- [elpa] externals/mct adeddd2dfe 14/64: Write helper for "choose completion" routine, ELPA Syncer, 2021/12/30
- [elpa] externals/mct 298a83cfc5 17/64: Respin the mct setup for in-region scenario (WIP), ELPA Syncer, 2021/12/30
- [elpa] externals/mct 0362ca4bf1 34/64: Rename symbol for consistency, ELPA Syncer, 2021/12/30
- [elpa] externals/mct 28d7c54f51 44/64: Add debug print to monitor completion-in-region-mode, ELPA Syncer, 2021/12/30
- [elpa] externals/mct bf0f666ee4 49/64: Replace "mct-mode" with "mct-minibuffer-mode", ELPA Syncer, 2021/12/30
- [elpa] externals/mct aaaf12c70c 50/64: Merge branch 'main' into experiment-completion-in-region, ELPA Syncer, 2021/12/30
- [elpa] externals/mct 775f42951d 02/64: Remove mct--region-current-buffer, ELPA Syncer, 2021/12/30
- [elpa] externals/mct fb177ace70 18/64: Keep "next or mini" intact (we'll use another fn), ELPA Syncer, 2021/12/30
- [elpa] externals/mct f3d86fe28a 06/64: Rename internal function, ELPA Syncer, 2021/12/30
- [elpa] externals/mct 72a1c3e6f4 22/64: Minor changes to doc strings, ELPA Syncer, 2021/12/30
- [elpa] externals/mct dedb62cce5 23/64: Implement next/prev candidate or quit completions,
ELPA Syncer <=
- [elpa] externals/mct 6bb328a795 24/64: Merge branch 'main' into experiment-completion-in-region, ELPA Syncer, 2021/12/30
- [elpa] externals/mct a3edf3ce5a 28/64: Remove obsolete function, ELPA Syncer, 2021/12/30
- [elpa] externals/mct 85d05c08b6 33/64: Remove superfluous comment, ELPA Syncer, 2021/12/30
- [elpa] externals/mct 6a1835cf00 48/64: Remove mct--region-buf, ELPA Syncer, 2021/12/30
- [elpa] externals/mct 771fb8b3cb 54/64: Make in-region prev motion work at all times, ELPA Syncer, 2021/12/30
- [elpa] externals/mct e4b49f40f1 58/64: Add TODO about local mct-region-mode, ELPA Syncer, 2021/12/30
- [elpa] externals/mct a6dac17d1c 59/64: Review mct--region-p for buffer-local mode, ELPA Syncer, 2021/12/30
- [elpa] externals/mct 59431a2622 61/64: Provide global variant of mct-region-mode, ELPA Syncer, 2021/12/30
- [elpa] externals/mct 9e81e4425a 64/64: Complete key bindings of next/prev group motions, ELPA Syncer, 2021/12/30
- [elpa] externals/mct 740d9f5d7d 01/64: Do not bind while-no-input-ignore-events, ELPA Syncer, 2021/12/30