Fix spacing and cursor position bug caused by `org-insert-property-drawer'release_8.1.2
commit68b0dba851bf38ca949ce894dfb2ab26ce2cf798
authorCarsten Dominik <carsten.dominik@gmail.com>
Mon, 16 Sep 2013 06:22:15 +0000 (16 08:22 +0200)
committerCarsten Dominik <carsten.dominik@gmail.com>
Mon, 16 Sep 2013 06:22:15 +0000 (16 08:22 +0200)
treec97a1181519307c09be2cce7e52ea97908fb80a9
parentc5f2ae7c8d2bb4f533f0a04bfab17b0db139a8f4
Fix spacing and cursor position bug caused by `org-insert-property-drawer'

* lisp/org.el (org-insert-property-drawer): Insert only after space in
current line.

This fixed a bug reported by Mathieu Boespflug, who writes:

> Hi,
>
> consider the following very simple org file:
>
> * TODO Thing1[]
>
> where "[]" marks where the point is. Now if I C-S-RET to insert a new
> TODO heading, I get
>
> * TODO Thing1
> * TODO []
>
> Note that there is a trailing space at the end of the last line, as
> expected. The problem is that if I now press C-c C-x p to set
> a property (any property), then I end up with the following situation:
>
> * TODO Thing1
> * TODO
>  :PROPERTIES:
>  :PROP:     val
>  :END: []
>
> The point is now at the end of the property drawer, rather than where it
> was before. Notice how the trailing whitespace in the heading has
> moreover been moved to after the property drawer.
>
> Expected behaviour:
>
> After C-c C-x p, I expect to get:
>
> * TODO Thing1
> * TODO []
>  :PROPERTIES:
>  :PROP:     val
>  :END:
>
> This is exactly what I get if there is *no trailing whitespace* in the
> TODO heading before hitting C-c C-x p. So it seems that the bug is that
> org-set-property does not deal well with trailing whitespace.
>
> This is a problem because it messes up setting properties by advising
> org-insert-todo-heading, say to set a CREATED property automatically for
> new TODO items.
lisp/org.el