summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2016-09-21 23:51:11 -0400
committerKyle Meyer <kyle@kyleam.com>2016-09-21 23:51:11 -0400
commit07a3c384b42b2e9ab8bdbd9bf7bdf67c0f8d293c (patch)
treec88ef273f843081b5650047bd07510babf03d01b
parenta8ba6e87e3712c264c4687b26bccdfd66d8c9ccb (diff)
downloademacs.d-07a3c384b42b2e9ab8bdbd9bf7bdf67c0f8d293c.tar.gz
Add org-agenda-refile-dwim command
-rw-r--r--init.el1
-rw-r--r--lisp/km-org.el13
2 files changed, 14 insertions, 0 deletions
diff --git a/init.el b/init.el
index e73b2c1..9c4798d 100644
--- a/init.el
+++ b/init.el
@@ -269,6 +269,7 @@
;; Bind `org-agenda-follow-mode' to same key as
;; `next-error-follow-minor-mode'.
("C-c C-f" . org-agenda-follow-mode)
+ ("C-c C-w" . km/org-agenda-refile-dwim)
("C-o" . org-agenda-show-and-scroll-up)
;; Free up 'j' for `km/org-agenda-avy-goto-subword-1'.
("C-j" . org-agenda-goto-date)))
diff --git a/lisp/km-org.el b/lisp/km-org.el
index b1cd833..29df941 100644
--- a/lisp/km-org.el
+++ b/lisp/km-org.el
@@ -514,6 +514,19 @@ A target is determined by `km/org-refile-dwim-target-file'."
org-refile-targets)))
(call-interactively #'org-refile)))
+(defun km/org-agenda-refile-dwim ()
+ "Rebind `org-agenda-refile-targets' if next window is an Org buffer.
+A target is determined by `km/org-refile-dwim-target-file'."
+ (interactive)
+ (let* ((dwim-target (km/org-refile-dwim-target-file))
+ (org-refile-targets (if dwim-target
+ `((nil
+ :maxlevel . ,km/org-refile-dwim-maxlevel)
+ (dwim-target
+ :maxlevel . ,km/org-refile-dwim-maxlevel))
+ org-refile-targets)))
+ (call-interactively #'org-agenda-refile)))
+
(defun km/org-refile-dwim-target-file ()
"Return next window that is an Org buffer."
(let* ((from-buffer (current-buffer))