Browse Source

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>
Nicolas Goaziou 10 years ago
parent
commit
1d4c79d415
1 changed files with 15 additions and 18 deletions
  1. 15 18
      lisp/org-agenda.el

+ 15 - 18
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.