bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#65734: 29.1.50; kill-whole-line and visibility of Org subtrees


From: Eli Zaretskii
Subject: bug#65734: 29.1.50; kill-whole-line and visibility of Org subtrees
Date: Mon, 04 Sep 2023 18:20:46 +0300

> From: Sebastian Miele <iota@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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]