[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 0f11e93f25 9/9: Add user option denote-open-link
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 0f11e93f25 9/9: Add user option denote-open-link-function for non-Org buffers |
Date: |
Tue, 26 Nov 2024 06:57:52 -0500 (EST) |
branch: externals/denote
commit 0f11e93f25c99a7325ae3ab4db93c58dd50c1de7
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Add user option denote-open-link-function for non-Org buffers
---
README.org | 18 ++++++++++++++++++
denote.el | 35 +++++++++++++++++++++++++----------
2 files changed, 43 insertions(+), 10 deletions(-)
diff --git a/README.org b/README.org
index 7d1e50cf18..fbad80f622 100644
--- a/README.org
+++ b/README.org
@@ -2751,6 +2751,24 @@ like an ordinary link by default. This is just a
convenience for the
user/theme in case they want =denote:= links to remain distinct from
other links.
+** The ~denote-open-link-function~ user option
+:PROPERTIES:
+:CUSTOM_ID: h:6aa22a2d-3338-433e-ab9f-ba272417aab9
+:END:
+
+[ This is part of {{{development-version}}}. ]
+
+#+vindex: denote-open-link-function
+The user option ~denote-open-link-function~ specifies the function
+used by Denote to open the file of a link. The default value opens the
+file in the other window. Another common value is the function
+~find-file~, which will open the file in the current window. Users may
+also specify a function of their choosing.
+
+Note that this is relevant in buffers other than Org mode because Org
+has its own mechanism for how to open links (read the documentation of
+the command ~org-open-at-point~).
+
** The ~denote-org-store-link-to-heading~ user option
:PROPERTIES:
:CUSTOM_ID: h:d99de1fb-b1b7-4a74-8667-575636a4d6a4
diff --git a/denote.el b/denote.el
index c21f9423cf..1b08dae15b 100644
--- a/denote.el
+++ b/denote.el
@@ -874,6 +874,27 @@ have been warned."
'denote-file-name-slug-functions
"2.3.0")
+(define-obsolete-variable-alias
+ 'denote-link-button-action
+ 'denote-open-link-function
+ "3.2.0")
+
+(defcustom denote-open-link-function #'find-file-other-window
+ "Function to find the file of a Denote link.
+
+The default value is `find-file-other-window', with `find-file' because
+another common option. Users can provide a custom function which
+behaves like the other two.
+
+This is used in all non-Org buffers that have a link created by Denote.
+Org has its own mechanism, which you can learn more about by reading the
+documentation of the `org-open-at-point' command."
+ :group 'denote
+ :type '(choice (function :tag "Other window" find-file-other-window)
+ (function :tag "Current window" find-file)
+ (function :tag "Custom function"))
+ :package-version '(denote . "3.2.0"))
+
(define-obsolete-variable-alias
'denote-link-description-function
'denote-link-description-format
@@ -4681,12 +4702,6 @@ file's title. This has the same meaning as in
`denote-link'."
;;;;; Link buttons
-;; NOTE 2022-06-15: I add this as a variable for advanced users who may
-;; prefer something else. If there is demand for it, we can make it a
-;; defcustom, but I think it would be premature at this stage.
-(defvar denote-link-button-action #'find-file-other-window
- "Display buffer action for Denote buttons.")
-
(defun denote-link--find-file-at-button (button)
"Visit file referenced by BUTTON."
(let* ((id (denote-extract-id-from-string
@@ -4694,7 +4709,7 @@ file's title. This has the same meaning as in
`denote-link'."
(button-start button)
(button-end button))))
(file (denote-get-path-by-id id)))
- (funcall denote-link-button-action file)))
+ (funcall denote-open-link-function file)))
(make-obsolete
'denote-link-buttonize-buffer
@@ -4705,7 +4720,7 @@ file's title. This has the same meaning as in
`denote-link'."
"Function to open Denote file present in LINK.
To be assigned to `markdown-follow-link-functions'."
(when (ignore-errors (string-match denote-id-regexp link))
- (funcall denote-link-button-action
+ (funcall denote-open-link-function
(denote-get-path-by-id (match-string 0 link)))))
(eval-after-load 'markdown-mode
@@ -4730,7 +4745,7 @@ To be assigned to `markdown-follow-link-functions'."
(mouse-set-point ev)
(if-let* ((id (get-text-property (point) 'denote-link-id))
(path (denote-get-path-by-id id)))
- (funcall denote-link-button-action path)
+ (funcall denote-open-link-function path)
(error "Cannot resolve the link at point")))
(defun denote-fontify-links (&optional limit)
@@ -4840,7 +4855,7 @@ major mode is not `org-mode' (or derived therefrom).
Consider using
(defun denote-link--backlink-find-file (button)
"Action for BUTTON to `find-file'."
- (funcall denote-link-button-action
+ (funcall denote-open-link-function
(concat (denote-directory)
(buffer-substring (button-start button) (button-end
button)))))
- [elpa] externals/denote updated (66124eb234 -> 0f11e93f25), ELPA Syncer, 2024/11/26
- [elpa] externals/denote 86c19b4114 1/9: Rework denote-rename-file-using-front-matter to handle all components, ELPA Syncer, 2024/11/26
- [elpa] externals/denote 0792229eed 3/9: Fix issue in denote-rewrite-front-matter with lines that are unchanged, ELPA Syncer, 2024/11/26
- [elpa] externals/denote bf07d3f075 8/9: Merge pull request #484 from jeanphilippegg/denote-rename-file-using-front-matter, ELPA Syncer, 2024/11/26
- [elpa] externals/denote cf35f02d47 2/9: Fix issue in denote--get-final-components-for-rewrite, ELPA Syncer, 2024/11/26
- [elpa] externals/denote 1f123e1440 6/9: Remove lines with empty values in denote--format-front-matter, ELPA Syncer, 2024/11/26
- [elpa] externals/denote 6caa664518 7/9: Remove reference to denote-link-add-links, ELPA Syncer, 2024/11/26
- [elpa] externals/denote 9426f780e4 4/9: Move code in denote--rename-file, ELPA Syncer, 2024/11/26
- [elpa] externals/denote 0f11e93f25 9/9: Add user option denote-open-link-function for non-Org buffers,
ELPA Syncer <=
- [elpa] externals/denote e8e97ccaa8 5/9: Add denote-front-matter-components-present-even-if-empty-value, ELPA Syncer, 2024/11/26