org-agenda: Fix agenda diary corruption

* lisp/org-agenda.el (org-agenda-insert-diary-make-new-entry): Do not
  save excursion or final position is lost.

Reported-by: Gregor Zattler <grfz@gmx.de>
<http://permalink.gmane.org/gmane.emacs.orgmode/94543>
This commit is contained in:
Nicolas Goaziou 2015-02-02 18:19:30 +01:00
parent 2ebb14d746
commit 1d4c79d415
1 changed files with 15 additions and 18 deletions

View File

@ -9498,24 +9498,21 @@ a timestamp can be added there."
"Make a new entry with TEXT as the first child of the current subtree.
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)
(org-end-of-meta-data)
(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)))))
(outline-next-heading)
(org-back-over-empty-lines)
(unless (looking-at "[ \t]*$") (save-excursion (insert "\n")))
(org-insert-heading nil t)
(org-do-demote)
(let ((col (current-column)))
(insert text)
(org-end-of-meta-data)
(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.