branch: externals/embark commit 8fbb20d18938669231d7edaf81d31c9378bb20b2 Author: Omar Antolín <omar.anto...@gmail.com> Commit: Omar Antolín <omar.anto...@gmail.com>
Add embark-org-refile-here action --- embark-org.el | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/embark-org.el b/embark-org.el index dc96e7806d..fa901f552e 100644 --- a/embark-org.el +++ b/embark-org.el @@ -382,6 +382,7 @@ bound to i." "<right>" #'org-do-demote "^" #'org-sort "r" #'org-refile + "R" #'embark-org-refile-here "I" #'org-clock-in "O" #'org-clock-out "a" #'org-archive-subtree-default-with-confirmation @@ -627,5 +628,28 @@ at point, the default action is whatever is bound to RET in (cl-pushnew 'embark-org--at-heading (alist-get cmd embark-around-action-hooks))) +(defun embark-org-refile-here (target) + "Refile the heading at point to TARGET." + (if-let ((marker (get-text-property 0 'org-marker target))) + (with-selected-window + (or (and (derived-mode-p 'org-agenda-mode) + (let ((window (ignore-errors (other-window-for-scrolling)))) + (with-current-buffer (window-buffer window) + (when (derived-mode-p 'org-mode) window)))) + (selected-window)) + (org-refile nil nil + ;; The RFLOC argument: + (list + ;; Name + (org-with-point-at marker + (nth 4 (org-heading-components))) + ;; File + (buffer-file-name (marker-buffer marker)) + ;; nil + nil + ;; Position + marker))) + (user-error "The target is an org heading rather than a reference to one"))) + (provide 'embark-org) ;;; embark-org.el ends here