summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2013-09-16 08:22:15 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2013-09-16 08:22:15 +0200
commit68b0dba851bf38ca949ce894dfb2ab26ce2cf798 (patch)
treec97a1181519307c09be2cce7e52ea97908fb80a9
parentc5f2ae7c8d2bb4f533f0a04bfab17b0db139a8f4 (diff)
downloadorg-mode-0d2c9eecd5f8ae5122b00f42b330430d77e61441.tar.gz
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.el4
1 files changed, 3 insertions, 1 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 8e970a1..c319c7f 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)