]> code.delx.au - gnu-emacs/blobdiff - lisp/window.el
Merge from CEDET upstream (8569).
[gnu-emacs] / lisp / window.el
index 627b9a425eb74114ad1492775e2532d73a830c14..86d93c0a9f6fbd4bf725bf0cc0721c886f7a223b 100644 (file)
@@ -3686,7 +3686,7 @@ lines or columns tall.  If SIZE is negative, make the new window
 absolute value can be less than `window-min-height' or
 `window-min-width'; so this command can make a new window as
 small as one line or two columns.  SIZE defaults to half of
-WINDOW's size.  Interactively, SIZE is the prefix argument.
+WINDOW's size.
 
 Optional third argument SIDE nil (or `below') specifies that the
 new window shall be located below WINDOW.  SIDE `above' means the
@@ -3718,7 +3718,6 @@ scrollbars are inherited from WINDOW.  If WINDOW is an internal
 window, these properties as well as the buffer displayed in the
 new window are inherited from the window selected on WINDOW's
 frame.  The selected window is not changed by this function."
-  (interactive "i")
   (setq window (window-normalize-window window))
   (let* ((side (cond
                ((not side) 'below)
@@ -4259,7 +4258,8 @@ specific buffers."
             (total-width . ,(window-total-size window t))
             (normal-height . ,(window-normal-size window))
             (normal-width . ,(window-normal-size window t))
-            (combination-limit . ,(window-combination-limit window))
+            ,@(unless (window-live-p window)
+                `((combination-limit . ,(window-combination-limit window))))
             ,@(let ((parameters (window-parameters window))
                    list)
                ;; Make copies of those window parameters whose
@@ -4347,6 +4347,9 @@ value can be also stored on disk and read back in a new session."
 (defvar window-state-put-list nil
   "Helper variable for `window-state-put'.")
 
+(defvar window-state-put-stale-windows nil
+  "Helper variable for `window-state-put'.")
+
 (defun window--state-put-1 (state &optional window ignore totals)
   "Helper function for `window-state-put'."
   (let ((type (car state)))
@@ -4429,9 +4432,14 @@ value can be also stored on disk and read back in a new session."
          (set-window-parameter window (car parameter) (cdr parameter))))
       ;; Process buffer related state.
       (when state
-       ;; We don't want to raise an error here so we create a buffer if
-       ;; there's none.
-       (set-window-buffer window (get-buffer-create (car state)))
+       ;; We don't want to raise an error in case the buffer does not
+       ;; exist anymore, so we switch to a previous one and save the
+       ;; window with the intention of deleting it later if possible.
+       (let ((buffer (get-buffer (car state))))
+         (if buffer
+             (set-window-buffer window buffer)
+           (switch-to-prev-buffer window)
+           (push window window-state-put-stale-windows)))
        (with-current-buffer (window-buffer window)
          (set-window-hscroll window (cdr (assq 'hscroll state)))
          (apply 'set-window-fringes
@@ -4491,6 +4499,7 @@ Optional argument IGNORE non-nil means ignore minimum window
 sizes and fixed size restrictions.  IGNORE equal `safe' means
 windows can get as small as `window-safe-min-height' and
 `window-safe-min-width'."
+  (setq window-state-put-stale-windows nil)
   (setq window (window-normalize-window window t))
   (let* ((frame (window-frame window))
         (head (car state))
@@ -4539,6 +4548,10 @@ windows can get as small as `window-safe-min-height' and
        (set-window-buffer window (current-buffer))
        (window--state-put-1 state window nil totals)
        (window--state-put-2 ignore))
+      (while window-state-put-stale-windows
+       (let ((window (pop window-state-put-stale-windows)))
+         (when (eq (window-deletable-p window) t)
+           (delete-window window))))
       (window--check frame))))
 \f
 (defun display-buffer-record-window (type window buffer)
@@ -5457,6 +5470,9 @@ argument, ACTION is t."
   (let ((buffer (if (bufferp buffer-or-name)
                    buffer-or-name
                  (get-buffer buffer-or-name)))
+       ;; Make sure that when we split windows the old window keeps
+       ;; point, bug#14829.
+       (split-window-keep-point t)
        ;; Handle the old form of the first argument.
        (inhibit-same-window (and action (not (listp action)))))
     (unless (listp action) (setq action nil))