[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote aab21a74dd 194/355: Register 'denote:' custom Or
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote aab21a74dd 194/355: Register 'denote:' custom Org hyperlink type |
Date: |
Sun, 26 Jun 2022 23:58:23 -0400 (EDT) |
branch: externals/denote
commit aab21a74dd213e13adf98b8ad4ba836bdf4ef028
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Register 'denote:' custom Org hyperlink type
---
denote-link.el | 73 ++++++++++++++++++++++++++++++++++++++++------------------
1 file changed, 50 insertions(+), 23 deletions(-)
diff --git a/denote-link.el b/denote-link.el
index 3ae410795c..155380abba 100644
--- a/denote-link.el
+++ b/denote-link.el
@@ -43,6 +43,24 @@
:type 'boolean
:group 'denote-link)
+(defcustom denote-link-register-ol-hyperlink t
+ "When non-nil, register the `denote:' custom Org hyperlink type.
+This practically means that the links Denote creates will behave
+link ordinary links in Org files. They can be followed with a
+mouse click or the `org-open-at-point' command, and they can be
+insterted with completion via the `org-insert-link' command after
+selecting the `denote:' hyperlink type.
+
+When this option is nil, Denote links will not work properly in
+Org files. All commands that Denote defines, such as
+`denote-link-backlinks' and `denote-link-find-file' will work as
+intended.
+
+Note that if you do not want to `require' ol.el, you must set
+this option to nil BEFORE loading denote-link.el."
+ :type 'boolean
+ :group 'denote-link)
+
(defcustom denote-link-backlinks-display-buffer-action
'((display-buffer-reuse-window display-buffer-below-selected)
(window-height . fit-window-to-buffer))
@@ -72,29 +90,6 @@ and/or the documentation string of `display-buffer'."
;;;; Link to note
-;; FIXME 2022-06-14 16:58:24 +0300: Plain text links will use the
-;; identifier only. But for Org we need to figure out a better way of
-;; integrating with Org/Markdown in a standard way. Relying on
-;; org-id.el may be the right course of action for Org. What does
-;; markdown-mode require?
-;;
-;; Whatever we do, we need to consider the implications very carefully.
-;; This is not something we can undo once the package gets its first
-;; stable release.
-;;
-;; My principle is to avoid dependencies as much as possible. The
-;; `denote-link-find-file' exemplifies this idea.
-;;
-;; Discussions on the GitHub mirror:
-;;
-;; * https://github.com/protesilaos/denote/issues/8
-;; * https://github.com/protesilaos/denote/issues/13
-;;
-;; And on the mailing list:
-;;
-;; *
https://lists.sr.ht/~protesilaos/denote/%3C9ac1913b-7e8f-7d38-b547-771861a8d641%40eh-is.de%3E
-;; * https://lists.sr.ht/~protesilaos/denote/%3C87edzvd5oz.fsf%40cassou.me%3E
-
;; Arguments are: FILE-ID FILE-TITLE
(defconst denote-link--format-org "[[denote:%s][%s]]"
"Format of Org link to note.")
@@ -276,5 +271,37 @@ manual for more on the matter)."
(insert (denote-link--prepare-links files ext))
(user-error "No links matching `%s'" regexp))))
+
+;;;; Register `denote:' custom Org hyperlink
+
+(declare-function org-link-set-parameters "ol.el" (type &rest parameters))
+
+;; REVIEW 2022-06-15: Maybe there is a better way to make this optional.
+(when denote-link-register-ol-hyperlink
+ (require 'ol)
+ (org-link-set-parameters
+ "denote"
+ :follow #'denote-link-ol
+ :complete #'denote-link-ol-complete))
+
+(defun denote-link--ol-find-file (identifier)
+ "Visit file with IDENTIFIER.
+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))
+
+(defun denote-link-ol-complete ()
+ "Like `denote-link' but for Org integration.
+This lets the user complete a link through the `org-insert-link'
+interface by first selecting the `denote:' hyperlink type."
+ (insert
+ (denote-link--format-link
+ (denote-retrieve--read-file-prompt)
+ (denote-link--file-type-format (buffer-file-name)))))
+
(provide 'denote-link)
;;; denote-link.el ends here
- [elpa] externals/denote f57e9c5c9f 165/355: Change internal variable symbols for consistency, (continued)
- [elpa] externals/denote f57e9c5c9f 165/355: Change internal variable symbols for consistency, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 8565d36e7d 161/355: Add note in the manual about journal/diary, ELPA Syncer, 2022/06/27
- [elpa] externals/denote be58aec5db 163/355: Include journal sample that prompts for TITLE, ELPA Syncer, 2022/06/27
- [elpa] externals/denote d66312e517 172/355: Fix regression in file extension caused by f57e9c5, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 553c10a9cc 178/355: Tweak doc string, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 8e6e2736dc 174/355: Add generic denote-link-find-file, ELPA Syncer, 2022/06/27
- [elpa] externals/denote b54dd3404d 186/355: Tweak doc string, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 5195f13f55 197/355: Add optional absolute for denote--directory-files, ELPA Syncer, 2022/06/27
- [elpa] externals/denote a160d9f147 196/355: Fix typo in the manual, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 3654f902e6 210/355: Accept optional group in denote-retrieve--search, ELPA Syncer, 2022/06/27
- [elpa] externals/denote aab21a74dd 194/355: Register 'denote:' custom Org hyperlink type,
ELPA Syncer <=
- [elpa] externals/denote 4dc46d1b68 185/355: Set denote-link-fontify-backlinks to t by default, ELPA Syncer, 2022/06/27
- [elpa] externals/denote d5b62c4e58 220/355: Add denote-date command (notes for past date), ELPA Syncer, 2022/06/27
- [elpa] externals/denote f193199c88 228/355: Insert generic format links with prefix argument, ELPA Syncer, 2022/06/27
- [elpa] externals/denote e1c45e25f4 219/355: Optionally no current in files in dir regexp match, ELPA Syncer, 2022/06/27
- [elpa] externals/denote a1d315ff84 237/355: Reword statement about metanotes, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 1ba3ccc7d0 291/355: Add missing conditionality from commit 7074b25, ELPA Syncer, 2022/06/27
- [elpa] externals/denote cea51a8a11 242/355: Add section with Frequently Asked Questions, ELPA Syncer, 2022/06/27
- [elpa] externals/denote a785de6760 244/355: Make sure minibuffer can be resized while renaming, ELPA Syncer, 2022/06/27
- [elpa] externals/denote 6a0cb450c6 303/355: Add section referencing alternative blog posts, ELPA Syncer, 2022/06/27
- [elpa] externals/denote f03d75a72b 268/355: Document tasks/ideas to do/explore, ELPA Syncer, 2022/06/27