Subject: 30.1.50; [PATCH] Missing blank line when moving outline subtrees with outline-blank-line set to non-nil

From: James Cherti <[email-masked]>
Date: Mon, 24 Mar 2025 09:03:50 -0400

Emacs outline fails to preserve the final blank line after headings
when moving subtrees up or down when the outline-blank-line variable
is set to non-nil.

Attached is a patch that resolves the issue.

Steps to Reproduce:
- Set outline-blank-line to a non-nil value (e.g., t).
- Create an outline with multiple subtrees, ensuring a blank line
between them.
- Move an outline subtree up or down using the appropriate command (M-UP 
or M-DOWN).
- Observe that the moved subtree may not include the final blank line.

Expected Behavior: When moving outline subtrees up or down, Emacs should 
respect the outline-blank-line variable and ensure that the moved 
subtrees retain a blank line.

Actual Behavior: The final blank line is omitted when moving outline 
subtrees, despite outline-blank-line being set to non-nil.

Additional Information: Including a blank line when outline-blank-line 
is non-nil is important to maintain the structure of the document. 
Omitting it could cause subtrees to lose their separation, making the 
outline less readable.

--
James Cherti
GitHub: https://github.com/jamescherti
Website: https://www.jamescherti.com/
From 33de8e27fd90f8aeaf5542d0d0ed77b2bc8aec10 Mon Sep 17 00:00:00 2001
From: James Cherti <[email-masked]>
Date: Thu, 20 Mar 2025 09:01:36 -0400
Subject: [PATCH] outline-move-subtree-down/up: Include blank line when
 outline-blank-line is t

---
 lisp/outline.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/outline.el b/lisp/outline.el
index 1a1c8705ee2..1209b1ce766 100644
--- a/lisp/outline.el
+++ b/lisp/outline.el
@@ -915,7 +915,8 @@ outline-move-subtree-down
 	 ;; move it to, adding a newline if necessary, to ensure these points
 	 ;; are at bol on the line below the subtree.
          (end-point-func (lambda ()
-			   (outline-end-of-subtree)
+			   (let ((outline-blank-line nil))
+			     (outline-end-of-subtree))
 			   (if (eq (char-after) ?\n) (forward-char 1)
 				(if (and (eobp) (not (bolp))) (insert "\n")))
 			   (point)))
--
2.39.5