diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2015-01-30 10:23:47 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2015-01-30 10:23:47 +0100 |
commit | a1116aa54ee4befd8fa52e3f92207db200ebfd59 (patch) | |
tree | ab21eabb2d84be4fd72bfbded0b907c9d3d4a5dc | |
parent | 31e7634779a6e5806e86bb9f884c34d49dd229ee (diff) | |
download | org-mode-a1116aa54ee4befd8fa52e3f92207db200ebfd59.tar.gz |
Fix `org-agenda-insert-diary-make-new-entry'
* lisp/org-agenda.el (org-agenda-insert-diary-make-new-entry): Ensure
point is at a real body line and not in front of meta data, so
regular contents can be inserted safely after a call to this
function.
Reported-by: Samuel Loury <konubinix@gmail.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/94482>
-rw-r--r-- | lisp/org-agenda.el | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index ad4018d..3476a25 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -9488,27 +9488,30 @@ a timestamp can be added there." (defun org-agenda-insert-diary-make-new-entry (text) "Make a new entry with TEXT as the first child of the current subtree. -Position the point in the line right after the new heading so -that a timestamp can be added there." - (let ((org-show-following-heading t) - (org-show-siblings t) - (org-show-hierarchy-above t) - (org-show-entry-below t) - col) - (outline-next-heading) - (org-back-over-empty-lines) - (or (looking-at "[ \t]*$") - (progn (insert "\n") (backward-char 1))) - (org-insert-heading nil t) - (org-do-demote) - (setq col (current-column)) - (insert text "\n") - (if org-adapt-indentation (org-indent-to-column col)) - (let ((org-show-following-heading t) - (org-show-siblings t) - (org-show-hierarchy-above t) - (org-show-entry-below t)) - (org-show-context)))) +Position the point in the heading's first body line so that +a timestamp can be added there." + (let (col) + (org-with-wide-buffer + (outline-next-heading) + (org-back-over-empty-lines) + (or (looking-at "[ \t]*$") + (progn (insert "\n") (backward-char 1))) + (org-insert-heading nil t) + (org-do-demote) + (setq col (current-column)) + (insert text) + (forward-line) + (when (org-looking-at-p org-planning-line-re) (forward-line)) + (when (looking-at org-property-drawer-re) + (goto-char (match-end 0)) + (forward-line)) + (unless (bolp) (insert "\n")) + (when org-adapt-indentation (org-indent-to-column col)) + (let ((org-show-following-heading t) + (org-show-siblings t) + (org-show-hierarchy-above t) + (org-show-entry-below t)) + (org-show-context))))) (defun org-agenda-diary-entry () "Make a diary entry, like the `i' command from the calendar. |