From d78ad3f74eda05cedd71cc4c3e8c8604dbfa7e89 Mon Sep 17 00:00:00 2001 From: Protesilaos Date: Tue, 28 Apr 2026 22:56:36 +0300 Subject: [PATCH] Make denote-link-ol-store work in org-capture as well This affects the org-capture specifiers that create a link such as %a and %l. Thanks to jarofromel for bringing this matter to my attention in discussion 702: . --- denote.el | 59 +++++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/denote.el b/denote.el index 20658b0..024c5cb 100644 --- a/denote.el +++ b/denote.el @@ -6985,39 +6985,38 @@ create a new one." (format "%s::%s" file-text heading-text)) ;;;###autoload -(defun denote-link-ol-store (&optional interactive?) +(defun denote-link-ol-store (&optional _interactive?) "Handler for `org-store-link' adding support for denote: links. -Optional INTERACTIVE? is used by `org-store-link'. +Optional INTERACTIVE? is used internally by `org-store-link'. Also see the user option `denote-org-store-link-to-heading'." - (when interactive? - (when-let* ((file (buffer-file-name)) - ((file-regular-p file)) - ((denote-file-is-in-denote-directory-p file)) - ((denote-file-has-denoted-filename-p file)) - (file-id (denote-retrieve-filename-identifier file)) - (description (denote-get-link-description file))) - (let ((heading-links (and denote-org-store-link-to-heading - (derived-mode-p 'org-mode) - (denote--org-capture-link-specifiers-p))) - (heading (denote-link-ol-get-heading))) - (org-link-store-props - :type "denote" - :description (if (and heading-links heading) - (denote-link-format-heading-description - description - heading) - description) - :link (cond - ((when-let* ((id (org-entry-get (point) "CUSTOM_ID"))) - (format "denote:%s::#%s" file-id id))) - ((and heading-links (eq denote-org-store-link-to-heading 'context) heading) - (format "denote:%s::*%s" file-id heading)) - ((and heading-links heading) - (format "denote:%s::#%s" file-id (denote-link-ol-get-id))) - (t - (concat "denote:" file-id)))) - org-store-link-plist)))) + (when-let* ((file (buffer-file-name)) + ((file-regular-p file)) + ((denote-file-is-in-denote-directory-p file)) + ((denote-file-has-denoted-filename-p file)) + (file-id (denote-retrieve-filename-identifier file)) + (description (denote-get-link-description file))) + (let ((heading-links (and denote-org-store-link-to-heading + (derived-mode-p 'org-mode) + (denote--org-capture-link-specifiers-p))) + (heading (denote-link-ol-get-heading))) + (org-link-store-props + :type "denote" + :description (if (and heading-links heading) + (denote-link-format-heading-description + description + heading) + description) + :link (cond + ((when-let* ((id (org-entry-get (point) "CUSTOM_ID"))) + (format "denote:%s::#%s" file-id id))) + ((and heading-links (eq denote-org-store-link-to-heading 'context) heading) + (format "denote:%s::*%s" file-id heading)) + ((and heading-links heading) + (format "denote:%s::#%s" file-id (denote-link-ol-get-id))) + (t + (concat "denote:" file-id)))) + org-store-link-plist))) (defun denote-link--ol-export-get-relative-html (path) "Return relative PATH for Org export purposes.