Subject: bug#65734: [BUG] kill-whole-line on folded subtrees [9.6.8 (release_9.6.8-3-g21171d @ /home/w/usr/emacs/0/29/0/lisp/org/)]

From: Eli Zaretskii <[email-masked]>
Date: Thu, 11 Jan 2024 18:44:08 +0200

> From: Ihor Radchenko <[email-masked]>
> Cc: [email-masked], [email-masked], [email-masked],
>  [email-masked], [email-masked]
> Date: Thu, 11 Jan 2024 16:15:13 +0000
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> >> So, I'd like some way to configure `kill-whole-line'/`kill-line' to warn
> >> user about killing hidden text when we detect that we are deleting a
> >> folded heading. Something like:
> >> 
> >>    (y-or-n-p "Kill hidden subtree along with headline? ")
> >> 
> >> I believe that it might be useful in other situations as well. Like in
> >> outline-mode or outline-minor-mode.
> >
> > How would kill-line know that it's about to kill a subtree?  All it
> > knows is that it is killing some invisible text.
> 
> I imagine the following:
> 
> 1. `kill-*-line' function will, by default, test if invisible text of
>    length size is killed and query the user when called interactively.
> 
> 2. Major modes could also set buffer-local `kill-line-query-function'
>    that will return nil when killing should proceed without query or a
>    string with query text.

If the command is only sensitive to invisible text, it could warn
about so-and-so many invisible characters being killed, but it could
not warn about "subtrees", which is what you wanted.  Invisible text
in a buffer could have nothing to do with subtrees, even if the buffer
is under org-mode.