emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [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/)]
@ 2023-09-04 16:30 Sebastian Miele
  2023-09-05 10:29 ` Ihor Radchenko
  2024-01-09 15:50 ` Ihor Radchenko
  0 siblings, 2 replies; 53+ messages in thread
From: Sebastian Miele @ 2023-09-04 16:30 UTC (permalink / raw)
  To: emacs-orgmode

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-emacs@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/)


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

end of thread, other threads:[~2024-01-12 21:13 UTC | newest]

Thread overview: 53+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-04 16:30 [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/)] Sebastian Miele
2023-09-05 10:29 ` Ihor Radchenko
2023-09-05 11:54   ` bug#65734: " Eli Zaretskii
2023-09-05 15:25     ` Sebastian Miele
2023-09-05 15:50       ` Eli Zaretskii
2023-09-06  8:23         ` Ihor Radchenko
2023-09-06 12:16           ` Eli Zaretskii
2023-09-06 13:30             ` Sebastian Miele
2023-09-07 13:49               ` Ihor Radchenko
2023-09-06  8:30     ` Ihor Radchenko
2023-09-06 12:20       ` Eli Zaretskii
2023-09-07 10:00         ` Ihor Radchenko
2023-09-07 10:19           ` Eli Zaretskii
2023-09-07 10:27             ` Sebastian Miele
2023-09-07 13:43             ` Ihor Radchenko
2023-09-06 15:04       ` Sebastian Miele
2023-09-07 10:03         ` Ihor Radchenko
2023-09-05 14:30   ` Max Nikulin
2023-09-05 15:42     ` Eli Zaretskii
2023-09-05 15:50       ` Ihor Radchenko
2023-09-05 16:02         ` Max Nikulin
2023-09-05 16:12           ` Ihor Radchenko
2023-09-05 16:14         ` Eli Zaretskii
2024-01-07 16:27         ` Stefan Monnier
2024-01-08 12:15           ` Ihor Radchenko
2024-01-08 15:33             ` Stefan Monnier
2024-01-09 14:52               ` Ihor Radchenko
2024-01-09 16:48                 ` Stefan Monnier
2024-01-09 22:21                   ` Ihor Radchenko
2024-01-09 15:47             ` Ihor Radchenko
2024-01-09 16:01               ` Stefan Monnier
2024-01-09 22:33                 ` Ihor Radchenko
2024-01-10  3:08                   ` Stefan Monnier
2024-01-10 12:52                   ` Eli Zaretskii
2024-01-10 13:05                     ` Ihor Radchenko
2024-01-10 13:55                       ` Eli Zaretskii
2024-01-11 15:50                         ` Ihor Radchenko
2024-01-11 16:05                           ` Eli Zaretskii
2024-01-11 16:15                             ` Ihor Radchenko
2024-01-11 16:44                               ` Eli Zaretskii
2024-01-11 18:08                                 ` Ihor Radchenko
2024-01-11 19:19                                   ` Eli Zaretskii
2024-01-12 12:24                                     ` Ihor Radchenko
2024-01-12 12:32                                       ` Eli Zaretskii
2024-01-12 12:39                                         ` Ihor Radchenko
2024-01-12 14:03                                           ` Eli Zaretskii
2024-01-12 14:15                                             ` Ihor Radchenko
2024-01-12 21:09                                   ` Stefan Monnier
2024-01-12 21:16                                     ` Ihor Radchenko
2024-01-10 16:26                       ` Stefan Monnier
2024-01-10 16:39                         ` Eli Zaretskii
2024-01-11 15:44                         ` Ihor Radchenko
2024-01-09 15:50 ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).