summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2014-04-02 23:17:28 -0400
committerKyle Meyer <kyle@kyleam.com>2014-04-02 23:17:28 -0400
commit2b565eece01a9790635d557da3a32af5308bbb82 (patch)
treeebe590a9e482e440271f209d7929eca760ca1f28
parentb64c9c2f7c82d5179c6afa1db29f857a4013b9d9 (diff)
downloademacs.d-2b565eece01a9790635d557da3a32af5308bbb82.tar.gz
Add commands to refile beyond org-refile-targets
-rw-r--r--lisp/init-org.el34
1 files changed, 34 insertions, 0 deletions
diff --git a/lisp/init-org.el b/lisp/init-org.el
index 3a05016..2418e81 100644
--- a/lisp/init-org.el
+++ b/lisp/init-org.el
@@ -193,4 +193,38 @@ be restored properly."
(setq org-refile-target-verify-function 'km/verify-refile-target)
+(defun km/org-refile-to-other-file (file &optional maxlevel)
+ "Refile with `org-refile-targets' set to FILE.
+A numeric prefix can be given to set MAXLEVEL (defaults to 2)."
+ (interactive "fFile:")
+ (let* ((maxlevel (if current-prefix-arg
+ (prefix-numeric-value current-prefix-arg)
+ 2))
+ (org-refile-targets
+ `((,(substring-no-properties file) :maxlevel . ,maxlevel))))
+ (org-refile)))
+
+(defun km/org-refile-to-other-org-buffer (buffer &optional maxlevel)
+ "Refile with `org-refile-targets' set to BUFFER file name.
+A numeric prefix can be given to set MAXLEVEL (defaults to 2)."
+ (interactive (list
+ (org-icompleting-read "Buffer: "
+ (mapcar 'buffer-name
+ (org-buffer-list 'files)))))
+ (let* ((maxlevel (if current-prefix-arg
+ (prefix-numeric-value current-prefix-arg)
+ 2))
+ (org-refile-targets
+ `((,(substring-no-properties (buffer-file-name (get-buffer buffer)))
+ :maxlevel . ,maxlevel))))
+ (org-refile)))
+
+(eval-after-load 'org
+ '(add-to-list 'org-mode-hook
+ '(lambda ()
+ (local-set-key (kbd "C-c m r")
+ 'km/org-refile-to-other-org-buffer)
+ (local-set-key (kbd "C-c m R")
+ 'km/org-refile-to-other-file))))
+
(provide 'init-org)