summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2023-04-08 22:50:39 +0200
committerDaniel Mendler <mail@daniel-mendler.de>2023-04-08 22:50:39 +0200
commite18bc35dd9a283c5bc781453e3a9bf20b6332cf3 (patch)
treebe84fb0e5e03f8aea5c3757cd31df7837a78f85f
parent15e0e61addd320972265b03ac6e692edd9468a0b (diff)
Use pcase-let
-rw-r--r--cape.el22
1 files changed, 11 insertions, 11 deletions
diff --git a/cape.el b/cape.el
index ee1e9ab..1e9587b 100644
--- a/cape.el
+++ b/cape.el
@@ -294,21 +294,21 @@ If INTERACTIVE is nil the function acts like a Capf."
(if interactive
(let (cape-file-directory-must-exist)
(cape-interactive #'cape-file))
- (let* ((default-directory (pcase cape-file-directory
- ('nil default-directory)
- ((pred stringp) cape-file-directory)
- (_ (funcall cape-file-directory))))
- (bounds (cape--bounds 'filename))
- (non-essential t)
- (file (buffer-substring (car bounds) (cdr bounds)))
- ;; Support org links globally, see `org-open-at-point-global'.
- (org (string-prefix-p "file:" file)))
- (when org (setcar bounds (+ 5 (car bounds))))
+ (pcase-let* ((default-directory (pcase cape-file-directory
+ ('nil default-directory)
+ ((pred stringp) cape-file-directory)
+ (_ (funcall cape-file-directory))))
+ (`(,beg . ,end) (cape--bounds 'filename))
+ (non-essential t)
+ (file (buffer-substring-no-properties beg end))
+ ;; Support org links globally, see `org-open-at-point-global'.
+ (org (string-prefix-p "file:" file)))
+ (when org (setq beg (+ 5 beg)))
(when (or org
(not cape-file-directory-must-exist)
(and (string-search "/" file)
(file-exists-p (file-name-directory file))))
- `(,(car bounds) ,(cdr bounds)
+ `(,beg ,end
,(cape--nonessential-table #'read-file-name-internal)
,@(when (or org (string-match-p "./" file))
'(:company-prefix-length t))