When in a dired buffer, I use R
or dired-do-rename
to move files from one directory to another (typically my "refile" directory to where the file(s) actually belong(s)).
When I do this I'd like to store an org-link using org-store-link
to the "refiled" document(s) in it's/their new location preferable using th prefix argument, C-u
.
Any idea how to accomplish this? Ideally it would work for a single or multiple files marked with m
. If performing this action on multiple files, all links should be stored.
I imagine this is possible with defadvice
since I can't find any obvious hooks but don't have the experience to implement it.
dired-add-file
is responsible for this. You could advise (yes, I know...) that function to make it log/record the filenames it marks into some dynamically scoped variable. Then you can let-bind that variable around the call to dired-do-rename. Not sure if that is super clean, but I don't know better anyway.