[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/cape 6c9abaf15a 2/2: cape-interactive: Preserve context
From: |
ELPA Syncer |
Subject: |
[elpa] externals/cape 6c9abaf15a 2/2: cape-interactive: Preserve context when Capf is invoked interactively |
Date: |
Tue, 6 Jun 2023 06:57:41 -0400 (EDT) |
branch: externals/cape
commit 6c9abaf15adfbd9c6bf593609ac3bea8c8de0611
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
cape-interactive: Preserve context when Capf is invoked interactively
---
cape.el | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/cape.el b/cape.el
index aefb68a7f6..9b61aec192 100644
--- a/cape.el
+++ b/cape.el
@@ -308,8 +308,7 @@ See the user option `cape-file-directory-must-exist'.
If INTERACTIVE is nil the function acts like a Capf."
(interactive (list t))
(if interactive
- (let (cape-file-directory-must-exist)
- (cape-interactive #'cape-file))
+ (cape-interactive '(cape-file-directory-must-exist) #'cape-file)
(pcase-let* ((default-directory (pcase cape-file-directory
('nil default-directory)
((pred stringp) cape-file-directory)
@@ -487,8 +486,7 @@ See the user options `cape-dabbrev-min-length' and
`cape-dabbrev-check-other-buffers'."
(interactive (list t))
(if interactive
- (let ((cape-dabbrev-min-length 0))
- (cape-interactive #'cape-dabbrev))
+ (cape-interactive '((cape-dabbrev-min-length 0)) #'cape-dabbrev)
(when-let ((bounds (cape--dabbrev-bounds)))
`(,(car bounds) ,(cdr bounds)
,(cape--table-with-properties
@@ -824,7 +822,12 @@ changed. The function `cape-company-to-capf' is
experimental."
;;;###autoload
(defun cape-interactive (&rest capfs)
"Complete interactively with the given CAPFS."
- (let ((completion-at-point-functions capfs))
+ (let* ((ctx (and (consp (car capfs)) (car capfs)))
+ (capfs (if ctx (cdr capfs) capfs))
+ (completion-at-point-functions
+ (if ctx
+ (mapcar (lambda (fun) `(lambda () (let ,ctx (,fun)))) capfs)
+ capfs)))
(unless (completion-at-point)
(user-error "%s: No completions"
(mapconcat (lambda (fun)