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

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

[elpa] externals/denote 2f5b4ee97d 3/5: Abstract let bound code into its


From: ELPA Syncer
Subject: [elpa] externals/denote 2f5b4ee97d 3/5: Abstract let bound code into its own function in denote-org-dblock.el
Date: Fri, 1 Dec 2023 09:57:44 -0500 (EST)

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

    Abstract let bound code into its own function in denote-org-dblock.el
---
 denote-org-dblock.el | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/denote-org-dblock.el b/denote-org-dblock.el
index 68cd6eeef8..8aca2034aa 100644
--- a/denote-org-dblock.el
+++ b/denote-org-dblock.el
@@ -41,12 +41,29 @@
 (require 'denote-sort)
 (require 'org)
 
-;;;; Dynamic block to insert links
+;;;; Common helper functions
+
+(defun denote-org-dblock--files (files-matching-regexp &optional 
sort-by-component reverse)
+  "Return list of FILES-MATCHING-REGEXP in variable `denote-directory'.
+SORT-BY-COMPONENT and REVERSE have the same meaning as
+`denote-sort-files'.  If both are nil, do not try to perform any
+sorting."
+  (cond
+   ((and sort-by-component reverse)
+    (denote-sort-get-directory-files files-matching-regexp sort-by-component 
reverse))
+   (sort-by-component
+    (denote-sort-get-directory-files files-matching-regexp sort-by-component))
+   (reverse
+    (denote-sort-get-directory-files files-matching-regexp 
:no-component-specified reverse))
+   (t
+    (denote-directory-files files-matching-regexp))))
 
 (defun denote-org-dblock--file-regexp-prompt ()
   "Prompt for regexp to match Denote file names."
   (read-regexp "Search for notes matching REGEX: " nil 
'denote-link--add-links-history))
 
+;;;; Dynamic block to insert links
+
 ;;;###autoload
 (defun denote-org-dblock-insert-links (regexp)
   "Create Org dynamic block to insert Denote links matching REGEXP."
@@ -155,16 +172,7 @@ component.  If the symbol is not among 
`denote-sort-components',
 fall back to the default identifier-based sorting.
 
 If optional REVERSE is non-nil reverse the sort order."
-  (let ((files
-         (cond
-          ((and sort-by-component reverse)
-           (denote-sort-get-directory-files regexp sort-by-component reverse))
-          (sort-by-component
-           (denote-sort-get-directory-files regexp sort-by-component))
-          (reverse
-           (denote-sort-get-directory-files regexp :no-component-specified 
reverse))
-          (t
-           (denote-directory-files regexp)))))
+  (let ((files (denote-org-dblock--files regexp sort-by-component reverse)))
     ;; FIXME 2023-11-23: Do not use a separator for the last file.
     ;; Not a big issue, but is worth checking.
     (mapc



reply via email to

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