branch: externals/denote
commit 01618516ff09afb19302b20fe49c48e222ca45b8
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>
Refine denote--file-name-relative-to-denote-directory
---
denote.el | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/denote.el b/denote.el
index 58ea9ed912..f57ce463e0 100644
--- a/denote.el
+++ b/denote.el
@@ -317,9 +317,11 @@ FILE is relative to the variable `denote-directory'."
(defun denote--file-name-relative-to-denote-directory (file)
"Return file name of FILE relative to the variable `denote-directory'.
FILE must be an absolute path."
- (if (and (file-name-absolute-p file)
- (string-prefix-p (denote-directory) file))
- (substring-no-properties file (length (denote-directory)))))
+ (if-let* ((dir (denote-directory))
+ ((file-name-absolute-p file))
+ ((string-prefix-p dir file)))
+ (substring-no-properties file (length dir))
+ file))
(defun denote--current-file-is-note-p ()
"Return non-nil if current file likely is a Denote note."