From 65b404427e1e49c251c45ab4f3587c5f97358436 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Mon, 18 Feb 2013 09:28:05 +0100 Subject: [PATCH] Improve spacing when inserting new headline after end of subtree When using C-RET to insert a new headline, the new headline was inserted after arbitrary amounts of whitespace at the end of the subtree. This whitespace is now shrunk, to avoid unnatural spacing. * lisp/org.el (org-insert-heading): Shrink whitespace at end of subtree when `org-insert-heading-respect-content' is on. --- lisp/org.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 461cdf094..f0d3c61d1 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -7331,7 +7331,12 @@ This is important for non-interactive uses of the command." (cond (org-insert-heading-respect-content (if (not (equal force-heading '(16))) - (org-end-of-subtree nil t) + (progn + (org-end-of-subtree nil t) + (and (looking-at "^\\*") (backward-char 1)) + (while (and (not (bobp)) + (member (char-before) '(?\ ?\t ?\n))) + (backward-delete-char 1))) (org-up-heading-safe) (org-end-of-subtree nil t)) (when (featurep 'org-inlinetask)