branch: externals/denote
commit b8d4c362c3e1825ea8387fcb78f4c058993e2fe2
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>
Add helper to test that dir is part of denote
This is done to avoid duplication in the code.
---
denote.el | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/denote.el b/denote.el
index dcdd1b8239..42a09701e6 100644
--- a/denote.el
+++ b/denote.el
@@ -446,11 +446,16 @@ FILE must be an absolute path."
((string-prefix-p dir file-name)))
(substring-no-properties file-name (length dir))))
+(defun denote--default-dir-has-denote-prefix ()
+ "Test `default-directory' for variable `denote-directory' prefix."
+ (string-prefix-p (denote-directory)
+ (expand-file-name default-directory)))
+
(defun denote--current-file-is-note-p ()
"Return non-nil if current file likely is a Denote note."
(and (or (string-match-p denote--id-regexp (buffer-file-name))
(string-match-p denote--id-regexp (buffer-name)))
- (string-prefix-p (denote-directory) (expand-file-name
default-directory))))
+ (denote--default-dir-has-denote-prefix)))
(defun denote--directory-files ()
"List expanded note files."
@@ -1108,8 +1113,7 @@ The return value is for `denote--format-front-matter'."
(lambda (buf)
(with-current-buffer buf
(when (and (eq major-mode 'dired-mode)
- (string-prefix-p (denote-directory)
- (expand-file-name default-directory)))
+ (denote--default-dir-has-denote-prefix))
(revert-buffer))))
(buffer-list)))