[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 8c724d54cf 01/27: Support subdirectories
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 8c724d54cf 01/27: Support subdirectories |
Date: |
Sun, 3 Jul 2022 00:57:33 -0400 (EDT) |
branch: externals/denote
commit 8c724d54cf44bfb29e3a150890547bc79215606d
Author: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Support subdirectories
- In denote-directory-files, replace directory-files with
directory-files-recursively.
- The new function denote--file-name-relative-to-denote-directory is
used to fix the backlinks buffer and other parts of the code.
- Adjust denote-link--expand-identifiers and
denote-retrieve--read-file-prompt.
---
denote-link.el | 18 +++++++++++-------
denote-retrieve.el | 7 ++++---
denote.el | 24 +++++++++++++++++++-----
3 files changed, 34 insertions(+), 15 deletions(-)
diff --git a/denote-link.el b/denote-link.el
index 66b886640e..8970bbbc3b 100644
--- a/denote-link.el
+++ b/denote-link.el
@@ -312,9 +312,13 @@ format is always [[denote:IDENTIFIER]]."
(defun denote-link--expand-identifiers (regexp)
"Expend identifiers matching REGEXP into file paths."
- (delq nil (mapcar (lambda (i)
- (file-name-completion i (denote-directory)))
- (denote-link--collect-identifiers regexp))))
+ (let ((files (denote--directory-files))
+ (found-files))
+ (dolist (file files)
+ (dolist (i (denote-link--collect-identifiers regexp))
+ (if (string-prefix-p i (file-name-nondirectory file))
+ (push file found-files))))
+ found-files))
(defvar denote-link--find-file-history nil
"History for `denote-link-find-file'.")
@@ -442,16 +446,16 @@ Use optional TITLE for a prettier heading."
(l (length heading)))
(insert (format "%s\n%s\n\n" heading (make-string l ?-))))
(mapc (lambda (f)
- (insert (file-name-nondirectory f))
+ (insert f)
(make-button (point-at-bol) (point-at-eol) :type
'denote-link-backlink-button)
(newline))
files)
- (goto-char (point-min))
+ (goto-char (point-min)))
;; NOTE 2022-06-15: Technically this is not Dired. Maybe we
;; should abstract the fontification into a general purpose
;; minor-mode.
- (when denote-link-fontify-backlinks
- (denote-dired-mode 1)))
+ ;(when denote-link-fontify-backlinks
+ ;(denote-dired-mode 1)))
(denote-link--display-buffer buf)))
;;;###autoload
diff --git a/denote-retrieve.el b/denote-retrieve.el
index c12907f872..a340d8fac0 100644
--- a/denote-retrieve.el
+++ b/denote-retrieve.el
@@ -90,7 +90,8 @@ Optional GROUP is a regexp construct for
(defun denote-retrieve--read-file-prompt ()
"Prompt for regular file in variable `denote-directory'."
- (read-file-name "Select note: " (denote-directory) nil nil nil
#'denote--only-note-p))
+ (read-file-name "Select note: " (denote-directory) nil nil nil
+ #'(lambda (f) (or (denote--only-note-p f) (file-directory-p
f)))))
(defun denote-retrieve--files-in-output (files)
"Return list of FILES from `find' output."
@@ -109,14 +110,14 @@ The xrefs are returned as an alist."
Parse `denote-retrieve--xrefs'."
(sort
(mapcar (lambda (x)
- (file-name-nondirectory (car x)))
+ (denote--file-name-relative-to-denote-directory (car x)))
xrefs)
#'string-lessp))
(defun denote-retrieve--proces-grep (identifier)
"Process lines matching IDENTIFIER and return list of files."
(let* ((default-directory (denote-directory))
- (file (file-name-nondirectory (buffer-file-name))))
+ (file (denote--file-name-relative-to-denote-directory
(buffer-file-name))))
(denote-retrieve--files-in-output
(delete file (denote-retrieve--files-in-xrefs
(denote-retrieve--xrefs identifier))))))
diff --git a/denote.el b/denote.el
index 346986e12e..b785672a9a 100644
--- a/denote.el
+++ b/denote.el
@@ -310,6 +310,13 @@ FILE is relative to the variable `denote-directory'."
(string-match-p (concat "\\b" denote--id-regexp) file)
(not (string-match-p "[#~]\\'" file))))
+(defun denote--file-name-relative-to-denote-directory (file)
+ "Return file name of FILE relative to the variable `denote-directory'.
+FILE must be an absolute path."
+ (if (and (file-name-absolute-p file)
+ (string-prefix-p (denote-directory) file))
+ (substring-no-properties file (length (denote-directory)))))
+
(defun denote--current-file-is-note-p ()
"Return non-nil if current file likely is a Denote note."
(and (or (string-match-p denote--id-regexp (buffer-file-name))
@@ -322,11 +329,18 @@ FILE is relative to the variable `denote-directory'."
"List note files, assuming flat directory.
If optional ABSOLUTE, show full paths, else only show base file
names that are relative to the variable `denote-directory'."
- (let ((default-directory (denote-directory)))
- (seq-remove
- (lambda (f)
- (not (denote--only-note-p f)))
- (directory-files default-directory absolute
directory-files-no-dot-files-regexp t))))
+ (let* ((default-directory (denote-directory))
+ (files (mapcar
+ (lambda (s) (expand-file-name s))
+ (seq-remove
+ (lambda (f)
+ (not (denote--only-note-p f)))
+ (directory-files-recursively default-directory
directory-files-no-dot-files-regexp t)))))
+ (if absolute
+ files
+ (mapcar
+ (lambda (s) (denote--file-name-relative-to-denote-directory s))
+ files))))
(defun denote--directory-files-matching-regexp (regexp &optional
no-check-current)
"Return list of files matching REGEXP.
- [elpa] externals/denote updated (2193501cef -> 25e86bf0bc), ELPA Syncer, 2022/07/03
- [elpa] externals/denote e5d6ad589b 13/27: Support subdirectories in denote--link-find-file-at-button, ELPA Syncer, 2022/07/03
- [elpa] externals/denote 53e6ca2299 12/27: Tweak filename fontification to work with subdirs, ELPA Syncer, 2022/07/03
- [elpa] externals/denote 58637a0035 04/27: Tweak doc string, ELPA Syncer, 2022/07/03
- [elpa] externals/denote 8c724d54cf 01/27: Support subdirectories,
ELPA Syncer <=
- [elpa] externals/denote 12008dbcbf 11/27: Untabify a line, ELPA Syncer, 2022/07/03
- [elpa] externals/denote 01618516ff 07/27: Refine denote--file-name-relative-to-denote-directory, ELPA Syncer, 2022/07/03
- [elpa] externals/denote 070d4412ee 23/27: Set org-id-extra-files to all files in all subdirectories., ELPA Syncer, 2022/07/03
- [elpa] externals/denote add8f657bb 09/27: Merge pull request #25 from ggjp/subdir-support, ELPA Syncer, 2022/07/03
- [elpa] externals/denote 5f8b585349 22/27: Merge branch 'main' into subdir-support, ELPA Syncer, 2022/07/03
- [elpa] externals/denote e1aeb459ea 19/27: Refine how faces are applied (extends 123fb2b), ELPA Syncer, 2022/07/03
- [elpa] externals/denote 123fb2b670 18/27: Put all faces in denote-faces.el, ELPA Syncer, 2022/07/03
- [elpa] externals/denote 66e455ef84 14/27: Fix denote--current-file-is-note-p for subdirectories, ELPA Syncer, 2022/07/03
- [elpa] externals/denote 6dfb9376ca 24/27: Merge pull request #28 from ggjp/subdir-support, ELPA Syncer, 2022/07/03
- [elpa] externals/denote 25e86bf0bc 27/27: Update Acknowledgements in the manual, ELPA Syncer, 2022/07/03