[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
org-cut-subtree should respect org-ctrl-k-protect-subtree
From: |
Dan Drake |
Subject: |
org-cut-subtree should respect org-ctrl-k-protect-subtree |
Date: |
Tue, 27 Aug 2024 08:10:28 -0500 |
I customized org-ctrl-k-protect subtree so that when point is on a
headline for an entry with some folded content, ctrl-k asks for
confirmation first.
However, I also have the "k" speed key set up; to me, doing ctrl-K and
the "k" speed key are the same, but only ctrl-K respects the "protect
subtree" variable.
I took at look at the source code, and it seems like a trivial change
to make these two things act consistently: by default, the "k" speed
key calls org-cut-subtree. I copied over the "when" snippet from
org-kill-line (which is what ctrl-K ends up calling), and this seems
to work as expected:
(defun org-cut-subtree (&optional n)
"Cut the current subtree into the clipboard.
With prefix arg N, cut this many sequential subtrees.
This is a short-hand for marking the subtree and then cutting it."
(interactive "p")
(when (and (org-invisible-p (line-end-position))
org-ctrl-k-protect-subtree
(or (eq org-ctrl-k-protect-subtree 'error)
(not (y-or-n-p "Kill hidden subtree along with headline? "))))
(user-error
(substitute-command-keys
"`\\[org-kill-line]' aborted as it would kill a hidden subtree")))
(org-copy-subtree n 'cut))
Could this change be included in org?
--
Ceci n'est pas une .signature.
- org-cut-subtree should respect org-ctrl-k-protect-subtree,
Dan Drake <=