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

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

[elpa] externals/cape 2bcdd7bfe5 052/146: cape-file-capf: Require direct


From: ELPA Syncer
Subject: [elpa] externals/cape 2bcdd7bfe5 052/146: cape-file-capf: Require directory as prefix (Fix #9)
Date: Sun, 9 Jan 2022 20:57:42 -0500 (EST)

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

    cape-file-capf: Require directory as prefix (Fix #9)
---
 cape.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/cape.el b/cape.el
index 9059511ec9..db93c6d9c5 100644
--- a/cape.el
+++ b/cape.el
@@ -323,9 +323,11 @@
 (defun cape-file-capf ()
   "File name completion-at-point-function."
   (when-let (bounds (bounds-of-thing-at-point 'filename))
-    `(,(car bounds) ,(cdr bounds) ,#'read-file-name-internal
-      :company-prefix-length ,(eq (char-before) ?/)
-      :exclusive no ,@cape--file-properties)))
+    (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 ()



reply via email to

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