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

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

[elpa] externals/mct e25fdd5 55/70: Merge branch 'completion-group-navig


From: ELPA Syncer
Subject: [elpa] externals/mct e25fdd5 55/70: Merge branch 'completion-group-navigation' into 'main'
Date: Thu, 11 Nov 2021 03:57:51 -0500 (EST)

branch: externals/mct
commit e25fdd5ad2ab45fec7d277e5990be0db6f96c9b9
Merge: 532656b 2dd1308
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Merge branch 'completion-group-navigation' into 'main'
    
    Add functions to jump through completion groups in completions
    
    See merge request protesilaos/mct!2
---
 mct.el | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/mct.el b/mct.el
index 3f848a1..8bbff09 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 ()
@@ -831,6 +864,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]