[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 1a166df581: Generalise denote-excluded-directori
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 1a166df581: Generalise denote-excluded-directories-regexp |
Date: |
Sat, 5 Nov 2022 04:57:29 -0400 (EDT) |
branch: externals/denote
commit 1a166df581d37fccc5c79d38c330e12b1c54b906
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Generalise denote-excluded-directories-regexp
This builds on the initial idea of Graham Marlow in commit 39a20a7,
further refined in 95cd9f8.
Graham contributed in pull request 112 on the GitHub mirror:
<https://github.com/protesilaos/denote/pull/112>.
---
README.org | 31 +++++++++++++++++++++++++++++--
denote.el | 35 ++++++++++++++++++++++++++---------
2 files changed, 55 insertions(+), 11 deletions(-)
diff --git a/README.org b/README.org
index e95043be49..c9b5cacc2d 100644
--- a/README.org
+++ b/README.org
@@ -648,6 +648,31 @@ to experiment with the best setup for their workflow.
Feel welcome to ask for help if the information provided herein is not
sufficient. The manual shall be expanded accordingly.
+** Exclude certain directories from all operations
+:PROPERTIES:
+:CUSTOM_ID: h:8458f716-f9c2-4888-824b-2bf01cc5850a
+:END:
+
+[ Part of {{{development-version}}}. ]
+
+#+vindex: denote-excluded-directories-regexp
+The user option ~denote-excluded-directories-regexp~ instructs all
+Denote functions that read or check file/directory names to omit
+directories that match the given regular expression. The regexp needs
+to match only the name of the directory, not its full path.
+
+Affected operations include file prompts and functions that return the
+available files in the value of the user option ~denote-directory~
+([[#h:15719799-a5ff-4e9a-9f10-4ca03ef8f6c5][Maintain separate directory silos
for notes]]).
+
+File prompts are used by several commands, such as ~denote-link~ and
+~denote-subdirectory~.
+
+Functions that check for files include ~denote-directory-files~ and
+~denote-directory-subdirectories~.
+
+[[#h:c916d8c5-540a-409f-b780-6ccbd90e088e][For developers or advanced users]].
+
* Renaming files
:PROPERTIES:
:CUSTOM_ID: h:532e8e2a-9b7d-41c0-8f4b-3c5cbb7d4dca
@@ -2313,7 +2338,7 @@ Everything is in place to set up the package.
(setq denote-sort-keywords t)
(setq denote-file-type nil) ; Org is the default, set others here
(setq denote-prompts '(title keywords))
-
+(setq denote-excluded-directories-regexp nil)
;; Pick dates, where relevant, with Org's advanced interface:
(setq denote-date-prompt-use-org-read-date t)
@@ -2514,7 +2539,9 @@ might change them without further notice.
#+findex: denote-directory-subdirectories
+ Function ~denote-directory-subdirectories~ :: Return list of
- subdirectories of the variable ~denote-directory~. Note that the
+ subdirectories in variable ~denote-directory~. Omit dotfiles (such
+ as .git) unconditionally. Also exclude whatever matches
+ ~denote-excluded-directories-regexp~. Note that the
~denote-directory~ accepts a directory-local value for what we call
"silos" ([[#h:15719799-a5ff-4e9a-9f10-4ca03ef8f6c5][Maintain separate
directories for notes]]).
diff --git a/denote.el b/denote.el
index 91de774d0b..d5874d6046 100644
--- a/denote.el
+++ b/denote.el
@@ -380,11 +380,17 @@ current note."
(make-obsolete 'denote-link-fontify-backlinks 'denote-backlinks-show-context
"1.2.0")
(defcustom denote-excluded-directories-regexp nil
- "Regular expression of directories to exclude from file prompts.
-When nil (the default value) all directory names are shown.
+ "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
+`denote-directory'. The regexp needs to match only the name of
+the directory, not its full path.
-File prompts are used by several commands, such as `denote-link'.
-The underlying function is `denote-file-prompt'."
+File prompts are used by several commands, such as `denote-link'
+and `denote-subdirectory'.
+
+Functions that check for files include `denote-directory-files'
+and `denote-directory-subdirectories'."
:group 'denote
:package-version '(denote . "1.2.0")
:type 'string)
@@ -646,7 +652,13 @@ value, as explained in its doc string."
(seq-remove
(lambda (f)
(not (denote-file-has-identifier-p f)))
- (directory-files-recursively (denote-directory)
directory-files-no-dot-files-regexp t))))
+ (directory-files-recursively
+ (denote-directory)
+ directory-files-no-dot-files-regexp
+ :include-directories
+ (lambda (f)
+ (when-let ((regexp denote-excluded-directories-regexp))
+ (not (string-match-p regexp f))))))))
(defun denote-directory-text-only-files ()
"Return list of text files in variable `denote-directory'.
@@ -659,12 +671,17 @@ Filter `denote-directory-files' using
`denote-file-is-note-p'."
"1.0.0")
(defun denote-directory-subdirectories ()
- "Return list of subdirectories in variable `denote-directory'."
+ "Return list of subdirectories in variable `denote-directory'.
+Omit dotfiles (such as .git) unconditionally. Also exclude
+whatever matches `denote-excluded-directories-regexp'."
(seq-remove
(lambda (filename)
- (or (not (file-directory-p filename))
- (string-match-p "\\`\\."
(denote-get-file-name-relative-to-denote-directory filename))
- (string-match-p "/\\."
(denote-get-file-name-relative-to-denote-directory filename))))
+ (let ((rel (denote-get-file-name-relative-to-denote-directory filename)))
+ (or (not (file-directory-p filename))
+ (string-match-p "\\`\\." rel)
+ (string-match-p "/\\." rel)
+ (when-let ((regexp denote-excluded-directories-regexp))
+ (string-match-p regexp rel)))))
(directory-files-recursively (denote-directory) ".*" t t)))
(define-obsolete-function-alias
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/denote 1a166df581: Generalise denote-excluded-directories-regexp,
ELPA Syncer <=