Optimize file-exists-p! & project-file-exists-p!
This commit is contained in:
parent
e13ccf3e08
commit
52a04fd8c6
2 changed files with 13 additions and 7 deletions
|
@ -30,9 +30,10 @@ For example
|
|||
|
||||
Returns
|
||||
|
||||
'(or (file-exists-p (expand-file-name \"some-file\" \"~\"))
|
||||
(and (file-exists-p (expand-file-name path-var \"~\"))
|
||||
(file-exists-p \"/an/absolute/path\")))
|
||||
'(let ((_directory \"~\"))
|
||||
(or (file-exists-p (expand-file-name \"some-file\" _directory))
|
||||
(and (file-exists-p (expand-file-name path-var _directory))
|
||||
(file-exists-p \"/an/absolute/path\"))))
|
||||
|
||||
This is used by `associate!', `file-exists-p!' and `project-file-exists-p!'."
|
||||
(cond ((stringp spec)
|
||||
|
@ -41,7 +42,9 @@ This is used by `associate!', `file-exists-p!' and `project-file-exists-p!'."
|
|||
spec
|
||||
`(expand-file-name ,spec ,directory))))
|
||||
((symbolp spec)
|
||||
`(file-exists-p ,(if directory
|
||||
`(file-exists-p ,(if (and directory
|
||||
(or (not (stringp directory))
|
||||
(file-name-absolute-p directory)))
|
||||
`(expand-file-name ,spec ,directory)
|
||||
path)))
|
||||
((and (listp spec)
|
||||
|
@ -385,8 +388,11 @@ doesn't apply to variables, however.
|
|||
|
||||
For example:
|
||||
|
||||
(file-exists-p (or doom-core-dir \"~/.config\" \"some-file\") \"~\")"
|
||||
(doom--resolve-path-forms spec directory))
|
||||
(file-exists-p! (or doom-core-dir \"~/.config\" \"some-file\") \"~\")"
|
||||
(if directory
|
||||
`(let ((_directory ,directory))
|
||||
,(doom--resolve-path-forms spec '_directory))
|
||||
(doom--resolve-path-forms spec)))
|
||||
|
||||
(defmacro define-key! (keymaps key def &rest rest)
|
||||
"Like `define-key', but accepts a variable number of KEYMAPS and/or KEY+DEFs.
|
||||
|
|
|
@ -99,7 +99,7 @@ If NOCACHE, don't fetch a cached answer."
|
|||
Paths are relative to the project root, unless they start with ./ or ../ (in
|
||||
which case they're relative to `default-directory'). If they start with a slash,
|
||||
they are absolute."
|
||||
(doom--resolve-path-forms files '(doom-project-root)))
|
||||
`(file-exists-p! ,files (doom-project-root)))
|
||||
|
||||
(defun doom-project-find-file (dir)
|
||||
"Fuzzy-find a file under DIR."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue