(error "Window %s is not an internal window" window)
(walk-window-subtree
(lambda (window)
- (set-window-parameter window 'window-atom t))
+ (unless (window-parameter window 'window-atom)
+ (set-window-parameter window 'window-atom t)))
window t)
window))
sibling of an atomic window's root. If an internal window is
specified here, all children of that window become part of the
atomic window too. If no window is specified, the new window
- becomes a sibling of the selected window.
+ becomes a sibling of the selected window. By default, the
+ `window-atom' parameter of the existing window is set to `main'
+ provided it is live and was not set before.
`side' denotes the side of the existing window where the new
window shall be located. Valid values are `below', `right',
- `above' and `left'. The default is `below'.
+ `above' and `left'. The default is `below'. By default, the
+ `window-atom' parameter of the new window is set to this value.
The return value is the new window, nil when creating that window
failed."
- (let ((ignore-window-parameters t)
- (window-combination-limit t)
- (window (cdr (assq 'window alist)))
- (side (cdr (assq 'side alist)))
- new)
+ (let* ((ignore-window-parameters t)
+ (window-combination-limit t)
+ (window-combination-resize 'atom)
+ (window (cdr (assq 'window alist)))
+ (side (cdr (assq 'side alist)))
+ (atom (when window (window-parameter window 'window-atom)))
+ root new)
(setq window (window-normalize-window window))
- ;; Split off new window
+ (setq root (window-atom-root window))
+ ;; Split off new window.
(when (setq new (split-window window nil side))
- ;; Make sure we have a valid atomic window.
- (window-make-atom (window-parent window))
+ (window-make-atom
+ (if (and root (not (eq root window)))
+ ;; When WINDOW was part of an atomic window and we did not
+ ;; split its root, root atomic window at old root.
+ root
+ ;; Otherwise, root atomic window at WINDOW's new parent.
+ (window-parent window)))
+ ;; Assign `window-atom' parameters, if needed.
+ (when (and (not atom) (window-live-p window))
+ (set-window-parameter window 'window-atom 'main))
+ (set-window-parameter new 'window-atom side)
;; Display BUFFER in NEW and return NEW.
(window--display-buffer
buffer new 'window alist display-buffer-mark-dedicated))))
(and (setq sibling (window-next-sibling window))
(window-parameter sibling 'window-side)))
(setq major window)))
- frame t)
+ frame t 'nomini)
(or major (frame-root-window frame))))
(defun window--major-side-window (side)
(walk-window-tree
(lambda (window)
(when (eq (window-parameter window 'window-side) side)
- (setq windows (cons window windows)))))
+ (setq windows (cons window windows))))
+ nil nil 'nomini)
(nreverse windows))))
(slots (when major (max 1 (window-child-count major))))
(max-slots
(if bottom (throw 'reset t) (setq bottom t)))
(t
(throw 'reset t))))
- frame t))
+ frame t 'nomini))
;; If there's a side window, there must be at least one
;; non-side window.
(and (or left top right bottom) (not none)))
(walk-window-tree
(lambda (window)
(set-window-parameter window 'window-side nil))
- frame t))))
+ frame t 'nomini))))
(defun window--check (&optional frame)
"Check atomic and side windows on FRAME.
(setq value (+ value
(window--min-size-1 sub horizontal ignore)))
(setq sub (window-right sub)))
- ;; The minimum size of an ortho-combination is the maximum of
- ;; the minimum sizes of its child windows.
+ ;; The minimum size of an ortho-combination is the maximum
+ ;; of the minimum sizes of its child windows.
(while sub
(setq value (max value
(window--min-size-1 sub horizontal ignore)))
(defun window-deletable-p (&optional window)
"Return t if WINDOW can be safely deleted from its frame.
WINDOW must be a valid window and defaults to the selected one.
-Return `frame' if deleting WINDOW should also delete its frame."
+Return 'frame if deleting WINDOW should also delete its frame."
(setq window (window-normalize-window window))
- (unless ignore-window-parameters
+ (unless (or ignore-window-parameters
+ (eq (window-parameter window 'delete-window) t))
;; Handle atomicity.
(when (window-parameter window 'window-atom)
(setq window (window-atom-root window))))
;; on the same terminal, and it does not contain the active
;; minibuffer.
(unless (or (eq frame (next-frame frame 0))
+ ;; We can delete our frame only if no other frame
+ ;; currently uses our minibuffer window.
+ (catch 'other
+ (dolist (other (frame-list))
+ (when (and (not (eq other frame))
+ (eq (window-frame (minibuffer-window other))
+ frame))
+ (throw 'other t))))
(let ((minibuf (active-minibuffer-window)))
(and minibuf (eq frame (window-frame minibuf)))))
'frame))
;; (Bug#12588).
point window-point-insertion-type)))))
(set-window-prev-buffers
- window (cons entry (window-prev-buffers window))))))))
+ window (cons entry (window-prev-buffers window)))))
+
+ (run-hooks 'buffer-list-update-hook))))
(defun unrecord-window-buffer (&optional window buffer)
"Unrecord BUFFER in WINDOW.
(let* ((new (split-window-internal window new-size side new-normal)))
;; Assign window-side parameters, if any.
- (when (eq window-combination-resize 'side)
+ (cond
+ ((eq window-combination-resize 'side)
(let ((window-side
(cond
(window-side window-side)
;; new parent the same window-side parameter.
(set-window-parameter
(window-parent new) 'window-side window-side))))
+ ((eq window-combination-resize 'atom)
+ ;; Make sure `window--check-frame' won't destroy an existing
+ ;; atomic window in case the new window gets nested inside.
+ (unless (window-parameter window 'window-atom)
+ (set-window-parameter window 'window-atom t))
+ (when new-parent
+ (set-window-parameter (window-parent new) 'window-atom t))
+ (set-window-parameter new 'window-atom t)))
(run-window-configuration-change-hook frame)
(window--check frame)
frame's root window, or reuses an existing window at the bottom
of the selected frame."
(let (bottom-window window)
- (walk-window-tree (lambda (window) (setq bottom-window window)))
+ (walk-window-tree
+ (lambda (window) (setq bottom-window window)) nil nil 'nomini)
(or (and (not (frame-parameter nil 'unsplittable))
(setq window (window--try-to-split-window bottom-window alist))
(window--display-buffer
(and (not (frame-parameter nil 'unsplittable))
(setq window
(condition-case nil
- (split-window (frame-root-window))
+ (split-window (window--major-non-side-window))
(error nil)))
(window--display-buffer
buffer window 'window alist display-buffer-mark-dedicated))
(interactive (list (read-buffer "Pop to buffer: " (other-buffer))
(if current-prefix-arg t)))
(setq buffer (window-normalize-buffer-to-switch-to buffer))
- (set-buffer buffer)
+ ;; This should be done by `select-window' below.
+ ;; (set-buffer buffer)
(let* ((old-frame (selected-frame))
(window (display-buffer buffer action))
(frame (window-frame window)))
(cond
((or (menu-or-popup-active-p)
(and window
- (not (coordinates-in-window-p (cdr mouse-position) window))))
- ;; A menu / popup dialog is active or the mouse is on the scroll-bar
- ;; of WINDOW, temporarily suspend delayed autoselection.
+ (not (consp (coordinates-in-window-p
+ (cdr mouse-position) window)))))
+ ;; A menu / popup dialog is active or the mouse is not on the
+ ;; text region of WINDOW: Suspend autoselection temporarily.
(mouse-autoselect-window-start mouse-position nil t))
((eq mouse-autoselect-window-state 'suspend)
;; Delayed autoselection was temporarily suspended, reenable it.