[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 3b62f8e167 043/355: Implement denote-link-clear-
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 3b62f8e167 043/355: Implement denote-link-clear-stale-backlinks |
Date: |
Sun, 26 Jun 2022 23:57:58 -0400 (EDT) |
branch: externals/denote
commit 3b62f8e167f3b0f4d57cffc91f99bcab24103cf0
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Implement denote-link-clear-stale-backlinks
---
denote-link.el | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/denote-link.el b/denote-link.el
index c0875cf463..4c2674aac6 100644
--- a/denote-link.el
+++ b/denote-link.el
@@ -66,7 +66,10 @@ Both are supplied by `denote-link'."
"Format of Org link to note.")
(defconst denote-link--backlink-format "[[denote:%s][backlink: %s (%s)]]"
- "Format of Org link to note.")
+ "Format of Org backlink to note.")
+
+(defconst denote-link--backlink-regexp "\\[\\[denote:\\(.*?\\)\\]\\[backlink:
\\(.*?\\) (\\(.*?\\))\\]\\]"
+ "Regexp of `denote-link--backlink-format'.")
(defun denote-link--retrieve-value (note regexp)
"Return REGEXP value from NOTE."
@@ -100,9 +103,6 @@ Run `denote-link-insert-functions' afterwards."
(insert target-link)
(run-hook-with-args 'denote-link-insert-functions target origin-link)))
-;; TODO 2022-06-07: have a `denote-unlink' command or a
-;; `denote-clean-backlinks' for invalid links.
-
(defconst denote-link-backlink-heading "Denote backlinks"
"String of the backlink's heading.
This heading is appended to a file when another links to it.")
@@ -125,5 +125,16 @@ This heading is appended to a file when another links to
it.")
(delete-duplicate-lines heading-point (point-max) nil nil t)
(widen)))))
+(defun denote-link-clear-stale-backlinks ()
+ "Delete backlinks that no longer point to files."
+ (interactive)
+ (let ((default-directory (denote--directory)))
+ (save-excursion
+ (goto-char (point-min))
+ (when (re-search-forward denote-link-backlink-heading nil t))
+ (while (re-search-forward denote-link--backlink-regexp nil t)
+ (unless (file-exists-p (match-string-no-properties 1))
+ (delete-line))))))
+
(provide 'denote-link)
;;; denote-link.el ends here
- [elpa] externals/denote 251b35d8f5 003/355: Add GPL, (continued)
- [elpa] externals/denote 251b35d8f5 003/355: Add GPL, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 2aed386b84 006/355: Add denote-org-capture (WORK-IN-PROGRESS), ELPA Syncer, 2022/06/26
- [elpa] externals/denote 0e2cc10fe6 009/355: Improve integration with org-capture-templates, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 1079beb858 017/355: Add todo about file deletion post org-capture, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 27642bee14 026/355: Clarify 'denote' doc string, ELPA Syncer, 2022/06/26
- [elpa] externals/denote ec3847607b 028/355: Remove to-do about file name format, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 7fe66f43d4 030/355: Remove needless outline and empty line, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 550428cabf 037/355: Add sample org-capture-templates to Commentary, ELPA Syncer, 2022/06/26
- [elpa] externals/denote efd5135835 039/355: Improve linking functionality, ELPA Syncer, 2022/06/26
- [elpa] externals/denote a34ca52fbf 040/355: Fix regression in M-x denote, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 3b62f8e167 043/355: Implement denote-link-clear-stale-backlinks,
ELPA Syncer <=
- [elpa] externals/denote d57ff29c3b 045/355: Add denote--file-regexp, ELPA Syncer, 2022/06/26
- [elpa] externals/denote de00f939d3 048/355: Fix typo, ELPA Syncer, 2022/06/26
- [elpa] externals/denote bf342a1d39 057/355: Correct factual statement about command args, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 9bf10437e0 058/355: Add denote-front-matter-date-format user option, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 96eee4aeba 068/355: Change placement of findex keyword in the manual, ELPA Syncer, 2022/06/26
- [elpa] externals/denote d09b748c8d 063/355: Fix fontification; add denote-dired-directories, ELPA Syncer, 2022/06/26
- [elpa] externals/denote f8ea03abfb 067/355: Add documentation about renaming non-notes, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 431124fea1 060/355: Generalise dired fontification, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 147901f971 072/355: Rename 'denote--directory' to 'denote-directory', ELPA Syncer, 2022/06/26
- [elpa] externals/denote a5120e0e93 061/355: Enable optional EXTENSION in file name creation, ELPA Syncer, 2022/06/26