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

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

[nongnu] elpa/vcomplete a064184c7f 23/91: Add basic Embark support


From: ELPA Syncer
Subject: [nongnu] elpa/vcomplete a064184c7f 23/91: Add basic Embark support
Date: Tue, 24 May 2022 15:59:06 -0400 (EDT)

branch: elpa/vcomplete
commit a064184c7f3519807450c892441d1a1ce04044e3
Author: Daniel Semyonov <cmstr@dsemy.com>
Commit: Daniel Semyonov <cmstr@dsemy.com>

    Add basic Embark support
    
    * vcomplete.el (vcomplete-embark-current-completion): New function
    which acts as an Embark "target-finder".
    (vcomplete-embark-collect-candidates): New function which acts as an
    Embark "candidate collector".
---
 NEWS         |  3 +++
 vcomplete.el | 25 +++++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/NEWS b/NEWS
index ed30480912..5d6d77e16b 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ Vcomplete NEWS -- history of user-visible changes.
 See the end of the file for an explanation of the versioning scheme.
 
 * 1.0 (in development)
+
+** Add basic Embark support.
+
 ** Highlight the completion at point in the completion list buffer.
 even when using normal navigation commands.
 This only works when completing in the minibuffer currently (although
diff --git a/vcomplete.el b/vcomplete.el
index ac18991e55..5f148614af 100644
--- a/vcomplete.el
+++ b/vcomplete.el
@@ -273,6 +273,31 @@ completion:
     (remove-hook 'minibuffer-exit-hook #'vcomplete--reset-vars)
     (remove-hook 'completion-in-region-mode-hook #'vcomplete--setup-current)))
 
+;;;; Embark integration:
+
+(declare-function embark-target-completion-at-point "ext:embark")
+(declare-function embark-completions-buffer-candidates "ext:embark")
+
+(defun vcomplete-embark-current-completion (&optional relative)
+  "Call ‘embark-target-completion-at-point’ in the ‘*Completions*’ buffer."
+  (when (and vcomplete-mode
+             (or (minibufferp) completion-in-region-mode))
+    (vcomplete-with-completions-buffer
+      (embark-target-completion-at-point relative))))
+
+(defun vcomplete-embark-collect-candidates ()
+  "Call ‘embark-completions-buffer-candidates’ in the ‘*Completions*’ buffer."
+  (when (and vcomplete-mode
+             (or (minibufferp) completion-in-region-mode))
+    (vcomplete-with-completions-buffer
+      (embark-completions-buffer-candidates))))
+
+(with-eval-after-load 'embark
+  (add-hook 'embark-target-finders
+            #'vcomplete-embark-current-completion)
+  (add-hook 'embark-candidate-collectors
+           #'vcomplete-embark-collect-candidates))
+
 (provide 'vcomplete)
 
 ;;; vcomplete.el ends here



reply via email to

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