[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote d942333980 1/2: Make 'denote-add-links' always r
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote d942333980 1/2: Make 'denote-add-links' always read the dir-local variables |
Date: |
Mon, 1 Jul 2024 12:57:52 -0400 (EDT) |
branch: externals/denote
commit d9423339802b073bfa087705d19a546f98c42585
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Make 'denote-add-links' always read the dir-local variables
We do this by expanding the lists without using an intermediate
buffer. The previous approach was not working as intended in a silo,
because the dir-local value of 'denote-directory' was not present.
Thanks to yetanotherfossman for reporting the problem with
'denote-add-links' when used in a silo and for figuring out that the
temporary buffer was part of the problem. This was done in issue 386:
<https://github.com/protesilaos/denote/issues/386>.
---
README.org | 2 +-
denote.el | 33 ++++++++++++++-------------------
2 files changed, 15 insertions(+), 20 deletions(-)
diff --git a/README.org b/README.org
index 1b445eae9a..57176a9476 100644
--- a/README.org
+++ b/README.org
@@ -5741,7 +5741,7 @@ Denote is meant to be a collective effort. Every bit of
help matters.
Vick (VicZz), Viktor Haag, Wade Mealing, Yi Liu, Ypot, atanasj,
azegas, babusri, doolio, duli, drcxd, elge70, fingerknight,
hpgisler, mentalisttraceur, pRot0ta1p, rbenit68, relict007, sienic,
- sundar bp, zadca123
+ 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.el b/denote.el
index af653346ea..b0d14f7056 100644
--- a/denote.el
+++ b/denote.el
@@ -4404,10 +4404,7 @@ Place the buffer below the current window or wherever
the user option
(defvar denote-link--prepare-links-format "- %s\n"
"Format specifiers for `denote-link-add-links'.")
-;; NOTE 2022-06-16: There is no need to overwhelm the user with options,
-;; though I expect someone to want to change the sort order.
-(defvar denote-link-add-links-sort nil
- "When t, add REVERSE to `sort-lines' of `denote-link-add-links'.")
+(make-obsolete-variable 'denote-link-add-links-sort nil "3.1.0")
(defun denote-link--prepare-links (files current-file-type id-only &optional
no-sort)
"Prepare links to FILES from CURRENT-FILE-TYPE.
@@ -4415,18 +4412,15 @@ When ID-ONLY is non-nil, use a generic link format.
With optional NO-SORT do not try to sort the inserted lines.
Otherwise sort lines while accounting for `denote-link-add-links-sort'."
- (with-temp-buffer
- (mapc
- (lambda (file)
- (let ((description (denote--link-get-description file)))
- (insert
- (format
- denote-link--prepare-links-format
- (denote-format-link file description current-file-type id-only)))))
- files)
- (unless no-sort
- (sort-lines denote-link-add-links-sort (point-min) (point-max)))
- (buffer-string)))
+ (let ((links))
+ (dolist (file files)
+ (let* ((description (denote--link-get-description file))
+ (link (denote-format-link file description current-file-type
id-only))
+ (link-as-list-item (format denote-link--prepare-links-format
link)))
+ (push link-as-list-item links)))
+ (if no-sort
+ (nreverse links)
+ (sort links #'string-collate-lessp))))
(defun denote-link--insert-links (files current-file-type &optional id-only
no-sort)
"Insert at point a typographic list of links matching FILES.
@@ -4440,7 +4434,9 @@ With ID-ONLY as a non-nil value, produce links that
consist only
of the identifier, thus deviating from CURRENT-FILE-TYPE.
Optional NO-SORT is passed to `denote-link--prepare-links'."
- (insert (denote-link--prepare-links files current-file-type id-only
no-sort)))
+ (when-let ((links (denote-link--prepare-links files current-file-type
id-only no-sort)))
+ (dolist (link links)
+ (insert link))))
;;;###autoload
(defun denote-add-links (regexp &optional id-only)
@@ -4459,8 +4455,7 @@ inserts links with just the identifier."
(and buffer-file-name (denote-file-has-supported-extension-p
buffer-file-name)))
(user-error "The current file type is not recognized by Denote"))
(let ((file-type (denote-filetype-heuristics (buffer-file-name))))
- (if-let ((files (denote-directory-files regexp :omit-current))
- (beg (point)))
+ (if-let ((files (denote-directory-files regexp :omit-current)))
(denote-link--insert-links files file-type id-only)
(message "No links matching `%s'" regexp))))