branch: externals/denote
commit 877252b77e9d4e5e25fa236ee10f7f6b86f92262
Author: Protesilaos Stavrou <i...@protesilaos.com>
Commit: Protesilaos Stavrou <i...@protesilaos.com>

    Introduce denote-directory-get-files-function
    
    This is for users who need to customise the behaviour of
    'denote-directory-files'. I am adding it in response to issue 5 on the
    denote-org repository about the performance of Org dynamic
    blocks (where a custom function could help):
    <https://github.com/protesilaos/denote-org/issues/5>.
---
 README.org | 6 ++++++
 denote.el  | 7 ++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/README.org b/README.org
index 8f7496fa0e..247adb6323 100644
--- a/README.org
+++ b/README.org
@@ -5110,6 +5110,12 @@ The following sections cover the specifics.
   satisfy ~denote-file-has-identifier-p~ and are not backups. [ Part
   of {{{development-version}}}. ]
 
+#+vindex: denote-directory-get-files-function
++ Variable ~denote-directory-get-files-function~ :: Function to return
+  list of Denote files. Each file is a string representing an absolute
+  file system path. This is intended for use in the function
+  ~denote-directory-files~. [ Part of {{{development-version}}}. ]
+
 #+findex: denote-directory-files
 + Function ~denote-directory-files~ :: Return list of absolute file
   paths in variable ~denote-directory~. Files that match
diff --git a/denote.el b/denote.el
index 04c05ec43a..a01c7ddba1 100644
--- a/denote.el
+++ b/denote.el
@@ -1318,6 +1318,11 @@ are not backups."
            (not (backup-file-name-p file))))
     (denote--directory-all-files-recursively))))
 
+(defvar denote-directory-get-files-function #'denote-directory-get-files
+  "Function to return list of Denote files.
+Each file is a string representing an absolute file system path.  This
+is intended for use in the function `denote-directory-files'.")
+
 (defun denote-directory-files (&optional files-matching-regexp omit-current 
text-only exclude-regexp)
   "Return list of absolute file paths in variable `denote-directory'.
 Files that match `denote-excluded-files-regexp' are excluded from the
@@ -1339,7 +1344,7 @@ text files that satisfy 
`denote-file-has-supported-extension-p'.
 With optional EXCLUDE-REGEXP exclude the files that match the given
 regular expression.  This is done after FILES-MATCHING-REGEXP and
 OMIT-CURRENT have been applied."
-  (let ((files (denote--directory-get-files)))
+  (let ((files (funcall denote-directory-get-files-function)))
     (when (and omit-current buffer-file-name (denote-file-has-identifier-p 
buffer-file-name))
       (setq files (delete buffer-file-name files)))
     (when files-matching-regexp

Reply via email to