summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2022-02-14 12:14:57 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2022-02-14 12:15:25 +0100
commite5e11f30f0b6ed0a2b283d5d3dec84bcd36557fc (patch)
tree6d4c94d2919ed59749663f13e03824f51a5d018e
parenta20e8c3596c317619cdcecbf8fc66441e558d997 (diff)
cape-file: Mark completion table as non-essential
-rw-r--r--cape.el15
1 files changed, 13 insertions, 2 deletions
diff --git a/cape.el b/cape.el
index 4c7e400..b91d581 100644
--- a/cape.el
+++ b/cape.el
@@ -352,6 +352,15 @@
(cape--silent
(complete-with-action action table str pred))))
+(defun cape--nonessential-table (table)
+ "Mark completion TABLE as `non-essential'."
+ (lambda (str pred action)
+ (let ((non-essential t))
+ (let ((result (funcall table str pred action)))
+ (when (and (eq action 'completion--unquote) (functionp (cadr result)))
+ (cl-callf cape--nonessential-table (cadr result)))
+ result))))
+
(cl-defun cape--table-with-properties (table &key category (sort t) &allow-other-keys)
"Create completion TABLE with properties.
CATEGORY is the optional completion category.
@@ -416,13 +425,15 @@ VALID is the input comparator, see `cape--input-valid-p'."
If INTERACTIVE is nil the function acts like a capf."
(interactive (list t))
(if interactive
- (let (cape-file-directory-must-exist)
+ (let ((cape-file-directory-must-exist))
(cape--interactive #'cape-file))
(let* ((bounds (cape--bounds 'filename))
+ (non-essential t)
(file (buffer-substring (car bounds) (cdr bounds))))
(when (or (not cape-file-directory-must-exist)
(and (string-match-p "/" file) (file-exists-p (file-name-directory file))))
- `(,(car bounds) ,(cdr bounds) ,#'read-file-name-internal
+ `(,(car bounds) ,(cdr bounds)
+ ,(cape--nonessential-table #'read-file-name-internal)
,@(and (not (equal file "/")) (string-suffix-p "/" file)
'(:company-prefix-length t))
:exclusive no ,@cape--file-properties)))))