Skip to content

Instantly share code, notes, and snippets.

@samspills
Last active February 23, 2024 08:58
Show Gist options
  • Save samspills/895c29a1c0f6bf2e66c23149bfcc0f38 to your computer and use it in GitHub Desktop.
Save samspills/895c29a1c0f6bf2e66c23149bfcc0f38 to your computer and use it in GitHub Desktop.
Org refile and leave a link behind
@gvoysey
Copy link

gvoysey commented Jul 29, 2020

hi! I think org-id-link-to-use-id is named org-id-link-to-org-use-id now (i'm running 9.3.7 at the moment).

When i update that, i get a curious situation where what actually happens on refile is kind of the inverse of what you describe here: a backlink to the original subtree location is created at the refile point, not the other way around.

Have you encountered this?

@samspills
Copy link
Author

Sorry I know this is two years too late, but I have not encountered this. Using the following:

(defun org-refile--insert-link ( &rest _ )              
  (unless (string-suffix-p "inbox.org" buffer-file-name)
    (org-back-to-heading)                               
    (let* ((refile-region-marker (point-marker))        
           (source-link (org-store-link nil)))          
      (org-insert-heading)                              
      (insert source-link)                              
      (goto-char refile-region-marker))))               
(advice-add 'org-refile                                 
            :before                                     
            #'org-refile--insert-link)                  

with org version 9.6 (running in doomemacs (updated yesterday), on emacs 27.2), everything is working as expected.

@terxw
Copy link

terxw commented Nov 7, 2022

hi! I think org-id-link-to-use-id is named org-id-link-to-org-use-id now (i'm running 9.3.7 at the moment).

When i update that, i get a curious situation where what actually happens on refile is kind of the inverse of what you describe here: a backlink to the original subtree location is created at the refile point, not the other way around.

Have you encountered this?

yes, i have encountered exactly this, trying to figure it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment