Closed sthesing closed 1 year ago
Hi @sthesing Thank you for your kind words. My first gut feel is that I will see what I can add to the documentation. I will unlikely add the code to the code base (but this also depends on the demand). I don't think it will be too challenging.
It will be something very similar to what @alejandrogallo has done here.
Thanks for pointing out #159 so me. Sorry that I overlooked that. Any helpful additions to the documentation would be welcome. I fear my current skills in reading elisp code and knowledge of what's under the hood in custom links is not enough to adapt the work of @alejandrogallo. So anything helpful on where to start reading would be much appreciated.
if there is a function in denote that from a denote link gives you the filepath
for the notes file, then you could write, let us suppose that this function is
denote-file-path-from-id
, then
(defun denote-org-transclusion-add (link plist)
(when (string= "denote" (org-element-property :type link))
(let* ((denote-id (org-element-property :path link)) ;; get denote id from denote:<denote-id> link
(file-path (denote-file-path-from-id denote-id)) ;; path resolved by the id
(new-link (with-temp-buffer ;; create a [[file:/path/to/denote/note]] org link
(insert "file:") ;; and store it in 'new-link' variable
(insert file-path)
(beginning-of-buffer)
(org-element-link-parser))))
(org-transclusion-add-org-file new-link plist)))) ;; re-use the org transclusion infrastructure for file: links
(cl-pushnew 'denote-org-transclusion-add ;; register the org transclusion 'plugin'
org-transclusion-add-functions)
I hope this helps you, you just have to find the denote-file-path-from-id
functionality in denote
I hope this helps you, you just have to find the
denote-file-path-from-id
functionality in denote
Wow, thanks @alejandrogallo ! With that explanation, it was very easy to set this up. The function in question is called denote-get-path-by-id
.
So for anyone who came here looking for a solution, this is the complete code:
(defun denote-org-transclusion-add (link plist)
(when (string= "denote" (org-element-property :type link))
(let* ((denote-id (org-element-property :path link)) ;; get denote id from denote:<denote-id> link
(file-path (denote-get-path-by-id denote-id)) ;; path resolved by the id
(new-link (with-temp-buffer ;; create a [[file:/path/to/denote/note]] org link
(insert "file:") ;; and store it in 'new-link' variable
(insert file-path)
(beginning-of-buffer)
(org-element-link-parser))))
(org-transclusion-add-org-file new-link plist)))) ;; re-use the org transclusion infrastructure for file: links
(cl-pushnew 'denote-org-transclusion-add ;; register the org transclusion 'plugin'
org-transclusion-add-functions)
Thanks, @nobiot and @alejandrogallo, this was so very helpful!
(Edit: fixed a quoting issue)
@sthesing does the function you have in your last comment work?
I don’t have capacity to follow the discussion now but I can come back to help you if you have not found a function that works. You can keep the issue open if this is the case.
Yes, it works. Thanks a lot!
Great to hear that. @alejandrogallo Thank you :)
@sthesing glad this worked out! Enjoy!
I hope this helps you, you just have to find the
denote-file-path-from-id
functionality in denoteWow, thanks @alejandrogallo ! With that explanation, it was very easy to set this up. The function in question is called
denote-get-path-by-id
. So for anyone who came here looking for a solution, this is the complete code:(defun denote-org-transclusion-add (link plist) (when (string= "denote" (org-element-property :type link)) (let* ((denote-id (org-element-property :path link)) ;; get denote id from denote:<denote-id> link (file-path (denote-get-path-by-id denote-id)) ;; path resolved by the id (new-link (with-temp-buffer ;; create a [[file:/path/to/denote/note]] org link (insert "file:") ;; and store it in 'new-link' variable (insert file-path) (beginning-of-buffer) (org-element-link-parser)))) (org-transclusion-add-org-file new-link plist)))) ;; re-use the org transclusion infrastructure for file: links (cl-pushnew 'denote-org-transclusion-add ;; register the org transclusion 'plugin' org-transclusion-add-functions)
Thanks, @nobiot and @alejandrogallo, this was so very helpful!
(Edit: fixed a quoting issue)
I'm not sure I know how to use this function. I've pasted it into init.el, but it's not available after buffer evaluation or start-up (when trying to invoke it with M-x). Maybe I'm doing it wrong?
You don't use this function with M-x. This piece of code does two things: define the function and set the function to a hook. Once this is done, you can use the normal command org-transclusion-add
(and its friends) while your cursor is on a denote link.
Well, this makes sense. And it works. Thank you!
Good :) I would appreciate it if you could update Reddit and StackOverflow if it is also by you.
Hey @nobiot,
thanks for this wonderful package!
Any chance of supporting the
denote:
-links of Prot's denote - package?That would be much appreciated.