[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote c98e793eef 07/10: Make 'denote-files' Org dynami
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote c98e793eef 07/10: Make 'denote-files' Org dynamic block leverage denote-sort |
Date: |
Thu, 30 Nov 2023 00:57:47 -0500 (EST) |
branch: externals/denote
commit c98e793eef4576a9c2da859a0663b12465473530
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Make 'denote-files' Org dynamic block leverage denote-sort
---
denote-org-dblock.el | 44 ++++++++++++++++++++++++++++++++++----------
1 file changed, 34 insertions(+), 10 deletions(-)
diff --git a/denote-org-dblock.el b/denote-org-dblock.el
index ed2e5a288e..7cb54bb236 100644
--- a/denote-org-dblock.el
+++ b/denote-org-dblock.el
@@ -38,6 +38,7 @@
;;; Code:
(require 'denote)
+(require 'denote-sort)
(require 'org)
;;;; Dynamic block to insert links
@@ -134,8 +135,9 @@ argument."
((stringp separator) separator)
(t denote-org-dblock-file-contents-separator)))
-(defun denote-org-dblock-add-files (regexp &optional separator no-front-matter
add-links)
+(defun denote-org-dblock-add-files (regexp &optional separator no-front-matter
add-links sort-by-component reverse)
"Insert files matching REGEXP.
+
Seaprate them with the optional SEPARATOR. If SEPARATOR is nil,
use the `denote-org-dblock-file-contents-separator'.
@@ -145,8 +147,22 @@ blank line, starting from the top of the buffer.
If optional ADD-LINKS is non-nil, first insert a link to the file
and then insert its contents. In this case, format the contents
-as a typographic list."
- (let ((files (denote-directory-files-matching-regexp regexp)))
+as a typographic list.
+
+If optional SORT-BY-COMPONENT is a symbol among `denote-sort-components',
+sort files matching REGEXP by the corresponding Denote file name
+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))
+ (t
+ (denote-directory-files-matching-regexp regexp)))))
;; FIXME 2023-11-23: Do not use a separator for the last file.
;; Not a big issue, but is worth checking.
(mapc
@@ -159,11 +175,18 @@ as a typographic list."
files)))
;;;###autoload
-(defun denote-org-dblock-insert-files (regexp)
- "Create Org dynamic block to insert Denote files matching REGEXP."
- (interactive (list (denote-org-dblock--file-regexp-prompt)))
+(defun denote-org-dblock-insert-files (regexp sort-by-component)
+ "Create Org dynamic block to insert Denote files matching REGEXP.
+Sort the files according to SORT-BY-COMPONENT, which is a symbol
+among `denote-sort-components'."
+ (interactive
+ (list
+ (denote-org-dblock--file-regexp-prompt)
+ (denote-sort-component-prompt)))
(org-create-dblock (list :name "denote-files"
:regexp regexp
+ :sort-by-component sort-by-component
+ :reverse-sort nil
:no-front-matter nil
:file-separator t
:add-links nil))
@@ -176,13 +199,14 @@ as a typographic list."
Used by `org-dblock-update' with PARAMS provided by the dynamic block."
(let* ((regexp (plist-get params :regexp))
(rx (if (listp regexp) (macroexpand `(rx ,regexp)) regexp))
+ (sort (plist-get params :sort-by-component))
+ (reverse (plist-get params :reverse-sort))
(block-name (plist-get params :block-name))
(separator (plist-get params :file-separator))
- (no-front-matter (plist-get params :no-front-matter))
+ (no-f-m (plist-get params :no-front-matter))
(add-links (plist-get params :add-links)))
- (when block-name
- (insert "#+name: " block-name "\n"))
- (when rx (denote-org-dblock-add-files rx separator no-front-matter
add-links)))
+ (when block-name (insert "#+name: " block-name "\n"))
+ (when rx (denote-org-dblock-add-files rx separator no-f-m add-links sort
reverse)))
(join-line)) ; remove trailing empty line
(provide 'denote-org-dblock)
- [elpa] externals/denote updated (edeaaa735e -> 97f34bdc0c), ELPA Syncer, 2023/11/30
- [elpa] externals/denote cf3c2b8cbe 03/10: Change the arity of denote-sort-files to make only REVERSE be optional, ELPA Syncer, 2023/11/30
- [elpa] externals/denote 1999217a51 06/10: Make sorting work for missing components; remove the macro, ELPA Syncer, 2023/11/30
- [elpa] externals/denote 0ed067e5a8 05/10: Rename symbols for consistency; make denote-sort-component-prompt public, ELPA Syncer, 2023/11/30
- [elpa] externals/denote 97f34bdc0c 10/10: Document denote-sort.el, with 'denote-sort-dired' in particular, ELPA Syncer, 2023/11/30
- [elpa] externals/denote db31cca8fa 02/10: Clarify denote-sort-components docstring, ELPA Syncer, 2023/11/30
- [elpa] externals/denote 3cd4999d1c 01/10: Rename denote-sort-files-keys to denote-sort-components; change to list of symbols, ELPA Syncer, 2023/11/30
- [elpa] externals/denote 4050bf6caf 08/10: Fix denote-org-dblock-add-files case of REVERSE without SORT-BY-COMPONENT, ELPA Syncer, 2023/11/30
- [elpa] externals/denote c98e793eef 07/10: Make 'denote-files' Org dynamic block leverage denote-sort,
ELPA Syncer <=
- [elpa] externals/denote 1318e4175e 04/10: Tweak denote-sort-files for clarity, ELPA Syncer, 2023/11/30
- [elpa] externals/denote 59f2a61caf 09/10: Document sorting facilities for 'denote-files' Org dynamic block, ELPA Syncer, 2023/11/30