summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2025-12-20 15:04:41 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2025-12-20 15:07:54 +0100
commite18cdcb5b2f326ee606ff8be4c427d00c66f316b (patch)
tree2b685e1477b730f7b56ec06b6d203cb7087ddf53
parent11abd6d12243dd20b5e19b58983d12c72fe07a98 (diff)
cape-file: Add location metadata for preview
-rw-r--r--cape.el26
1 files changed, 17 insertions, 9 deletions
diff --git a/cape.el b/cape.el
index 92f3b81..795b2c0 100644
--- a/cape.el
+++ b/cape.el
@@ -429,15 +429,23 @@ If INTERACTIVE is nil the function acts like a Capf."
(substitute-in-file-name file)))))
(unless (boundp 'comint-unquote-function)
(require 'comint))
- `( ,beg ,end
- ,(cape--nonessential-table
- (completion-table-with-quoting
- #'read-file-name-internal
- comint-unquote-function
- comint-requote-function))
- ,@(when (or prefix (string-match-p "./" file))
- '(:company-prefix-length t))
- ,@cape--file-properties)))))
+ (let ((table (cape--nonessential-table
+ (completion-table-with-quoting
+ #'read-file-name-internal
+ comint-unquote-function
+ comint-requote-function))))
+ `( ,beg ,end ,table
+ :company-location
+ ,(lambda (file)
+ (let* ((str (buffer-substring-no-properties beg (point)))
+ (pre (condition-case nil
+ (car (completion-boundaries str table nil ""))
+ (t 0)))
+ (file (file-name-concat (substring str 0 pre) file)))
+ (and (file-exists-p file) (list file))))
+ ,@(when (or prefix (string-match-p "./" file))
+ '(:company-prefix-length t))
+ ,@cape--file-properties))))))
;;;;; cape-elisp-symbol