branch: externals/denote
commit b8be7d7bf0225b1ab252ba45628b9cd46136caa6
Author: Jean-Philippe Gagné Guay <[email protected]>
Commit: Jean-Philippe Gagné Guay <[email protected]>
Remove directories parameter from some functions
---
README.org | 5 +----
denote.el | 76 +++++++++++++++++++++++++++++---------------------------------
2 files changed, 36 insertions(+), 45 deletions(-)
diff --git a/README.org b/README.org
index a0fb1ca23a..329cc7f593 100644
--- a/README.org
+++ b/README.org
@@ -5540,10 +5540,7 @@ The following sections cover the specifics.
expression. This is done after =FILES-MATCHING-REGEXP= and
=OMIT-CURRENT= have been applied. With optional =HAS-IDENTIFIER= as
a non-~nil~ value, limit the results to files that have an
- identifier. With Optional =DIRECTORIES= as a list of directories,
- search through instead of looking into the variable
- ~denote-directory~. [ The optional =DIRECTORIES= is part of
- {{{development-version}}}. ]
+ identifier.
#+findex: denote-directory-subdirectories
+ Function ~denote-directory-subdirectories~ :: Return list of
diff --git a/denote.el b/denote.el
index 1c5c02d905..f76ce0f9f8 100644
--- a/denote.el
+++ b/denote.el
@@ -996,9 +996,9 @@ to override what this function returns."
(format "/%s/" (mapconcat #'identity common-parent "/"))
"/"))
-(defun denote-directories-get-common-root (&optional directories)
- "Get the common root directory of DIRECTORIES or `denote-directories'."
- (denote--get-common-root-directory (or directories (denote-directories))))
+(defun denote-directories-get-common-root ()
+ "Get the common root directory of `denote-directories'."
+ (denote--get-common-root-directory (denote-directories)))
(defun denote-directory ()
"Return the `car' of `denote-directories'.
@@ -1271,18 +1271,19 @@ relative to whichever one of those it belongs to."
(and (stringp denote-excluded-directories-regexp)
(string-match-p denote-excluded-directories-regexp file)))
-(defun denote--directory-all-files-recursively (directories)
- "Return list of all files in DIRECTORIES or `denote-directories'.
+(defun denote--directory-all-files-recursively ()
+ "Return list of all files in variable `denote-directories'.
Avoids traversing dotfiles (unconditionally) and whatever matches
`denote-excluded-directories-regexp'."
- (let ((predicate-fn
- (lambda (file)
- (let ((rel (denote-get-file-name-relative-to-denote-directory file
directories)))
- (cond
- ((string-match-p "\\`\\." rel) nil)
- ((string-match-p "/\\." rel) nil)
- ((denote--exclude-directory-regexp-p rel) nil)
- ((file-readable-p file)))))))
+ (let* ((directories (denote-directories))
+ (predicate-fn
+ (lambda (file)
+ (let ((rel (denote-get-file-name-relative-to-denote-directory file
directories)))
+ (cond
+ ((string-match-p "\\`\\." rel) nil)
+ ((string-match-p "/\\." rel) nil)
+ ((denote--exclude-directory-regexp-p rel) nil)
+ ((file-readable-p file)))))))
(apply #'append
(mapcar
(lambda (directory)
@@ -1304,21 +1305,17 @@ Avoids traversing dotfiles (unconditionally) and
whatever matches
'denote-directory-get-files
"4.1.0")
-(defun denote-directory-get-files (&optional directories)
+(defun denote-directory-get-files ()
"Return list with full path of valid files in variable `denote-directory'.
Consider files that satisfy `denote-file-has-denoted-filename-p' and
-are not backups.
-
-With optional DIRECTORIES, as a list of directories, perform the
-operation therein."
- (when-let* ((dirs (or directories (denote-directories))))
- (seq-filter
- (lambda (file)
- (and (file-regular-p file)
- (denote-file-has-denoted-filename-p file)
- (not (denote--file-excluded-p file))
- (not (backup-file-name-p file))))
- (denote--directory-all-files-recursively dirs))))
+are not backups."
+ (seq-filter
+ (lambda (file)
+ (and (file-regular-p file)
+ (denote-file-has-denoted-filename-p file)
+ (not (denote--file-excluded-p file))
+ (not (backup-file-name-p file))))
+ (denote--directory-all-files-recursively)))
(make-obsolete-variable
'denote-directory-get-files-function
@@ -1327,7 +1324,7 @@ operation therein."
;; The HAS-IDENTIFIER is there because we support cases where files do
;; not have an identifier.
-(defun denote-directory-files (&optional files-matching-regexp omit-current
text-only exclude-regexp has-identifier directories)
+(defun denote-directory-files (&optional files-matching-regexp omit-current
text-only exclude-regexp has-identifier)
"Return list of absolute file paths in variable `denote-directory'.
Files that match `denote-excluded-files-regexp' are excluded from the
list.
@@ -1350,11 +1347,8 @@ regular expression. This is done after
FILES-MATCHING-REGEXP and
OMIT-CURRENT have been applied.
With optional HAS-IDENTIFIER as a non-nil value, limit the results to
-files that have an identifier.
-
-With optional DIRECTORIES, search through them instead of in the
-variable `denote-directory'."
- (let ((files (denote-directory-get-files directories)))
+files that have an identifier."
+ (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
@@ -1373,18 +1367,18 @@ variable `denote-directory'."
files)))
files))
-(defun denote-directory-subdirectories (&optional directories)
- "Return list of subdirectories in DIRECTORIES or variable `denote-directory'.
+(defun denote-directory-subdirectories ()
+ "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)
- (let ((rel (denote-get-file-name-relative-to-denote-directory filename
directories)))
+ (let ((rel (denote-get-file-name-relative-to-denote-directory filename
(denote-directories))))
(or (not (file-directory-p filename))
(string-match-p "\\`\\." rel)
(string-match-p "/\\." rel)
(denote--exclude-directory-regexp-p rel))))
- (denote--directory-all-files-recursively (or directories
(denote-directories)))))
+ (denote--directory-all-files-recursively)))
;; TODO 2023-01-24: Perhaps there is a good reason to make this a user
;; option, but I am keeping it as a generic variable for now.
@@ -1555,10 +1549,10 @@ Return the absolute path to the matching file."
;; relative file paths of the completion candidates.
(default-directory (if single-dir-p
(car roots)
- (denote-directories-get-common-root roots)))
+ (denote-directories-get-common-root)))
(files (denote-directory-files
(or denote-file-prompt-use-files-matching-regexp
files-matching-regexp)
- :omit-current nil nil has-identifier roots))
+ :omit-current nil nil has-identifier))
(relative-files (if single-dir-p
(mapcar
(lambda (file)
@@ -1995,7 +1989,7 @@ When called from Lisp, the arguments are a string, a
symbol among
files)))))
(if-let* ((directory (if single-dir-p ; see comment in `denote-file-prompt'
(car roots)
- (denote-directories-get-common-root roots)))
+ (denote-directories-get-common-root)))
(files (funcall files-fn))
(dired-name (format-message files-matching-regexp))
(buffer-name (funcall denote-sort-dired-buffer-name-function
files-matching-regexp sort-by-component reverse-sort exclude-regexp)))
@@ -3582,8 +3576,8 @@ packages such as `marginalia' and `embark')."
;; relative file paths of the completion candidates.
(default-directory (if single-dir-p
(car roots)
- (denote-directories-get-common-root roots)))
- (subdirectories (denote-directory-subdirectories roots))
+ (denote-directories-get-common-root)))
+ (subdirectories (denote-directory-subdirectories))
(directories (append roots subdirectories)))
(completing-read
(format-prompt "Select SUBDIRECTORY" default)