Subject: bug#18381: 24.3.93; Diary can wrongly be displayed in Calendar's window

From: Glenn Morris <[email-masked]>
Date: Tue, 09 Sep 2014 14:13:02 -0400

I went with the following.

(I suspect it's going to be like when you press on a bubble in some
wallpaper, and another one pops up somewhere else...)

@@ -901,12 +900,20 @@
                   ;;;     (diary-include-other-diary-files) ; recurse
                   ;;;   (run-hooks 'diary-list-entries-hook))
                   (unless list-only
-                    (if (and diary-display-function
-                             (listp diary-display-function))
-                        ;; Backwards compatibility.
-                        (run-hooks 'diary-display-function)
-                      (funcall (or diary-display-function
-                                   'diary-simple-display))))
+                    ;; Avoid M-x diary; M-x calendar; M-x diary
+                    ;; clobbering the calendar window.
+                    ;; FIXME this is not the right solution.
+                    (let ((display-buffer-fallback-action
+                           (list (delq
+                                  'display-buffer-in-previous-window
+                                  (copy-sequence
+                                   (car display-buffer-fallback-action))))))
+                      (if (and diary-display-function
+                               (listp diary-display-function))
+                          ;; Backwards compatibility.
+                          (run-hooks 'diary-display-function)
+                        (funcall (or diary-display-function
+                                     'diary-simple-display)))))
                   (run-hooks 'diary-hook)))))
         (and temp-buff (buffer-name temp-buff) (kill-buffer temp-buff)))
       (or d-incp (message "Preparing diary...done"))