diff options
-rw-r--r-- | init.el | 1 | ||||
-rw-r--r-- | lisp/km-org.el | 13 |
2 files changed, 14 insertions, 0 deletions
@@ -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)) |