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

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

[elpa] externals/mct f7aa93a8da: Document mct+avy integration


From: ELPA Syncer
Subject: [elpa] externals/mct f7aa93a8da: Document mct+avy integration
Date: Wed, 9 Feb 2022 04:57:33 -0500 (EST)

branch: externals/mct
commit f7aa93a8da9b9ce0219865be8921bc5dbba9dba6
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Document mct+avy integration
---
 README.org | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/README.org b/README.org
index e7d6a33a82..fbf5e9eb5b 100644
--- a/README.org
+++ b/README.org
@@ -1146,6 +1146,45 @@ not be part of =mct.el=.  Use this in your init file 
instead:
 (advice-add #'completing-read-multiple :filter-args #'my-crm-indicator)
 #+end_src
 
+** Select completion with Avy
+:PROPERTIES:
+:CUSTOM_ID: h:18a2a223-8544-4294-b847-012c99003de4
+:END:
+
+The =avy= package by Oleh Krehel can be used to quickly select a candidate
+from a visible =*Completions*= buffer.  In the following example, we
+activate it with the =C-.= key.
+
+#+begin_src emacs-lisp
+;; Adapted from Omar AntolĂ­n Camarena's `avy-embark-collect.el'.
+(defun my-avy--choose (pt)
+  "Choose completion at PT."
+  (goto-char pt)
+  (mct-choose-completion-exit))
+
+(defun my-avy-completions-select ()
+  "Choose completion and exit using Avy."
+  (interactive)
+  (when (mct--get-completion-window)
+    (mct--switch-to-completions)
+    (avy-with avy-completion
+      (let ((avy-action 'my-avy--choose))
+        (avy-process
+         (save-excursion
+           (let (completions)
+             (goto-char (mct--first-completion-point))
+             (while (not (eobp))
+               (push (point) completions)
+               (next-completion 1))
+             (nreverse completions))))))))
+
+(dolist (map (list mct-minibuffer-local-completion-map
+                   mct-minibuffer-completion-list-map
+                   mct-region-completion-list-map
+                   mct-region-buffer-map))
+  (define-key map (kbd "C-.") #'my-avy-completions-select))
+#+end_src
+
 ** Ido-style navigation through directories
 :PROPERTIES:
 :CUSTOM_ID: h:9a6746dd-0be9-4e29-ac40-0af9612d05a2



reply via email to

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