From 1d4c79d41525113f9e43b82dc9b24d353dc311bd Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Mon, 2 Feb 2015 18:19:30 +0100 Subject: [PATCH] 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 --- lisp/org-agenda.el | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 164e2d53a..3b67075a6 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -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. -- 2.11.4.GIT