From a2a7550591f6a05986f13e6bf1457e55832555e0 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 10 Mar 2009 17:27:10 +0100 Subject: [PATCH] Bugfix: Make sure TODO keyword is inserted at the right position Wanrong Lin writes: > Suppose I have an org file with following lines: > > * Test1 > Test2 > > Now if I put the cursor at the beginning of the "Test2" line and > press "M-S-RET" (Alt-Shift-Return on my machine), I got this: > > * Test1 > * Test2TODO > > The "TODO" keyword was inserted at the end instead of the > beginning of the task text. This seems a bug to me. Yes, this is a bug that occurs in the special case when the heading stars are inserted in front of an existing line. The commit adds code to make sure the correct position is used. --- lisp/ChangeLog | 3 +++ lisp/org.el | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c8ba7dcf9..614d84a36 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2009-03-10 Carsten Dominik + * org.el (org-insert-todo-heading): Make sure the keyword is + inserted at the correct position. + * org-publish.el (org-publish-project-alist) (org-publish-projects, org-publish-org-index): Change default anme for the index of file names to "sitemap.org". diff --git a/lisp/org.el b/lisp/org.el index d136dca20..c94eb8c6a 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5283,7 +5283,9 @@ state (TODO by default). Also with prefix arg, force first state." (run-hook-with-args-until-success 'org-todo-get-default-hook new-mark-x nil) new-mark-x))) - (insert new-mark " ")) + (beginning-of-line 1) + (and (looking-at "\\*+ ") (goto-char (match-end 0)) + (insert new-mark " "))) (when org-provide-todo-statistics (org-update-parent-todo-statistics))))