[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 941303ee23 2/2: Move helper for Org link to head
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 941303ee23 2/2: Move helper for Org link to heading into denote.el; make adaptations |
Date: |
Tue, 23 Jan 2024 03:58:01 -0500 (EST) |
branch: externals/denote
commit 941303ee23927f88080f3fcbeb5d3021f4975939
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Move helper for Org link to heading into denote.el; make adaptations
---
denote-org-extras.el | 7 ++-----
denote.el | 13 +++++++++----
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/denote-org-extras.el b/denote-org-extras.el
index c4dbbc25ba..260973e46d 100644
--- a/denote-org-extras.el
+++ b/denote-org-extras.el
@@ -86,10 +86,6 @@ See the `:link' property of `denote-file-types'."
heading-id
description))
-(defun denote-org-extras-format-link-get-description (file heading-text)
- "Return link description for FILE with HEADING-TEXT at the end."
- (format "%s::%s" (denote--link-get-description file) heading-text))
-
;;;###autoload
(defun denote-org-extras-link-to-heading ()
"Link to file and then specify a heading to extend the link to.
@@ -115,12 +111,13 @@ To only link to a file, use the `denote-link' command."
(unless (derived-mode-p 'org-mode)
(user-error "Links to headings only work between Org files"))
(when-let ((file (denote-file-prompt ".*\\.org"))
+ (file-text (denote--link-get-description file))
(heading (denote-org-extras--outline-prompt file))
(line (string-to-number (car (split-string heading "\t"))))
(heading-data (denote-org-extras--get-heading-and-id-from-line
line file))
(heading-text (car heading-data))
(heading-id (cdr heading-data))
- (description (denote-org-extras-format-link-get-description file
heading-text)))
+ (description (denote-link-format-heading-description file-text
heading-text)))
(insert (denote-org-extras-format-link-with-heading file heading-id
description))))
;;;; Extract subtree into its own note
diff --git a/denote.el b/denote.el
index 11565c85f4..b9c00f704b 100644
--- a/denote.el
+++ b/denote.el
@@ -4128,6 +4128,10 @@ create a new one."
"Get current Org heading text."
(org-get-heading :no-tags :no-todo :no-priority :no-comment))
+(defun denote-link-format-heading-description (file-text heading-text)
+ "Return description for FILE-TEXT with HEADING-TEXT at the end."
+ (format "%s::%s" file-text heading-text))
+
;;;###autoload
(defun denote-link-ol-store ()
"Handler for `org-store-link' adding support for denote: links.
@@ -4140,10 +4144,11 @@ Also see the user option
`denote-org-store-link-to-heading'."
(let ((heading-links (and denote-org-store-link-to-heading (derived-mode-p
'org-mode))))
(org-link-store-props
:type "denote"
- :description
- (if heading-links
- (format "%s::%s" file-title (denote-link-ol-get-heading))
- file-title)
+ :description (if heading-links
+ (denote-link-format-heading-description
+ (denote--link-get-description file)
+ (denote-link-ol-get-heading))
+ file-title)
:link (if heading-links
(format "denote:%s::#%s" file-id (denote-link-ol-get-id))
(concat "denote:" file-id)))