Hi,

a recent discussion brought up the question of how to delete an Org subtree
without modifying the kill ring.

Org already provides org-cut-subtree, but there does not appear to be a
corresponding command for simply deleting a subtree. One workaround is to call
org-cut-subtree and then modify the kill ring afterwards, but that seems
undesirable since the intention is not to kill the subtree in the first place.

Would an org-delete-subtree command be useful in Org core?

Conceptually, a simple implementation could be along these lines:

(defun org-delete-subtree (&optional n)

  "Delete the current subtree without adding it to the kill ring.

With prefix arg N, delete this many sequential subtrees."

  (interactive "p" org-mode)

  ;; Determine the region occupied by N subtrees and delete it

  ;; using `delete-region' instead of `kill-region'.

  ...)

I left out the detailed implementation here deliberately, since org-copy-subtree
already handles a number of details such as sequential subtrees, inline tasks,
and markers, and it may be preferable to share some of that machinery rather
than duplicate it.

The intended distinction would simply be:
* org-cut-subtree: remove the subtree and put it into the kill ring
* org-delete-subtree: remove the subtree without touching the kill ring

Does this sound like functionality that would be appropriate for Org itself?

Best regards,
Michael Hailer




Attachment: publickey - [email protected] - 0x0D521D34.asc
Description: application/pgp-keys

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to