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

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

[elpa] externals/cape 75cb8c799a 071/146: Unify cape-file and cape-file-


From: ELPA Syncer
Subject: [elpa] externals/cape 75cb8c799a 071/146: Unify cape-file and cape-file-capf
Date: Sun, 9 Jan 2022 20:57:43 -0500 (EST)

branch: externals/cape
commit 75cb8c799a4eb620019a5386112d9da72765b238
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Unify cape-file and cape-file-capf
---
 cape.el | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/cape.el b/cape.el
index e8a6f79608..5671fdd956 100644
--- a/cape.el
+++ b/cape.el
@@ -369,23 +369,21 @@ SORT should be nil to disable sorting."
 (defvar cape--file-properties
   (list :annotation-function (lambda (s) (if (string-suffix-p "/" s) " Folder" 
" File"))
         :company-kind (lambda (s) (if (string-suffix-p "/" s) 'folder 'file)))
-  "Completion extra properties for `cape-file-capf'.")
+  "Completion extra properties for `cape-file'.")
 
 ;;;###autoload
-(defun cape-file-capf ()
-  "File name completion-at-point-function."
-  (when-let (bounds (bounds-of-thing-at-point 'filename))
-    (let ((file (buffer-substring (car bounds) (cdr bounds))))
-      (when (and (string-match-p "/" file) (file-exists-p (file-name-directory 
file)))
-        `(,(car bounds) ,(cdr bounds) ,#'read-file-name-internal
-          :company-prefix-length ,(and (not (equal file "/")) (string-suffix-p 
"/" file))
-          :exclusive no ,@cape--file-properties)))))
-
-;;;###autoload
-(defun cape-file ()
-  "Complete file name at point."
-  (interactive)
-  (cape--complete-thing 'filename #'read-file-name-internal 
cape--file-properties))
+(defun cape-file (&optional interactive)
+  "Complete file name at point.
+If INTERACTIVE is nil the function acts like a capf."
+  (interactive (list t))
+  (if interactive
+      (cape--complete-thing 'filename #'read-file-name-internal 
cape--file-properties)
+    (when-let (bounds (bounds-of-thing-at-point 'filename))
+      (let ((file (buffer-substring (car bounds) (cdr bounds))))
+        (when (and (string-match-p "/" file) (file-exists-p 
(file-name-directory file)))
+          `(,(car bounds) ,(cdr bounds) ,#'read-file-name-internal
+            :company-prefix-length ,(and (not (equal file "/")) 
(string-suffix-p "/" file))
+            :exclusive no ,@cape--file-properties))))))
 
 (defvar cape--symbol-properties
   (list :annotation-function (lambda (_) " Symbol")



reply via email to

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