From aaa5b89d0ad4bb8be0b42c873ede359e2ed651e8 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sun, 24 Apr 2022 02:53:43 -0700 Subject: [PATCH] [oni-org] Add commands to move subtrees relative to others --- oni-org/oni-org.el | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/oni-org/oni-org.el b/oni-org/oni-org.el index 3948aea..9a728be 100644 --- a/oni-org/oni-org.el +++ b/oni-org/oni-org.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2022.0401.183938 +;; Version: 2022.0424.025154 ;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org org-contrib org-bullets org-edna diminish all-the-icons olivetti mixed-pitch) ;; This program is free software; you can redistribute it and/or modify @@ -858,5 +858,26 @@ This is an around advice for ‘org-html--svg-image’ as FUN." (defalias 'org-dblock-write:oni-project-steps 'oni-org-dblock-write-project-steps) +;;; Moving subtrees + +(defun oni-move-subtree-above () + (interactive) + (let ((target (org-refile-get-location "Move subtree above"))) + (org-cut-subtree) + (goto-char (nth 3 target)) + (org-paste-subtree))) + +(defun oni-move-subtree-below () + (interactive) + (let* ((components (org-heading-components)) + (target (org-refile-get-location "Move subtree below")) + (marker (copy-marker (nth 3 target)))) + (org-cut-subtree) + (goto-char marker) + (org-forward-heading-same-level 1) + (when (= (point) (marker-position marker)) + (goto-char (point-max))) + (org-paste-subtree (car components)))) + (provide 'oni-org) ;;; oni-org.el ends here