2

I often use the capture-refile-archive structure of org-mode but I have problem with the way the refiling works. I use IDO completion so that when I refile a tree C-c C-w I get all the possible trees to refile under in the mini-buffer.

However, this results in a huge number of possible completions that really aren't very readable. It would be far better if you could choose a refile file location and then use the org-goto-interface temporary buffer to choose a particular subtree.

Does anybody know how this could be done?

oLas
  • 1,171
  • 1
  • 9
  • 17

2 Answers2

4

Perhaps the settings you are looking for are

(setq org-refile-use-outline-path 'file)
(setq org-outline-path-complete-in-steps t)

org-refile-use-outline-path lets you give the refile targets as paths (file.org/heading/subheading) and org-outline-path-complete-in-steps will pause after competing each stage of the path. Start refiling, type the path and press [tab] to get a list of all the top level headlines. Continue to the location you want.

erikstokes
  • 1,197
  • 6
  • 15
  • 1
    This is exactly what I was hoping for. Its a shame that it doesn't work with the `org-completion-use-ido` – oLas Nov 11 '14 at 15:14
0

You can do this by setting org-refile-targets before running org-refile. For example, I've described doing this for selecting and refiling to Org files that aren't in the global org-refile-targets. That was focused on having functions other than org-refile to handle special cases, but if you wanted org-refile to always ask for a buffer or file to refile to, you could advise org-refile to override org-refile-targets or you could set org-refile-targets to a function that returns a selected buffer.

(defun km/get-open-org-file ()
  (buffer-file-name
   (get-buffer
    (org-icompleting-read "Buffer: "
                          (mapcar 'buffer-name
                                  (org-buffer-list 'files))))))

(setq org-refile-targets '((km/get-open-org-file . (:maxlevel . 2))))

How exactly you set up org-refile-targets depends a lot on your work flow and structure for notes, but those examples hopefully give you an idea of how you can get things working the way you want.

Kyle Meyer
  • 1,546
  • 9
  • 10
  • That is a helpful start for determining how to show the refile targets before refiling but I'm not particularly interested in having dynamic refile locations. The larger problem that I would like to solve is using the `org-goto-interface` to select a subtree to refile to. – oLas Oct 31 '14 at 15:25
  • Perhaps this functionality doesn't exist, if not, I might try and implement it but I thought it was worth asking. – oLas Oct 31 '14 at 15:25
  • Sorry, looking back at that, my answer focused on "choose a refile file location" and ignored the clear focus on using `org-goto-interface`. I don't think that functionality exists. It might be tricky to implement because `org-goto` relies on `org-refile` underneath. – Kyle Meyer Oct 31 '14 at 19:35