GNU bug report logs -
#65734
29.1.50; kill-whole-line and visibility of Org subtrees
Previous Next
Reported by: Sebastian Miele <iota <at> whxvd.name>
Date: Mon, 4 Sep 2023 14:49:02 UTC
Severity: normal
Found in version 29.1.50
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> From: Sebastian Miele <iota <at> whxvd.name>
> Date: Mon, 04 Sep 2023 16:44:19 +0200
>
> In an emacs -Q, create an Org buffer with the following contents:
>
> <-----cut-here----->
> * AB
> ** C
> <-----cut-here----->
>
> Fold the subtree under the heading AB, so that only a single line is
> diplayed (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. And according to the source of
> kill-whole-line, the intended effect indeed is to kill a whole _visible_
> line.
>
> The following patch 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'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?
Thanks.
This bug report was last modified 1 year and 19 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.