[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote efd5135835 039/355: Improve linking functionalit
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote efd5135835 039/355: Improve linking functionality |
Date: |
Sun, 26 Jun 2022 23:57:57 -0400 (EDT) |
branch: externals/denote
commit efd5135835e4d7a9d1dbe4ae9ed75bd30c094fd2
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Improve linking functionality
* Add a backlinks' heading.
* Delete duplicate links.
---
denote-link.el | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/denote-link.el b/denote-link.el
index bb16594ca7..8273da23cd 100644
--- a/denote-link.el
+++ b/denote-link.el
@@ -79,7 +79,7 @@ Both are supplied by `denote-link'."
(defun denote-link--read-file-prompt ()
"Prompt for regular file in `denote-directory'."
(read-file-name "Select note: " (denote--directory)
- nil t nil #'file-regular-p))
+ nil t nil #'file-regular-p)) ; Includes backup files. Maybe
we can remove them?
;;;###autoload
(defun denote-link (target)
@@ -101,16 +101,29 @@ Run `denote-link-insert-functions' afterwards."
(insert target-link)
(run-hook-with-args 'denote-link-insert-functions target origin-link)))
-;; NOTE 2022-06-05: A proof-of-concept. We need to: (i) have a
-;; Backlinks heading, (ii) delete duplicates, (iii) ensure one backlink
-;; per line, (iv) have a `denote-unlink' command or a
+;; 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.")
+
(defun denote-link-backlink (target-file origin-link)
"Insert ORIGIN-LINK to TARGET-FILE."
- (let ((default-directory (denote--directory)))
+ (let ((default-directory (denote--directory))
+ (heading denote-link-backlink-heading)
+ heading-point)
(with-current-buffer (find-file-noselect target-file)
(goto-char (point-max))
- (insert origin-link))))
+ (unless (save-excursion (setq heading-point (re-search-backward heading
nil t)))
+ (unless (denote--line-regexp-p 'empty 0)
+ (newline))
+ (insert (format "* %s\n\n" heading)))
+ (insert (format "- %s\n" origin-link))
+ ;; delete duplicate links
+ (unwind-protect
+ (delete-duplicate-lines heading-point (point-max) nil nil t)
+ (widen)))))
(provide 'denote-link)
;;; denote-link.el ends here
- [elpa] externals/denote fa6a3315dc 047/355: Add correct group for org capture specifiers, (continued)
- [elpa] externals/denote fa6a3315dc 047/355: Add correct group for org capture specifiers, ELPA Syncer, 2022/06/26
- [elpa] externals/denote f33f8a7040 053/355: Rewrite README as a manual, ELPA Syncer, 2022/06/26
- [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 <=
- [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, 2022/06/26
- [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