Browse Source

Improve behvior of org-insert-heading to end of subtree

* lisp/org.el (org-insert-heading): Improve whitespace behavior at
end of subtree.

In a subtree with lots of empty space at the end, until now the new
entry would be inserted after all that whitespace.  Now, it is
inserted closer to the existing text, and the whitespace remains after
the new headline.
Carsten Dominik 11 years ago
parent
commit
cf6e54e90b
1 changed files with 3 additions and 0 deletions
  1. 3 0
      lisp/org.el

+ 3 - 0
lisp/org.el

@@ -7629,6 +7629,9 @@ This is important for non-interactive uses of the command."
 	  ;; If we insert after content, move there and clean up whitespace
 	  (when respect-content
 	    (org-end-of-subtree nil t)
+	    (skip-chars-backward " \r\n")
+	    (and (looking-at "[ \t]+") (replace-match ""))
+	    (forward-char 1)
 	    (when (looking-at "^\\*")
 	      (backward-char 1)
 	      (insert "\n")))