[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 0519be74a9 121/355: Add PROOF-OF-CONCEPT denote-
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 0519be74a9 121/355: Add PROOF-OF-CONCEPT denote-link-backlinks |
Date: |
Sun, 26 Jun 2022 23:58:12 -0400 (EDT) |
branch: externals/denote
commit 0519be74a9e5931471bf4a0248cd44b305a46ce8
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Add PROOF-OF-CONCEPT denote-link-backlinks
---
denote-link.el | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 64 insertions(+), 5 deletions(-)
diff --git a/denote-link.el b/denote-link.el
index c019bde3e0..85f8d13fa1 100644
--- a/denote-link.el
+++ b/denote-link.el
@@ -75,13 +75,17 @@
;;; User options
-(defcustom denote-link-insert-functions
- (list #'denote-link-backlink)
+(defcustom denote-link-insert-functions nil
"Functions that run after `denote-link'.
Each function accepts a TARGET file and a BACKLINK argument.
-Both are supplied by `denote-link'. Advanced users are
-encouraged to study `denote-link-backlink' for how those
-arguments are used."
+Both are supplied by `denote-link'.
+
+Advanced users are encouraged to study `denote-link-backlink' for
+how those arguments are used. Add that function to this hook if
+you want Denote to automatically insert backlinks in the
+applicable files. Though you might prefer to use the command
+`denote-link-backlinks', which does not touch the underlying
+files."
:type 'hook
:group 'denote-link)
@@ -160,6 +164,61 @@ Run `denote-link-insert-functions' afterwards."
(insert link)
(run-hook-with-args 'denote-link-insert-functions target backlink)))
+;;;; Backlinks' buffer (WORK-IN-PROGRESS)
+
+;; (require 'button)
+(define-button-type 'denote-link-find-file
+ 'follow-link t
+ 'action #'denote-link--find-file
+ 'face 'unspecified)
+
+(defun denote-link--find-file (button)
+ "Action for BUTTON."
+ (find-file (buffer-substring (button-start button) (button-end button))))
+
+(declare-function denote-dired-mode "denote-dired")
+
+(defun denote-link--prettify-compilation (buffer _output)
+ "Narrow to grep matches in BUFFER.
+PROOF-OF-CONCEPT."
+ (with-current-buffer buffer
+ (narrow-to-region
+ (progn
+ (re-search-forward "find" nil t)
+ (forward-line 1)
+ (point))
+ (progn
+ (re-search-forward "Grep" nil t)
+ (forward-line -1)
+ (point)))
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward (format "%s" denote--keyword-regexp)
(point-max) t)
+ (make-button (match-beginning 0) (match-end 0) :type
'denote-link-find-file)))
+ (denote-dired-mode 1)))
+
+;;;###autoload
+(defun denote-link-backlinks ()
+ "PROOF-OF-CONCEPT."
+ (interactive)
+ (let* ((default-directory (denote-directory))
+ (file (file-name-nondirectory (buffer-file-name)))
+ (id (denote-link--retrieve-value file denote-link--identifier-regexp))
+ (buf (format "*denote-backlinks to %s*" id)))
+ (compilation-start
+ (format "find * -type f -exec %s --color=auto -l -m 1 -e %s- %s %s"
+ grep-program
+ id
+ (shell-quote-argument "{}")
+ (shell-quote-argument ";"))
+ 'grep-mode
+ (lambda (_) buf)
+ t)
+ (with-current-buffer buf
+ (add-hook 'compilation-finish-functions
#'denote-link--prettify-compilation nil t))))
+
+;;;; Automatic backlink insertion
+
(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.")
- [elpa] externals/denote a611e08ec1 285/355: Clarify that linking still needs some updates, (continued)
- [elpa] externals/denote a611e08ec1 285/355: Clarify that linking still needs some updates, ELPA Syncer, 2022/06/27
- [elpa] externals/denote c3feb9a0ec 250/355: Remove superfluous when, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 662a71d051 330/355: Remove development note about links, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 3b2db33812 322/355: Remove development note about backlinks, ELPA Syncer, 2022/06/27
- [elpa] externals/denote ed75652925 341/355: Remove the ref card from the manual, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 8394280f95 317/355: Refine regexp for front-matter date extraction, ELPA Syncer, 2022/06/27
- [elpa] externals/denote b25235e93e 331/355: Add header links to the mailing list, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 26069e8612 029/355: Add todo about alternative to seq-remove, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 418a21dccb 052/355: Tweak file and defgroup descriptions, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 20a915672e 056/355: Remove interactive-only from 'denote', ELPA Syncer, 2022/06/27
- [elpa] externals/denote 0519be74a9 121/355: Add PROOF-OF-CONCEPT denote-link-backlinks,
ELPA Syncer <=
- [elpa] externals/denote a107fbf5d7 120/355: Make minor tweaks in the manual, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 254a6cd0f3 112/355: Update date function; enforce RFC3339 when needed, ELPA Syncer, 2022/06/27
- [elpa] externals/denote f1f9f757ef 109/355: Include markdown-toml sample in the manual, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 24371b4c86 129/355: fix: Update the identifier regexp to recognize TOML identifier too, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 0cb5c9f06e 122/355: Simplify attribution comment to ox-hugo, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 79fbe2493b 135/355: Merge pull request #11 from kaushalmodi/update-identifier-regexp, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 808a2c29f9 140/355: Acknowledge Peter Povinec for file-naming refinements, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 083b3bfc89 144/355: Use better example for file renaming, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 561553db8e 132/355: fix: Use the correct match subgroup in `denote-link--find-value`, ELPA Syncer, 2022/06/27
- [elpa] externals/denote e1c18f5f57 136/355: Remove potentially bad advice from the manual, ELPA Syncer, 2022/06/27