emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/denote b8d4c362c3 03/15: Add helper to test that dir is


From: ELPA Syncer
Subject: [elpa] externals/denote b8d4c362c3 03/15: Add helper to test that dir is part of denote
Date: Wed, 10 Aug 2022 02:57:34 -0400 (EDT)

branch: externals/denote
commit b8d4c362c3e1825ea8387fcb78f4c058993e2fe2
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    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)))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]