branch: externals/denote-org
commit 3c95f59c1b9122e15b09f82d9db3902aace73acf
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>
Make denote-org-link-to-heading link to current file when C-u is given
Thanks to Tonus for pointing out that it was impossible to create a
link inside the current file. This was done in issue 17:
<https://github.com/protesilaos/denote-org/issues/17>.
---
README.org | 2 +-
denote-org.el | 31 ++++++++++++++++---------------
2 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/README.org b/README.org
index e2ff5a2a7a..8b4ae18b96 100644
--- a/README.org
+++ b/README.org
@@ -705,7 +705,7 @@ Denote Org is meant to be a collective effort. Every bit
of help matters.
+ Author/maintainer :: Protesilaos Stavrou.
+ Contributions to code or the manual :: Peter Prevos.
-+ Ideas and user feedback :: GCamp6, Matt Nolan.
++ Ideas and user feedback :: GCamp6, Matt Nolan, Tonus.
* GNU Free Documentation License
:PROPERTIES:
diff --git a/denote-org.el b/denote-org.el
index 623b3473f0..e92209b007 100644
--- a/denote-org.el
+++ b/denote-org.el
@@ -115,33 +115,34 @@ Optional FORMAT is the exact link pattern to use."
"As part of making `denote-org' a standalone package")
;;;###autoload
-(defun denote-org-link-to-heading ()
+(defun denote-org-link-to-heading (&optional current-file)
"Link to file and then specify a heading to extend the link to.
-
-The resulting link has the following pattern:
+With optional CURRENT-FILE as a prefix argument, use the current Org
+file as the target. Else prompt for another Org file . The resulting
+link has the following pattern:
[[denote:IDENTIFIER::#ORG-HEADING-CUSTOM-ID]][Description::Heading text]].
-Because only Org files can have links to individual headings,
-limit the list of possible files to those which include the .org
-file extension (remember that Denote works with many file types,
-per the user option `denote-file-type').
+Because only Org files can have links to individual headings, limit the
+list of possible files to those which include the .org file
+extension (remember that Denote works with many file types, per the user
+option `denote-file-type').
-The user option `denote-org-store-link-to-heading'
-determined whether the `org-store-link' function can save a link
-to the current heading. Such links look the same as those of
-this command, though the functionality defined herein is
-independent of it.
+The user option `denote-org-store-link-to-heading' determined whether
+the `org-store-link' function can save a link to the current heading.
+Such links look the same as those of this command, though the
+functionality defined herein is independent of it.
To only link to a file, use the `denote-link' command.
Also see `denote-org-backlinks-for-heading'."
- (declare (interactive-only t))
- (interactive nil org-mode)
+ (interactive "P" org-mode)
(unless (derived-mode-p 'org-mode)
(user-error "Links to headings only work between Org files"))
(let ((context-p (eq denote-org-store-link-to-heading 'context)))
- (when-let* ((file (denote-file-prompt ".*\\.org"))
+ (when-let* ((file (if current-file
+ buffer-file-name
+ (denote-file-prompt ".*\\.org")))
(file-text (denote-get-link-description file))
(heading (denote-org-outline-prompt file))
(line (string-to-number (car (split-string heading "\t"))))