branch: externals/denote
commit bb1599b21ca7a7c04dcae2f6d45fc06b9f2ac4ee
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>
Omit backups from 'denote-directory-files'
Thanks to babusri for bringing this matter to my attention in issue
200 on the GitHub mirror:
<https://github.com/protesilaos/denote/issues/200>.
---
README.org | 4 ++--
denote.el | 19 +++++++++++++------
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/README.org b/README.org
index 96706f8a35..c2fb1bc911 100644
--- a/README.org
+++ b/README.org
@@ -4896,8 +4896,8 @@ Denote is meant to be a collective effort. Every bit of
help matters.
Mirko Hernandez, Niall Dooley, Paul van Gelder, Peter Prevos, Peter
Smith, Suhail Singh, Shreyas Ragavan, Stefan Thesing, Summer Emacs,
Sven Seebeck, Taoufik, TJ Stankus, Viktor Haag, Wade Mealing, Yi
- Liu, Ypot, atanasj, doolio, drcxd, hpgisler, pRot0ta1p, rbenit68,
- relict007, sienic, sundar bp.
+ Liu, Ypot, atanasj, babusri, doolio, drcxd, hpgisler, pRot0ta1p,
+ rbenit68, relict007, sienic, sundar bp.
Special thanks to Peter Povinec who helped refine the file-naming
scheme, which is the cornerstone of this project.
diff --git a/denote.el b/denote.el
index 11d54a43fc..3e4ced6f05 100644
--- a/denote.el
+++ b/denote.el
@@ -797,6 +797,18 @@ Avoids traversing dotfiles (unconditionally) and whatever
matches
(t)))
:follow-symlinks))
+(defun denote--directory-get-files ()
+ "Return list with full path of valid files in variable `denote-directory'.
+Consider files that satisfy `denote-file-has-identifier-p' and
+are not backups."
+ (mapcar
+ #'expand-file-name
+ (seq-filter
+ (lambda (file)
+ (and (denote-file-has-identifier-p file)
+ (not (backup-file-name-p file))))
+ (denote--directory-all-files-recursively))))
+
(defun denote-directory-files (&optional files-matching-regexp omit-current
text-only)
"Return list of absolute file paths in variable `denote-directory'.
@@ -814,11 +826,7 @@ current Denote file in the returned list.
With optional TEXT-ONLY as a non-nil value, limit the results to
text files that satisfy `denote-file-is-note-p'."
- (let ((files (mapcar
- #'expand-file-name
- (seq-filter
- #'denote-file-has-identifier-p
- (denote--directory-all-files-recursively)))))
+ (let ((files (denote--directory-get-files)))
(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
@@ -3062,7 +3070,6 @@ With non-nil ID-ONLY, use the generic link format without
a
title.
Fall back to `denote-org-link-format'."
- ;; Includes backup files. Maybe we can remove them?
(cond
(id-only denote-id-only-link-format)
((when-let ((link (denote--link-format file-type)))