In an emacs -Q, create an Org buffer with the following contents: --8<---------------cut here---------------start------------->8--- * AB ** C --8<---------------cut here---------------end--------------->8---
Fold the subtree under the heading AB, so that only a single line is displayed (ending in "..."). With point between A and B, hit C-S-<backspace> (kill-whole-line). Expected: The whole _visible_ line, i.e., the entire contents of the buffer is erased. Actual behavior: The line with heading C remains. Contrast this with the same experiment, except that the point is at the beginning of the line containing AB when hitting C-S-<backspace>. Then the expected behavior happens. According to the source of kill-whole-line, the intended effect indeed is to kill a whole _visible_ line. The following patch to the Emacs sources fixes the issue: diff --git a/lisp/simple.el b/lisp/simple.el index abd587245fe..44221f3fc24 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -6649,9 +6649,7 @@ kill-whole-line (unless (bobp) (backward-char)) (point)))) (t - (save-excursion - (kill-region (point) (progn (forward-visible-line 0) (point)))) - (kill-region (point) + (kill-region (save-excursion (forward-visible-line 0) (point)) (progn (forward-visible-line arg) (point)))))) (defun forward-visible-line (arg) The reason for the issue probably is: Without the patch, the killing happens in two stages. The first kill-region kills from the beginning of the line until after the A. That kills the leading *. That probably somehow triggers Org visibility changes. With the patch applied the whole killing happens in one stage, probably without causing an intermediate change of visibility. I first reported this to bug-gnu-em...@gnu.org (see https://debbugs.gnu.org/65734). However, Eli asks: > I'm not sure I understand why this is deemed a problem in Emacs. > Shouldn't Org redefine C-S-<backspace> if the default binding doesn't > suit what happens in Org buffers? Did you discuss this with Org > developers? Emacs : GNU Emacs 29.1.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.17.8) of 2023-09-04 Package: Org mode version 9.6.8 (release_9.6.8-3-g21171d @ /home/w/usr/emacs/0/29/0/lisp/org/)