Browse Source

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.
Carsten Dominik 12 years ago
parent
commit
65b404427e
1 changed files with 6 additions and 1 deletions
  1. 6 1
      lisp/org.el

+ 6 - 1
lisp/org.el

@@ -7331,7 +7331,12 @@ This is important for non-interactive uses of the command."
 	    (cond
 	    (cond
 	     (org-insert-heading-respect-content
 	     (org-insert-heading-respect-content
 	      (if (not (equal force-heading '(16)))
 	      (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-up-heading-safe)
 		(org-end-of-subtree nil t))
 		(org-end-of-subtree nil t))
 	      (when (featurep 'org-inlinetask)
 	      (when (featurep 'org-inlinetask)