]> git.eshelyaron.com Git - emacs.git/commitdiff
Sanitize buffer display handling in calendar.el, a first step.
authorMartin Rudalics <rudalics@gmx.at>
Fri, 14 Jan 2011 10:29:40 +0000 (11:29 +0100)
committerMartin Rudalics <rudalics@gmx.at>
Fri, 14 Jan 2011 10:29:40 +0000 (11:29 +0100)
* window.el (window-safely-shrinkable-p): Remove.

* calendar/calendar.el (calendar-generate-window): Only fit a
vertically combined window to its buffer.
(calendar-basic-setup): Call pop-to-buffer, preferably making a
new window at the bottom of the frame.  Remove the
split-height-threshold binding around call of
calendar-list-holidays, this must be handled separately.

lisp/ChangeLog
lisp/calendar/calendar.el
lisp/window.el

index 0bf2d2cdd2193f489306e95d5e2acce04693224f..9a14b52de3e55bc8b669bf17ab5ca081afc39c38 100644 (file)
@@ -1,3 +1,14 @@
+2011-01-14  Martin Rudalics  <rudalics@gmx.at>
+
+       * window.el (window-safely-shrinkable-p): Remove.
+
+       * calendar/calendar.el (calendar-generate-window): Only fit a
+       vertically combined window to its buffer.
+       (calendar-basic-setup): Call pop-to-buffer, preferably making a
+       new window at the bottom of the frame.  Remove the
+       split-height-threshold binding around call of
+       calendar-list-holidays, this must be handled separately.
+
 2011-01-13  Martin Rudalics  <rudalics@gmx.at>
 
        * mail/sendmail.el (sendmail-user-agent-compose): Remove let
index bf520306bbb3261b22bc8f75a81e8cbd017b654f..deaf06bcb39b662022e9070d6bd7b8534c8f4cd6 100644 (file)
@@ -172,6 +172,9 @@ This only affects frames wider than the default value of
                  (integer))
   :version "23.2"
   :group 'calendar)
+(make-obsolete-variable
+ 'calendar-split-width-threshold
+ "customize `display-buffer-alist' instead." "24.1")
 
 (defcustom calendar-week-start-day 0
   "The day of the week on which a week in the calendar begins.
@@ -1295,12 +1298,7 @@ display the generated calendar."
   (let ((buff (current-buffer)))
     (set-buffer (get-buffer-create calendar-buffer))
     (calendar-mode)
-    (let* ((pop-up-windows t)
-           ;; Not really needed now, but means we use exactly the same
-           ;; behavior as before in the non-wide case (see below).
-           (split-height-threshold 1000)
-           (split-width-threshold calendar-split-width-threshold)
-           (date (if arg (calendar-read-date t)
+    (let* ((date (if arg (calendar-read-date t)
                    (calendar-current-date)))
            (month (calendar-extract-month date))
            (year (calendar-extract-year date)))
@@ -1333,27 +1331,26 @@ display the generated calendar."
         ;;
         ;; Is this a wide frame?  If so, split it horizontally.
 
-       ;; FIXME: Adapt to new splitting code.
-        ;; (if (window-sensibly-splittable-p t) (split-window-horizontally))
-        (pop-to-buffer calendar-buffer)
-        ;; Has the window already been split vertically?
-        (when (and (not (window-dedicated-p))
-                   (window-full-height-p))
-          (let ((win (split-window-vertically)))
-            ;; In the upper window, show whatever was visible before.
-            ;; This looks better than using other-buffer.
-            (switch-to-buffer buff)
-            ;; Switch to the lower window with the calendar buffer.
-            (select-window win))))
+       ;; Try to make the new window at the bottom of the frame.  If
+       ;; there's real urgent need, we could also try to split the last
+       ;; full width window on the frame (provided we write a function
+       ;; to do that) and split it into two side-by-side windows with
+       ;; the calendar in the right window.  Hopefully, users will
+       ;; eventually start using the rightmost bottom side window for
+       ;; the calendar.  Using (pop-up-window (bottom . 1000)), for
+       ;; example, in `display-buffer-alist', with (override . t),
+       ;; should do the job.
+       (pop-to-buffer calendar-buffer '((pop-up-window (root . below)))))
       (calendar-generate-window month year)
       (if (and calendar-view-diary-initially-flag
                (calendar-date-is-visible-p date))
           (diary-view-entries))))
   (if calendar-view-holidays-initially-flag
       (let* ((diary-buffer (get-file-buffer diary-file))
-             (diary-window (if diary-buffer (get-buffer-window diary-buffer)))
-             (split-height-threshold (if diary-window 2 1000)))
-        ;; FIXME display buffer?
+             (diary-window (if diary-buffer (get-buffer-window diary-buffer))))
+        ;; This used to bind `split-height-threshold'.  Since that
+       ;; variable is no longer supported we have to find a different
+       ;; solution if needed.
         (calendar-list-holidays)))
   (run-hooks 'calendar-initial-window-hook))
 
@@ -1378,17 +1375,12 @@ Optional integers MON and YR are used instead of today's date."
     ;; Don't do any window-related stuff if we weren't called from a
     ;; window displaying the calendar.
     (when in-calendar-window
-      ;; The second test used to be window-full-width-p.
-      ;; Not sure what it was/is for, except perhaps some way of saying
-      ;; "try not to mess with existing configurations".
-      ;; If did the wrong thing on wide frames, where we have done a
-      ;; horizontal split in calendar-basic-setup.
-      (if (or (one-window-p t) (not (window-safely-shrinkable-p)))
-          ;; Don't mess with the window size, but ensure that the first
-          ;; line is fully visible.
-          (set-window-vscroll nil 0)
-        ;; Adjust the window to exactly fit the displayed calendar.
-        (fit-window-to-buffer nil nil calendar-minimum-window-height))
+      (if (window-iso-combined-p)
+         ;; Adjust the window to exactly fit the displayed calendar.
+         (fit-window-to-buffer nil nil calendar-minimum-window-height)
+       ;; For a full height window or a window that is horizontally
+       ;; combined don't fit height to that of its buffer.
+       (set-window-vscroll nil 0))
       (sit-for 0))
     (and (bound-and-true-p font-lock-mode)
          (font-lock-fontify-buffer))
index 534c2b0f83f9b4b587eb58affbca90dae5491362..894b38da65abbe671aca1785a3e83d6ae97ae35f 100644 (file)
@@ -5983,14 +5983,6 @@ WINDOW was scrolled."
          (error (setq delta nil)))
        delta))))
 
-(defun window-safely-shrinkable-p (&optional window)
-  "Return t if WINDOW can be shrunk without shrinking other windows.
-WINDOW defaults to the selected window."
-  (with-selected-window (or window (selected-window))
-    (let ((edges (window-edges)))
-      (or (= (nth 2 edges) (nth 2 (window-edges (previous-window))))
-         (= (nth 0 edges) (nth 0 (window-edges (next-window))))))))
-
 (defun shrink-window-if-larger-than-buffer (&optional window)
   "Shrink height of WINDOW if its buffer doesn't need so many lines.
 More precisely, shrink WINDOW vertically to be as small as