emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/mct 2dd1308 53/70: Add functions to jump through comple


From: ELPA Syncer
Subject: [elpa] externals/mct 2dd1308 53/70: Add functions to jump through completion groups in completions
Date: Thu, 11 Nov 2021 03:57:50 -0500 (EST)

branch: externals/mct
commit 2dd1308335488993d8d6a42ec9cd043af2f38744
Author: James N. V. Cash <james.nvc@gmail.com>
Commit: James N. V. Cash <james.nvc@gmail.com>

    Add functions to jump through completion groups in completions
---
 mct.el | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/mct.el b/mct.el
index 2ff86b3..29e4abe 100644
--- a/mct.el
+++ b/mct.el
@@ -574,6 +574,39 @@ minibuffer."
             (line-move-to-column col)))
       (previous-completion (if (natnump arg) arg 1))))))
 
+(defun mct-next-completion-group (&optional arg)
+  "Move to the next completion group.
+If ARG is supplied, move that many completion groups at a time."
+  (interactive "p" mct-mode)
+  (dotimes (_ (or arg 1))
+    (when-let (group (save-excursion
+                       (text-property-search-forward 'face
+                                                     
'completions-group-separator
+                                                     t nil)))
+      (let ((pos (prop-match-end group)))
+        (unless (eq pos (point-max))
+          (goto-char pos)
+          (next-completion 1))))))
+
+(defun mct-previous-completion-group (&optional arg)
+  "Move to the previous completion group.
+If ARG is supplied, move that many completion groups at a time."
+  (interactive "p" mct-mode)
+  (dotimes (_ (or arg 1))
+    ;; skip back, so if we're at the top of a group, we go to the previous 
one...
+    (next-line -1)
+    (if-let (group (save-excursion
+                     (text-property-search-backward 'face
+                                                    
'completions-group-separator
+                                                    t nil)))
+        (let ((pos (prop-match-beginning group)))
+          (unless (eq pos (point-min))
+            (goto-char pos)
+            (next-completion 1)))
+      ;; ...and if there was a match, go back down, so the point doesn't
+      ;; end in the group separator
+      (next-line 1))))
+
 ;;;;; Candidate selection
 
 (defun mct-choose-completion-exit ()
@@ -817,6 +850,8 @@ To be assigned to `minibuffer-setup-hook'."
     (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 (kbd "<left>") #'mct-previous-completion-group)
+    (define-key map (kbd "<right>") #'mct-next-completion-group)
     (define-key map (kbd "p") #'mct-previous-completion-or-mini)
     (define-key map (kbd "M-e") #'mct-edit-completion)
     (define-key map (kbd "<tab>") #'mct-choose-completion-no-exit)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]