emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/denote dd086b78fc 1/4: Add support for `org-store-link`


From: ELPA Syncer
Subject: [elpa] externals/denote dd086b78fc 1/4: Add support for `org-store-link`.
Date: Mon, 5 Sep 2022 07:57:34 -0400 (EDT)

branch: externals/denote
commit dd086b78fc6e2ae04aecec47cdb1199f25206a5e
Author: Marc Fargas <marc@marcfargas.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Add support for `org-store-link`.
    
    Hi,
    
    Denote, uses the `denote:` link type internally.
    
    This patch adds support for `org-store-link` of denote files meaning
    that you can call `org-store-link` from a note and get a `denote:` link
    instead of the current `file:` link.
    
    The main benefit of a denote link is that it is resilient to renames,
    etc. A file link would brake if the note was ever to be renamed.
    
    As a side benefit, as `org-capture` uses `org-store-link` now you can
    capture tasks on notes with resilient links!
    
    This may seem related to `denote-link-use-org-id` though that one would
    only work with orgmode notes (and, I think, as long as those were
    withing `org-directory` when using `id:` links).
    
    This should work with notes in any format, now `org-capture` works and
    `org-store-link` too.
    
    Best,
    Marc
    
    PS: This closes #104 on Github[1].
    PSS: Second attempt at submitting a patch via git-email ...
    
    [1]: https://github.com/protesilaos/denote/issues/104
    
    Signed-off-by: Marc Fargas <marc@marcfargas.com>
---
 denote.el | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/denote.el b/denote.el
index 2d5adfd642..8dccf117ce 100644
--- a/denote.el
+++ b/denote.el
@@ -2374,6 +2374,20 @@ interface by first selecting the `denote:' hyperlink 
type."
    "denote:"
    (denote--retrieve-filename-identifier (denote--retrieve-read-file-prompt))))
 
+(defun denote-link-ol-store()
+  "Handler for `org-store-link' adding support for denote: links."
+  (when (denote--current-file-is-note-p)
+    (let* ((file (buffer-file-name))
+           (file-type (denote--filetype-heuristics file))
+           (file-id (denote--retrieve-filename-identifier file))
+           (file-title (denote--retrieve-title-or-filename file file-type)))
+      
+      (org-link-store-props
+       :type "denote"
+       :description file-title
+       :link (concat "denote:" file-id)))
+    org-store-link-plist))
+
 (defun denote-link-ol-export (link description format)
   "Export a `denote:' link from Org files.
 The LINK, DESCRIPTION, and FORMAT are handled by the export
@@ -2407,6 +2421,7 @@ backend."
            :follow #'denote-link-ol-follow
            :face #'denote-link-ol-face
            :complete #'denote-link-ol-complete
+           :store #'denote-link-ol-store
            :export #'denote-link-ol-export)))))
 
 ;;;; Glue code for org-capture



reply via email to

[Prev in Thread] Current Thread [Next in Thread]