[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 1a124c2be6 204/355: Make 'denote:' link follow l
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 1a124c2be6 204/355: Make 'denote:' link follow links like 'file:' |
Date: |
Sun, 26 Jun 2022 23:58:24 -0400 (EDT) |
branch: externals/denote
commit 1a124c2be613fb466a78844342819924a891ba4d
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Make 'denote:' link follow links like 'file:'
We want it to behave exactly like the standard 'file:' hyperlink type.
With this change, we made it work with what is described in the manual.
Evaluate:
(info "(org) Search Options")
---
denote-link.el | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/denote-link.el b/denote-link.el
index e7f785d327..ab4a5fe0f8 100644
--- a/denote-link.el
+++ b/denote-link.el
@@ -293,18 +293,29 @@ manual for more on the matter)."
(require 'ol)
(org-link-set-parameters
"denote"
- :follow #'denote-link-ol
+ :follow #'denote-link-ol-follow
:complete #'denote-link-ol-complete))
-(defun denote-link--ol-find-file (identifier)
- "Visit file with IDENTIFIER.
+(declare-function org-link-open-as-file "ol" (path arg))
+
+(defun denote-link-ol-follow (link)
+ "Find file of type `denote:' matching LINK.
+LINK is the identifier of the note, optionally followed by a
+search option akin to that of standard Org `file:' link types.
+Read Info node `(org) Search Options'.
+
Uses the function `denote-directory' to establish the path to the
file."
- (find-file (file-name-completion identifier (denote-directory))))
-
-(defun denote-link-ol (identifier _)
- "Find file of type `denote:' matching IDENTIFIER."
- (funcall #'denote-link--ol-find-file identifier))
+ (let* ((search (and (string-match "::\\(.*\\)\\'" link)
+ (match-string 1 link)))
+ (id (if (and (stringp search) (not (string-empty-p search)))
+ (substring link 0 (match-beginning 0))
+ link))
+ (path (expand-file-name (file-name-completion id (denote-directory))))
+ (target (if (and (stringp search) (not (string-empty-p search)))
+ (concat path "::" search)
+ path)))
+ (org-link-open-as-file target nil)))
(defun denote-link-ol-complete ()
"Like `denote-link' but for Org integration.
- [elpa] externals/denote d90695213c 151/355: Add minor clarifications in the manual, (continued)
- [elpa] externals/denote d90695213c 151/355: Add minor clarifications in the manual, ELPA Syncer, 2022/06/26
- [elpa] externals/denote ce41b421ef 147/355: Update denote-retrieve symbols in denote-link, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 0e75e46b32 138/355: Improve denote-dired-rename-file, ELPA Syncer, 2022/06/26
- [elpa] externals/denote cdb7f554f2 160/355: Remove extra parenthesis from sample configuration, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 88e64be2cb 176/355: Fix plain text link format, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 7fab21926d 183/355: Process 'find' output in denote-retrieve, ELPA Syncer, 2022/06/26
- [elpa] externals/denote ecc7922a77 169/355: BREAKING remove support for hardcoded backlinks, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 49a2932d42 189/355: Implement denote-link-add-links, ELPA Syncer, 2022/06/26
- [elpa] externals/denote a7a0bf0255 207/355: Tweak doc string, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 2338ee4698 181/355: Refine how identifier is retrieved from file names, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 1a124c2be6 204/355: Make 'denote:' link follow links like 'file:',
ELPA Syncer <=
- [elpa] externals/denote a76b7fb0b8 193/355: Make plain text links the same as Org's, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 683180bcfc 206/355: Remove superfluous function and var, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 2e56f06381 201/355: Install aliases for certain commands, ELPA Syncer, 2022/06/26
- [elpa] externals/denote f8b2d44508 203/355: Depend on Emacs 27.2, not 27.1, ELPA Syncer, 2022/06/26
- [elpa] externals/denote a0525a0154 216/355: Do not try front matter rewrite on non-notes, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 74962d17f2 217/355: Improve denote-retrieve error handling, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 5228b1bb17 231/355: Sort 'denote-link-add-links' contents, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 75cf3d31d0 288/355: Accept optional BEG and END for buttonization, ELPA Syncer, 2022/06/26
- [elpa] externals/denote b651200fdf 236/355: Include "hackability" in the manual's overview, ELPA Syncer, 2022/06/26
- [elpa] externals/denote 55140b83f4 275/355: Clarify point about org-roam database, ELPA Syncer, 2022/06/26