Add support for `org-store-link`. v1 APPLIED

Marc Fargas: 1
 Add support for `org-store-link`.

 1 files changed, 15 insertions(+), 0 deletions(-)

El lun.  5 de sep. 2022,  Protesilaos escribió
Note that this does not affect `org-insert-link` (manually creating
links) where you can still opt for `file:`, `id:` or `denote:`. It only
affects the `org-store-link` system:

- When you call `org-store-link` manually (like you would call it from
  an email viewer, a PDF file or elsewhere)
- When you call `org-capture` which uses the `org-store-link` system to
  make the "origin" available to the capture template.
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~protesilaos/denote/patches/35137/mbox | git am -3
Learn more about email & git

[PATCH] Add support for `org-store-link`. Export this patch


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. 


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 bb134b3..15da94b 100644
--- a/denote.el
+++ b/denote.el
@@ -2371,6 +2371,20 @@ interface by first selecting the `denote:' hyperlink type."
   (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)))
       :type "denote"
       :description file-title
       :link (concat "denote:" file-id)))

(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
@@ -2404,6 +2418,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
Hello Marc and thanks for patch!

[ Also thanks for our discussion on the GitHub issue you linked to! ]