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

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

[elpa] externals/denote b5f94b50e1: Add :excluded-dirs-regexp parameter


From: ELPA Syncer
Subject: [elpa] externals/denote b5f94b50e1: Add :excluded-dirs-regexp parameter to all dynamic blocks
Date: Tue, 30 Jul 2024 03:58:17 -0400 (EDT)

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

    Add :excluded-dirs-regexp parameter to all dynamic blocks
    
    Thanks to Claudio Migliorelli for discussing this idea with me. It was
    done via a private channel and this information is shared with
    permission.
---
 README.org           | 60 ++++++++++++++++++++++++++++++++++++++++------------
 denote-org-extras.el | 26 ++++++++++++++++++-----
 denote.el            |  4 ++--
 3 files changed, 69 insertions(+), 21 deletions(-)

diff --git a/README.org b/README.org
index 877ec3b8e3..23d9330fb0 100644
--- a/README.org
+++ b/README.org
@@ -3225,6 +3225,22 @@ line to update the block.
   meaningful results: even something like =_journal= will work to
   include all files that have a =journal= keyword.
 
+- The =:excluded-dirs-regexp= is a string that contains a word or
+  regular expression that matches against directory files names
+  to-be-excluded from the results. This has the same meaning as
+  setting the ~denote-excluded-punctuation-regexp~ user option
+  ([[#h:8458f716-f9c2-4888-824b-2bf01cc5850a][Exclude certain directories from 
all operations]]). The user option
+  has a global effect, which is overridden locally in the dynamic
+  block. When the value of =:excluded-dirs-regexp= is nil (the
+  default), the value of ~denote-excluded-punctuation-regexp~ is used
+  (which is also nil by default, meaning that all directories are
+  included). When the value of =excluded-dirs-regexp= is ~t~ or some
+  other symbol, then the ~denote-excluded-punctuation-regexp~ is
+  ignored altogether. This is useful in the scenario where the user
+  option is set to exclude some directories but the dynamic blocks
+  wants to lift that restriction. [ The =excluded-dirs-regexp=
+  parameter is part of {{{development-version}}}. ]
+
 - The =:sort-by-component= parameter is optional. It sorts the files
   by the given Denote file name component. The value it accepts is an
   unquoted symbol among =title=, =keywords=, =signature=, =identifier=.
@@ -3320,6 +3336,22 @@ parameters, which are described further below:
   get meaningful results: even something like =_journal= will work to
   include all files that have a =journal= keyword.
 
+- The =:excluded-dirs-regexp= is a string that contains a word or
+  regular expression that matches against directory files names
+  to-be-excluded from the results. This has the same meaning as
+  setting the ~denote-excluded-punctuation-regexp~ user option
+  ([[#h:8458f716-f9c2-4888-824b-2bf01cc5850a][Exclude certain directories from 
all operations]]). The user option
+  has a global effect, which is overridden locally in the dynamic
+  block. When the value of =:excluded-dirs-regexp= is nil (the
+  default), the value of ~denote-excluded-punctuation-regexp~ is used
+  (which is also nil by default, meaning that all directories are
+  included). When the value of =excluded-dirs-regexp= is ~t~ or some
+  other symbol, then the ~denote-excluded-punctuation-regexp~ is
+  ignored altogether. This is useful in the scenario where the user
+  option is set to exclude some directories but the dynamic blocks
+  wants to lift that restriction. [ The =excluded-dirs-regexp=
+  parameter is part of {{{development-version}}}. ]
+
 - The =:sort-by-component= parameter is optional. It sorts the files
   by the given Denote file name component. The value it accepts is an
   unquoted symbol among =title=, =keywords=, =signature=, =identifier=.
@@ -5883,20 +5915,20 @@ Denote is meant to be a collective effort.  Every bit 
of help matters.
 
 + Ideas and/or user feedback :: Abin Simon, Aditya Yadav, Alan
   Schmitt, Aleksandr Vityazev, Alex Hirschfeld, Alexis Purslane,
-  Alfredo Borrás, Ashton Wiersdorf, Benjamin Kästner, Claudiu
-  Tănăselia, Colin McLear, Damien Cassou, Elias Storms, Federico
-  Stilman, Florian, Frédéric Willem Frank Ehmsen, Glenna D., Guo Yong,
-  Hanspeter Gisler Harold Ollivier, Jack Baty, Jay Rajput,
-  Jean-Charles Bagneris, Jens Östlund, Jeremy Friesen, Jonathan Sahar,
-  Johan Bolmsjö, Jousimies, Juanjo Presa, Julian Hoch, Kai von Fintel,
-  Kaushal Modi, Kolmas, M. Hadi Timachi, Maikol Solis, Mark Olson,
-  Mirko Hernandez, Niall Dooley, Nick Bell, Paul van Gelder, Peter
-  Prevos, Peter Smith, Samuel W. Flint, Suhail Singh, Shreyas Ragavan,
-  Stefan Thesing, Summer Emacs, Sven Seebeck, Taoufik, TJ Stankus,
-  Vick (VicZz), Viktor Haag, Wade Mealing, Yi Liu, Ypot, atanasj,
-  azegas, babusri, doolio, duli, drcxd, elge70, fingerknight,
-  hpgisler, mentalisttraceur, pRot0ta1p, rbenit68, relict007, sienic,
-  skissue, sundar bp, yetanotherfossman, zadca123
+  Alfredo Borrás, Ashton Wiersdorf, Benjamin Kästner, Claudio
+  Migliorelli, Claudiu Tănăselia, Colin McLear, Damien Cassou, Elias
+  Storms, Federico Stilman, Florian, Frédéric Willem Frank Ehmsen,
+  Glenna D., Guo Yong, Hanspeter Gisler Harold Ollivier, Jack Baty,
+  Jay Rajput, Jean-Charles Bagneris, Jens Östlund, Jeremy Friesen,
+  Jonathan Sahar, Johan Bolmsjö, Jousimies, Juanjo Presa, Julian Hoch,
+  Kai von Fintel, Kaushal Modi, Kolmas, M. Hadi Timachi, Maikol Solis,
+  Mark Olson, Mirko Hernandez, Niall Dooley, Nick Bell, Paul van
+  Gelder, Peter Prevos, Peter Smith, Samuel W. Flint, Suhail Singh,
+  Shreyas Ragavan, Stefan Thesing, Summer Emacs, Sven Seebeck,
+  Taoufik, TJ Stankus, Vick (VicZz), Viktor Haag, Wade Mealing, Yi
+  Liu, Ypot, atanasj, azegas, babusri, doolio, duli, drcxd, elge70,
+  fingerknight, hpgisler, mentalisttraceur, pRot0ta1p, rbenit68,
+  relict007, sienic, skissue, sundar bp, yetanotherfossman, zadca123
 
 Special thanks to Peter Povinec who helped refine the file-naming
 scheme, which is the cornerstone of this project.
diff --git a/denote-org-extras.el b/denote-org-extras.el
index 0ffb2a3ea9..89882a523d 100644
--- a/denote-org-extras.el
+++ b/denote-org-extras.el
@@ -369,6 +369,7 @@ Also see `denote-org-extras-dblock--files'."
    org-mode)
   (org-create-dblock (list :name "denote-links"
                            :regexp regexp
+                           :excluded-dirs-regexp nil
                            :sort-by-component nil
                            :reverse-sort nil
                            :id-only nil))
@@ -389,6 +390,8 @@ Used by `org-dblock-update' with PARAMS provided by the 
dynamic block."
          (sort (plist-get params :sort-by-component))
          (reverse (plist-get params :reverse-sort))
          (block-name (plist-get params :block-name))
+         (denote-excluded-directories-regexp (or (plist-get params 
:excluded-dirs-regexp)
+                                                 
denote-excluded-directories-regexp))
          (files (denote-org-extras-dblock--files rx sort reverse)))
     (when block-name (insert "#+name: " block-name "\n"))
     (denote-link--insert-links files 'org (plist-get params :id-only) 
:no-other-sorting)
@@ -405,6 +408,7 @@ Used by `org-dblock-update' with PARAMS provided by the 
dynamic block."
    org-mode)
   (org-create-dblock (list :name "denote-missing-links"
                            :regexp regexp
+                           :excluded-dirs-regexp nil
                            :sort-by-component nil
                            :reverse-sort nil
                            :id-only nil))
@@ -425,6 +429,8 @@ Used by `org-dblock-update' with PARAMS provided by the 
dynamic block."
          (sort (plist-get params :sort-by-component))
          (reverse (plist-get params :reverse-sort))
          (block-name (plist-get params :block-name))
+         (denote-excluded-directories-regexp (or (plist-get params 
:excluded-dirs-regexp)
+                                                 
denote-excluded-directories-regexp))
          (files (denote-org-extras-dblock--files-missing-only rx sort 
reverse)))
     (when block-name (insert "#+name: " block-name "\n"))
     (denote-link--insert-links files 'org (plist-get params :id-only) 
:no-other-sorting)
@@ -449,6 +455,7 @@ Used by `org-dblock-update' with PARAMS provided by the 
dynamic block."
   "Create Org dynamic block to insert Denote backlinks to current file."
   (interactive nil org-mode)
   (org-create-dblock (list :name "denote-backlinks"
+                           :excluded-dirs-regexp nil
                            :sort-by-component nil
                            :reverse-sort nil
                            :id-only nil))
@@ -467,6 +474,8 @@ Used by `org-dblock-update' with PARAMS provided by the 
dynamic block."
   (when-let ((files (denote-link-return-backlinks)))
     (let* ((sort (plist-get params :sort-by-component))
            (reverse (plist-get params :reverse-sort))
+           (denote-excluded-directories-regexp (or (plist-get params 
:excluded-dirs-regexp)
+                                                   
denote-excluded-directories-regexp))
            (files (denote-org-extras-dblock--maybe-sort-backlinks files sort 
reverse)))
       (denote-link--insert-links files 'org (plist-get params :id-only) 
:no-other-sorting)
       (join-line)))) ; remove trailing empty line
@@ -518,7 +527,7 @@ argument."
    ((stringp separator) separator)
    (t denote-org-extras-dblock-file-contents-separator)))
 
-(defun denote-org-extras-dblock-add-files (regexp &optional separator 
no-front-matter add-links sort-by-component reverse)
+(defun denote-org-extras-dblock-add-files (regexp &optional separator 
no-front-matter add-links sort-by-component reverse excluded-dirs-regexp)
   "Insert files matching REGEXP.
 
 Seaprate them with the optional SEPARATOR.  If SEPARATOR is nil,
@@ -537,8 +546,13 @@ 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 (denote-org-extras-dblock--files regexp sort-by-component 
reverse))
+If optional REVERSE is non-nil reverse the sort order.
+
+Optional EXCLUDED-DIRS-REGEXP is the `let' bound value of
+`denote-excluded-directories-regexp'.  When nil, the original value of
+that user option is used."
+  (let* ((denote-excluded-directories-regexp (or excluded-dirs-regexp 
denote-excluded-directories-regexp))
+         (files (denote-org-extras-dblock--files regexp sort-by-component 
reverse))
          (files-contents (mapcar
                           (lambda (file) 
(denote-org-extras-dblock--get-file-contents file no-front-matter add-links))
                           files)))
@@ -556,6 +570,7 @@ among `denote-sort-components'."
    org-mode)
   (org-create-dblock (list :name "denote-files"
                            :regexp regexp
+                           :excluded-dirs-regexp nil
                            :sort-by-component sort-by-component
                            :reverse-sort nil
                            :no-front-matter nil
@@ -580,9 +595,10 @@ Used by `org-dblock-update' with PARAMS provided by the 
dynamic block."
          (block-name (plist-get params :block-name))
          (separator (plist-get params :file-separator))
          (no-f-m (plist-get params :no-front-matter))
-         (add-links (plist-get params :add-links)))
+         (add-links (plist-get params :add-links))
+         (excluded-dirs (plist-get params :excluded-dirs-regexp)))
     (when block-name (insert "#+name: " block-name "\n"))
-    (when rx (denote-org-extras-dblock-add-files rx separator no-f-m add-links 
sort reverse)))
+    (when rx (denote-org-extras-dblock-add-files rx separator no-f-m add-links 
sort reverse excluded-dirs)))
   (join-line)) ; remove trailing empty line
 
 
diff --git a/denote.el b/denote.el
index 1fcc133c4c..29357d9efd 100644
--- a/denote.el
+++ b/denote.el
@@ -607,7 +607,7 @@ but carries out the renaming without asking for 
confirmation)."
                      (const :tag "Rewrite front matter" rewrite-front-matter)
                      (const :tag "Modify file name" modify-file-name))))
 
-(defcustom denote-excluded-directories-regexp nil
+ (defcustom denote-excluded-directories-regexp nil
   "Regular expression of directories to exclude from all operations.
 Omit matching directories from file prompts and also exclude them
 from all functions that check the contents of the variable
@@ -1090,7 +1090,7 @@ FILE must be an absolute path."
 
 (defun denote--exclude-directory-regexp-p (file)
   "Return non-nil if FILE matches `denote-excluded-directories-regexp'."
-  (and denote-excluded-directories-regexp
+  (and (stringp denote-excluded-directories-regexp)
        (string-match-p denote-excluded-directories-regexp file)))
 
 (defun denote--directory-files-recursively-predicate (file)



reply via email to

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