[oni-org] Combine ‘oni-move-subtree-*’ into ‘oni-org-move-subtree’
These two functions do essentially the same thing, but in different directions. This can also be done with one single interactive function. This way there is only one thing to call.
This commit is contained in:
parent
aaa5b89d0a
commit
54e9c9c26f
1 changed files with 21 additions and 17 deletions
|
@ -860,24 +860,28 @@ This is an around advice for ‘org-html--svg-image’ as FUN."
|
||||||
|
|
||||||
;;; Moving subtrees
|
;;; Moving subtrees
|
||||||
|
|
||||||
(defun oni-move-subtree-above ()
|
(defun oni-org-move-subtree (target placement)
|
||||||
(interactive)
|
"Move the subtree at point to TARGET and place it at PLACEMENT.
|
||||||
(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 ()
|
TARGET should be a point or a marker in the current buffer.
|
||||||
(interactive)
|
|
||||||
(let* ((components (org-heading-components))
|
PLACEMENT should be a symbol. If PLACEMENT is above, it'll be
|
||||||
(target (org-refile-get-location "Move subtree below"))
|
placed above TARGET. Otherwise it will be placed below it."
|
||||||
|
(interactive
|
||||||
|
(list (let ((org-refile-targets '((nil :maxlevel . 1)))
|
||||||
|
(org-refile-use-outline-path nil))
|
||||||
|
(org-refile-get-location "Move subtree to:"))
|
||||||
|
(intern (completing-read "Above / Below: " '(above below) nil t))))
|
||||||
|
(save-excursion
|
||||||
|
(let ((heading-level (car (org-heading-components)))
|
||||||
(marker (copy-marker (nth 3 target))))
|
(marker (copy-marker (nth 3 target))))
|
||||||
(org-cut-subtree)
|
(org-cut-subtree)
|
||||||
(goto-char marker)
|
(goto-char marker)
|
||||||
|
(unless (eq placement 'above)
|
||||||
(org-forward-heading-same-level 1)
|
(org-forward-heading-same-level 1)
|
||||||
(when (= (point) (marker-position marker))
|
(when (= (point) (marker-position marker))
|
||||||
(goto-char (point-max)))
|
(goto-char (point-max))))
|
||||||
(org-paste-subtree (car components))))
|
(org-paste-subtree heading-level))))
|
||||||
|
|
||||||
(provide 'oni-org)
|
(provide 'oni-org)
|
||||||
;;; oni-org.el ends here
|
;;; oni-org.el ends here
|
||||||
|
|
Loading…
Add table
Reference in a new issue