all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* org-cut-subtree should respect org-ctrl-k-protect-subtree
@ 2024-08-27 13:10 Dan Drake
  2024-08-27 14:15 ` Rudolf Adamkovič
  2024-09-01 16:20 ` Ihor Radchenko
  0 siblings, 2 replies; 11+ messages in thread
From: Dan Drake @ 2024-08-27 13:10 UTC (permalink / raw)
  To: emacs-orgmode

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.


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-10-20 12:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-27 13:10 org-cut-subtree should respect org-ctrl-k-protect-subtree Dan Drake
2024-08-27 14:15 ` Rudolf Adamkovič
2024-08-28 11:46   ` Dan Drake
2024-08-29 10:39     ` Rudolf Adamkovič
2024-09-01 16:20 ` Ihor Radchenko
2024-09-01 18:49   ` Dan Drake
2024-09-15 12:46     ` Ihor Radchenko
2024-09-17 23:36       ` Dan Drake
2024-10-20 12:46         ` Ihor Radchenko
2024-09-03 23:09   ` Rudolf Adamkovič
2024-09-22 16:35     ` Ihor Radchenko

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.