summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2013-09-19 04:56:48 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2013-09-19 04:59:09 +0200
commitcf6e54e90bbf2702b7aa5596446993c619604b40 (patch)
tree7ec3f7c7fc3cf9386997d6f32af3d4bce4d09273
parentcc8263a0b32762033516ceacc8f556d7f4eda088 (diff)
downloadorg-mode-cf6e54e90bbf2702b7aa5596446993c619604b40.tar.gz
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.
-rw-r--r--lisp/org.el3
1 files changed, 3 insertions, 0 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 0762696..9aeac40 100644
--- a/lisp/org.el
+++ b/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")))