diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2013-09-16 08:22:15 +0200 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2013-09-16 08:22:15 +0200 |
commit | 68b0dba851bf38ca949ce894dfb2ab26ce2cf798 (patch) | |
tree | c97a1181519307c09be2cce7e52ea97908fb80a9 | |
parent | c5f2ae7c8d2bb4f533f0a04bfab17b0db139a8f4 (diff) |
Fix spacing and cursor position bug caused by `org-insert-property-drawer'release_8.1.2
* 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.
-rw-r--r-- | lisp/org.el | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lisp/org.el b/lisp/org.el index 8e970a14c..c319c7f12 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -15606,7 +15606,9 @@ formats in the current buffer." (beginning-of-line 1))) (org-skip-over-state-notes) (skip-chars-backward " \t\n\r") - (if (eq (char-before) ?*) (forward-char 1)) + (if (and (eq (char-before) ?*) (not (eq (char-after) ?\n))) + (forward-char 1)) + (goto-char (point-at-eol)) (let ((inhibit-read-only t)) (insert "\n:PROPERTIES:\n:END:")) (beginning-of-line 0) (org-indent-to-column indent) |