[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 6bf916b03e 1/7: Add denote-link-add-missing-link
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 6bf916b03e 1/7: Add denote-link-add-missing-links |
Date: |
Fri, 30 Sep 2022 09:57:33 -0400 (EDT) |
branch: externals/denote
commit 6bf916b03e6c14eed32dc797851015970481160d
Author: EFLS <>
Commit: EFLS <>
Add denote-link-add-missing-links
Similar to `denote-link-add-missing-links', but only insert links
that are not yet included in the current buffer.
---
README.org | 11 +++++++++++
denote.el | 24 ++++++++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/README.org b/README.org
index 66528d7a1a..b3bd2fbf16 100644
--- a/README.org
+++ b/README.org
@@ -1204,6 +1204,17 @@ above is for interactive usage.
Links are created only for files which qualify as a "note" for our
purposes ([[#h:fc913d54-26c8-4c41-be86-999839e8ad31][Linking notes]]).
+** Insert links, but only those missing from current buffer
+
+#+findex: denote-link-add-missing-links
+As a variation on the =denote-link-add-links= function, one may wish to
+only include 'missing links', i.e. links that are not yet present in
+the current file.
+
+This can be achieved with =denote-link-add-missing-links=. The function
+is similar to =denote-link-add-links=, but will only include links to
+notes that are not yet linked to.
+
** Insert links from marked files in Dired
:PROPERTIES:
:CUSTOM_ID: h:9cbb692e-5d8a-44a6-9193-899a07872a07
diff --git a/denote.el b/denote.el
index 4036d422b3..5634b69df8 100644
--- a/denote.el
+++ b/denote.el
@@ -2518,6 +2518,30 @@ inserts links with just the identifier."
(defalias 'denote-link-insert-links-matching-regexp (symbol-function
'denote-link-add-links))
+;;;###autoload
+(defun denote-link-add-missing-links (regexp &optional id-only)
+ "Insert missing links to all notes matching REGEXP.
+Similar to `denote-link-add-links' but insert only links not yet
+present in the current buffer.
+
+Optional ID-ONLY has the same meaning as in `denote-link': it
+inserts links with just the identifier."
+ (interactive
+ (list
+ (read-regexp "Insert links matching REGEX: " nil
'denote-link--add-links-history)
+ current-prefix-arg))
+ (let* ((current-file (buffer-file-name))
+ (current-id (denote-link--file-type-regexp current-file))
+ (linked-files (denote-link--expand-identifiers current-id)))
+ (if-let* ((found-files (delete current-file
+ (denote-directory-files-matching-regexp
regexp)))
+ (final-files (seq-difference found-files linked-files)))
+ (let ((beg (point)))
+ (insert (denote-link--prepare-links final-files current-file
id-only))
+ (unless (derived-mode-p 'org-mode)
+ (denote-link-buttonize-buffer beg (point))))
+ (user-error "No links matching `%s' that aren't yet present in the
current buffer." regexp))))
+
;;;;; Links from Dired marks
;; NOTE 2022-07-21: I don't think we need a history for this one.
- [elpa] externals/denote updated (9b969da55c -> 2c2eb5d9e7), ELPA Syncer, 2022/09/30
- [elpa] externals/denote faa7a66771 3/7: Acknowledge Elias Storms for commit 6bf916b, ELPA Syncer, 2022/09/30
- [elpa] externals/denote 4a3d3e5c5e 5/7: Don't check for Org when buttonizing, ELPA Syncer, 2022/09/30
- [elpa] externals/denote 6bf916b03e 1/7: Add denote-link-add-missing-links,
ELPA Syncer <=
- [elpa] externals/denote 89d324b28f 2/7: Merge pull request #108 from EFLS/missing-links, ELPA Syncer, 2022/09/30
- [elpa] externals/denote 27e5ed7e0c 6/7: Remove full stop to placate the compiler, ELPA Syncer, 2022/09/30
- [elpa] externals/denote 2c2eb5d9e7 7/7: Tweak wording for docs on adding missing links, ELPA Syncer, 2022/09/30
- [elpa] externals/denote 5eee3489c9 4/7: Remove extra let from denote-link-add-missing-links, ELPA Syncer, 2022/09/30