diff options
| author | Martin Rudalics | 2013-08-14 11:14:32 +0200 |
|---|---|---|
| committer | Martin Rudalics | 2013-08-14 11:14:32 +0200 |
| commit | c660a885dfd57e979911e3d6069f8b6b05948347 (patch) | |
| tree | 1571b0d50a96ac925f94f01b32618a06d5d6f29d | |
| parent | 94a4e898b6cbf8375aa8eddb07a7d63a62b55e15 (diff) | |
| download | emacs-c660a885dfd57e979911e3d6069f8b6b05948347.tar.gz emacs-c660a885dfd57e979911e3d6069f8b6b05948347.zip | |
Fix some issues in window.el.
* window.el (window-make-atom): Don't overwrite parameter
already present.
(display-buffer-in-atom-window): Handle special case where we
split an already atomic window.
(window--major-non-side-window, display-buffer-in-side-window)
(window--side-check): Ignore minibuffer window when walking
window tree.
(window-deletable-p): Return 'frame only if no other frame uses
our minibuffer window.
(record-window-buffer): Run buffer-list-update-hook.
(split-window): Make sure window--check-frame won't destroy an
existing atomic window in case the new window gets nested
inside.
(display-buffer-at-bottom): Ignore minibuffer window when
walking window tree. Don't split a side window.
(pop-to-buffer): Don't set-buffer here, the select-window call
should do that.
(mouse-autoselect-window-select): Autoselect only if we are in the
text portion of the window.
| -rw-r--r-- | lisp/ChangeLog | 22 | ||||
| -rw-r--r-- | lisp/window.el | 94 |
2 files changed, 89 insertions, 27 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 17648f6a540..ac7a87deb5f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,25 @@ | |||
| 1 | 2013-08-14 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * window.el (window-make-atom): Don't overwrite parameter | ||
| 4 | already present. | ||
| 5 | (display-buffer-in-atom-window): Handle special case where we | ||
| 6 | split an already atomic window. | ||
| 7 | (window--major-non-side-window, display-buffer-in-side-window) | ||
| 8 | (window--side-check): Ignore minibuffer window when walking | ||
| 9 | window tree. | ||
| 10 | (window-deletable-p): Return 'frame only if no other frame uses | ||
| 11 | our minibuffer window. | ||
| 12 | (record-window-buffer): Run buffer-list-update-hook. | ||
| 13 | (split-window): Make sure window--check-frame won't destroy an | ||
| 14 | existing atomic window in case the new window gets nested | ||
| 15 | inside. | ||
| 16 | (display-buffer-at-bottom): Ignore minibuffer window when | ||
| 17 | walking window tree. Don't split a side window. | ||
| 18 | (pop-to-buffer): Don't set-buffer here, the select-window call | ||
| 19 | should do that. | ||
| 20 | (mouse-autoselect-window-select): Autoselect only if we are in the | ||
| 21 | text portion of the window. | ||
| 22 | |||
| 1 | 2013-08-13 Lars Magne Ingebrigtsen <larsi@gnus.org> | 23 | 2013-08-13 Lars Magne Ingebrigtsen <larsi@gnus.org> |
| 2 | 24 | ||
| 3 | * net/shr.el (shr-parse-image-data): New function to grab both the | 25 | * net/shr.el (shr-parse-image-data): New function to grab both the |
diff --git a/lisp/window.el b/lisp/window.el index b14d91cb924..e58496f6265 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -477,7 +477,8 @@ WINDOW must be an internal window. Return WINDOW." | |||
| 477 | (error "Window %s is not an internal window" window) | 477 | (error "Window %s is not an internal window" window) |
| 478 | (walk-window-subtree | 478 | (walk-window-subtree |
| 479 | (lambda (window) | 479 | (lambda (window) |
| 480 | (set-window-parameter window 'window-atom t)) | 480 | (unless (window-parameter window 'window-atom) |
| 481 | (set-window-parameter window 'window-atom t))) | ||
| 481 | window t) | 482 | window t) |
| 482 | window)) | 483 | window)) |
| 483 | 484 | ||
| @@ -498,24 +499,39 @@ following symbols can be used. | |||
| 498 | sibling of an atomic window's root. If an internal window is | 499 | sibling of an atomic window's root. If an internal window is |
| 499 | specified here, all children of that window become part of the | 500 | specified here, all children of that window become part of the |
| 500 | atomic window too. If no window is specified, the new window | 501 | atomic window too. If no window is specified, the new window |
| 501 | becomes a sibling of the selected window. | 502 | becomes a sibling of the selected window. By default, the |
| 503 | `window-atom' parameter of the existing window is set to `main' | ||
| 504 | provided it is live and was not set before. | ||
| 502 | 505 | ||
| 503 | `side' denotes the side of the existing window where the new | 506 | `side' denotes the side of the existing window where the new |
| 504 | window shall be located. Valid values are `below', `right', | 507 | window shall be located. Valid values are `below', `right', |
| 505 | `above' and `left'. The default is `below'. | 508 | `above' and `left'. The default is `below'. By default, the |
| 509 | `window-atom' parameter of the new window is set to this value. | ||
| 506 | 510 | ||
| 507 | The return value is the new window, nil when creating that window | 511 | The return value is the new window, nil when creating that window |
| 508 | failed." | 512 | failed." |
| 509 | (let ((ignore-window-parameters t) | 513 | (let* ((ignore-window-parameters t) |
| 510 | (window-combination-limit t) | 514 | (window-combination-limit t) |
| 511 | (window (cdr (assq 'window alist))) | 515 | (window-combination-resize 'atom) |
| 512 | (side (cdr (assq 'side alist))) | 516 | (window (cdr (assq 'window alist))) |
| 513 | new) | 517 | (side (cdr (assq 'side alist))) |
| 518 | (atom (when window (window-parameter window 'window-atom))) | ||
| 519 | root new) | ||
| 514 | (setq window (window-normalize-window window)) | 520 | (setq window (window-normalize-window window)) |
| 515 | ;; Split off new window | 521 | (setq root (window-atom-root window)) |
| 522 | ;; Split off new window. | ||
| 516 | (when (setq new (split-window window nil side)) | 523 | (when (setq new (split-window window nil side)) |
| 517 | ;; Make sure we have a valid atomic window. | 524 | (window-make-atom |
| 518 | (window-make-atom (window-parent window)) | 525 | (if (and root (not (eq root window))) |
| 526 | ;; When WINDOW was part of an atomic window and we did not | ||
| 527 | ;; split its root, root atomic window at old root. | ||
| 528 | root | ||
| 529 | ;; Otherwise, root atomic window at WINDOW's new parent. | ||
| 530 | (window-parent window))) | ||
| 531 | ;; Assign `window-atom' parameters, if needed. | ||
| 532 | (when (and (not atom) (window-live-p window)) | ||
| 533 | (set-window-parameter window 'window-atom 'main)) | ||
| 534 | (set-window-parameter new 'window-atom side) | ||
| 519 | ;; Display BUFFER in NEW and return NEW. | 535 | ;; Display BUFFER in NEW and return NEW. |
| 520 | (window--display-buffer | 536 | (window--display-buffer |
| 521 | buffer new 'window alist display-buffer-mark-dedicated)))) | 537 | buffer new 'window alist display-buffer-mark-dedicated)))) |
| @@ -631,7 +647,7 @@ its root window." | |||
| 631 | (and (setq sibling (window-next-sibling window)) | 647 | (and (setq sibling (window-next-sibling window)) |
| 632 | (window-parameter sibling 'window-side))) | 648 | (window-parameter sibling 'window-side))) |
| 633 | (setq major window))) | 649 | (setq major window))) |
| 634 | frame t) | 650 | frame t 'nomini) |
| 635 | (or major (frame-root-window frame)))) | 651 | (or major (frame-root-window frame)))) |
| 636 | 652 | ||
| 637 | (defun window--major-side-window (side) | 653 | (defun window--major-side-window (side) |
| @@ -762,7 +778,8 @@ following symbols can be used: | |||
| 762 | (walk-window-tree | 778 | (walk-window-tree |
| 763 | (lambda (window) | 779 | (lambda (window) |
| 764 | (when (eq (window-parameter window 'window-side) side) | 780 | (when (eq (window-parameter window 'window-side) side) |
| 765 | (setq windows (cons window windows))))) | 781 | (setq windows (cons window windows)))) |
| 782 | nil nil 'nomini) | ||
| 766 | (nreverse windows)))) | 783 | (nreverse windows)))) |
| 767 | (slots (when major (max 1 (window-child-count major)))) | 784 | (slots (when major (max 1 (window-child-count major)))) |
| 768 | (max-slots | 785 | (max-slots |
| @@ -919,14 +936,14 @@ of all windows on FRAME to nil." | |||
| 919 | (if bottom (throw 'reset t) (setq bottom t))) | 936 | (if bottom (throw 'reset t) (setq bottom t))) |
| 920 | (t | 937 | (t |
| 921 | (throw 'reset t)))) | 938 | (throw 'reset t)))) |
| 922 | frame t)) | 939 | frame t 'nomini)) |
| 923 | ;; If there's a side window, there must be at least one | 940 | ;; If there's a side window, there must be at least one |
| 924 | ;; non-side window. | 941 | ;; non-side window. |
| 925 | (and (or left top right bottom) (not none))) | 942 | (and (or left top right bottom) (not none))) |
| 926 | (walk-window-tree | 943 | (walk-window-tree |
| 927 | (lambda (window) | 944 | (lambda (window) |
| 928 | (set-window-parameter window 'window-side nil)) | 945 | (set-window-parameter window 'window-side nil)) |
| 929 | frame t)))) | 946 | frame t 'nomini)))) |
| 930 | 947 | ||
| 931 | (defun window--check (&optional frame) | 948 | (defun window--check (&optional frame) |
| 932 | "Check atomic and side windows on FRAME. | 949 | "Check atomic and side windows on FRAME. |
| @@ -980,8 +997,8 @@ means ignore all of the above restrictions for all windows." | |||
| 980 | (setq value (+ value | 997 | (setq value (+ value |
| 981 | (window--min-size-1 sub horizontal ignore))) | 998 | (window--min-size-1 sub horizontal ignore))) |
| 982 | (setq sub (window-right sub))) | 999 | (setq sub (window-right sub))) |
| 983 | ;; The minimum size of an ortho-combination is the maximum of | 1000 | ;; The minimum size of an ortho-combination is the maximum |
| 984 | ;; the minimum sizes of its child windows. | 1001 | ;; of the minimum sizes of its child windows. |
| 985 | (while sub | 1002 | (while sub |
| 986 | (setq value (max value | 1003 | (setq value (max value |
| 987 | (window--min-size-1 sub horizontal ignore))) | 1004 | (window--min-size-1 sub horizontal ignore))) |
| @@ -2808,10 +2825,11 @@ and no others." | |||
| 2808 | (defun window-deletable-p (&optional window) | 2825 | (defun window-deletable-p (&optional window) |
| 2809 | "Return t if WINDOW can be safely deleted from its frame. | 2826 | "Return t if WINDOW can be safely deleted from its frame. |
| 2810 | WINDOW must be a valid window and defaults to the selected one. | 2827 | WINDOW must be a valid window and defaults to the selected one. |
| 2811 | Return `frame' if deleting WINDOW should also delete its frame." | 2828 | Return 'frame if deleting WINDOW should also delete its frame." |
| 2812 | (setq window (window-normalize-window window)) | 2829 | (setq window (window-normalize-window window)) |
| 2813 | 2830 | ||
| 2814 | (unless ignore-window-parameters | 2831 | (unless (or ignore-window-parameters |
| 2832 | (eq (window-parameter window 'delete-window) t)) | ||
| 2815 | ;; Handle atomicity. | 2833 | ;; Handle atomicity. |
| 2816 | (when (window-parameter window 'window-atom) | 2834 | (when (window-parameter window 'window-atom) |
| 2817 | (setq window (window-atom-root window)))) | 2835 | (setq window (window-atom-root window)))) |
| @@ -2823,6 +2841,14 @@ Return `frame' if deleting WINDOW should also delete its frame." | |||
| 2823 | ;; on the same terminal, and it does not contain the active | 2841 | ;; on the same terminal, and it does not contain the active |
| 2824 | ;; minibuffer. | 2842 | ;; minibuffer. |
| 2825 | (unless (or (eq frame (next-frame frame 0)) | 2843 | (unless (or (eq frame (next-frame frame 0)) |
| 2844 | ;; We can delete our frame only if no other frame | ||
| 2845 | ;; currently uses our minibuffer window. | ||
| 2846 | (catch 'other | ||
| 2847 | (dolist (other (frame-list)) | ||
| 2848 | (when (and (not (eq other frame)) | ||
| 2849 | (eq (window-frame (minibuffer-window other)) | ||
| 2850 | frame)) | ||
| 2851 | (throw 'other t)))) | ||
| 2826 | (let ((minibuf (active-minibuffer-window))) | 2852 | (let ((minibuf (active-minibuffer-window))) |
| 2827 | (and minibuf (eq frame (window-frame minibuf))))) | 2853 | (and minibuf (eq frame (window-frame minibuf))))) |
| 2828 | 'frame)) | 2854 | 'frame)) |
| @@ -3060,7 +3086,9 @@ WINDOW must be a live window and defaults to the selected one." | |||
| 3060 | ;; (Bug#12588). | 3086 | ;; (Bug#12588). |
| 3061 | point window-point-insertion-type))))) | 3087 | point window-point-insertion-type))))) |
| 3062 | (set-window-prev-buffers | 3088 | (set-window-prev-buffers |
| 3063 | window (cons entry (window-prev-buffers window)))))))) | 3089 | window (cons entry (window-prev-buffers window))))) |
| 3090 | |||
| 3091 | (run-hooks 'buffer-list-update-hook)))) | ||
| 3064 | 3092 | ||
| 3065 | (defun unrecord-window-buffer (&optional window buffer) | 3093 | (defun unrecord-window-buffer (&optional window buffer) |
| 3066 | "Unrecord BUFFER in WINDOW. | 3094 | "Unrecord BUFFER in WINDOW. |
| @@ -3894,7 +3922,8 @@ frame. The selected window is not changed by this function." | |||
| 3894 | 3922 | ||
| 3895 | (let* ((new (split-window-internal window new-size side new-normal))) | 3923 | (let* ((new (split-window-internal window new-size side new-normal))) |
| 3896 | ;; Assign window-side parameters, if any. | 3924 | ;; Assign window-side parameters, if any. |
| 3897 | (when (eq window-combination-resize 'side) | 3925 | (cond |
| 3926 | ((eq window-combination-resize 'side) | ||
| 3898 | (let ((window-side | 3927 | (let ((window-side |
| 3899 | (cond | 3928 | (cond |
| 3900 | (window-side window-side) | 3929 | (window-side window-side) |
| @@ -3908,6 +3937,14 @@ frame. The selected window is not changed by this function." | |||
| 3908 | ;; new parent the same window-side parameter. | 3937 | ;; new parent the same window-side parameter. |
| 3909 | (set-window-parameter | 3938 | (set-window-parameter |
| 3910 | (window-parent new) 'window-side window-side)))) | 3939 | (window-parent new) 'window-side window-side)))) |
| 3940 | ((eq window-combination-resize 'atom) | ||
| 3941 | ;; Make sure `window--check-frame' won't destroy an existing | ||
| 3942 | ;; atomic window in case the new window gets nested inside. | ||
| 3943 | (unless (window-parameter window 'window-atom) | ||
| 3944 | (set-window-parameter window 'window-atom t)) | ||
| 3945 | (when new-parent | ||
| 3946 | (set-window-parameter (window-parent new) 'window-atom t)) | ||
| 3947 | (set-window-parameter new 'window-atom t))) | ||
| 3911 | 3948 | ||
| 3912 | (run-window-configuration-change-hook frame) | 3949 | (run-window-configuration-change-hook frame) |
| 3913 | (window--check frame) | 3950 | (window--check frame) |
| @@ -5676,7 +5713,8 @@ This either splits the window at the bottom of the frame or the | |||
| 5676 | frame's root window, or reuses an existing window at the bottom | 5713 | frame's root window, or reuses an existing window at the bottom |
| 5677 | of the selected frame." | 5714 | of the selected frame." |
| 5678 | (let (bottom-window window) | 5715 | (let (bottom-window window) |
| 5679 | (walk-window-tree (lambda (window) (setq bottom-window window))) | 5716 | (walk-window-tree |
| 5717 | (lambda (window) (setq bottom-window window)) nil nil 'nomini) | ||
| 5680 | (or (and (not (frame-parameter nil 'unsplittable)) | 5718 | (or (and (not (frame-parameter nil 'unsplittable)) |
| 5681 | (setq window (window--try-to-split-window bottom-window alist)) | 5719 | (setq window (window--try-to-split-window bottom-window alist)) |
| 5682 | (window--display-buffer | 5720 | (window--display-buffer |
| @@ -5684,7 +5722,7 @@ of the selected frame." | |||
| 5684 | (and (not (frame-parameter nil 'unsplittable)) | 5722 | (and (not (frame-parameter nil 'unsplittable)) |
| 5685 | (setq window | 5723 | (setq window |
| 5686 | (condition-case nil | 5724 | (condition-case nil |
| 5687 | (split-window (frame-root-window)) | 5725 | (split-window (window--major-non-side-window)) |
| 5688 | (error nil))) | 5726 | (error nil))) |
| 5689 | (window--display-buffer | 5727 | (window--display-buffer |
| 5690 | buffer window 'window alist display-buffer-mark-dedicated)) | 5728 | buffer window 'window alist display-buffer-mark-dedicated)) |
| @@ -5803,7 +5841,8 @@ at the front of the list of recently selected ones." | |||
| 5803 | (interactive (list (read-buffer "Pop to buffer: " (other-buffer)) | 5841 | (interactive (list (read-buffer "Pop to buffer: " (other-buffer)) |
| 5804 | (if current-prefix-arg t))) | 5842 | (if current-prefix-arg t))) |
| 5805 | (setq buffer (window-normalize-buffer-to-switch-to buffer)) | 5843 | (setq buffer (window-normalize-buffer-to-switch-to buffer)) |
| 5806 | (set-buffer buffer) | 5844 | ;; This should be done by `select-window' below. |
| 5845 | ;; (set-buffer buffer) | ||
| 5807 | (let* ((old-frame (selected-frame)) | 5846 | (let* ((old-frame (selected-frame)) |
| 5808 | (window (display-buffer buffer action)) | 5847 | (window (display-buffer buffer action)) |
| 5809 | (frame (window-frame window))) | 5848 | (frame (window-frame window))) |
| @@ -6641,9 +6680,10 @@ is active. This function is run by `mouse-autoselect-window-timer'." | |||
| 6641 | (cond | 6680 | (cond |
| 6642 | ((or (menu-or-popup-active-p) | 6681 | ((or (menu-or-popup-active-p) |
| 6643 | (and window | 6682 | (and window |
| 6644 | (not (coordinates-in-window-p (cdr mouse-position) window)))) | 6683 | (not (consp (coordinates-in-window-p |
| 6645 | ;; A menu / popup dialog is active or the mouse is on the scroll-bar | 6684 | (cdr mouse-position) window))))) |
| 6646 | ;; of WINDOW, temporarily suspend delayed autoselection. | 6685 | ;; A menu / popup dialog is active or the mouse is not on the |
| 6686 | ;; text region of WINDOW: Suspend autoselection temporarily. | ||
| 6647 | (mouse-autoselect-window-start mouse-position nil t)) | 6687 | (mouse-autoselect-window-start mouse-position nil t)) |
| 6648 | ((eq mouse-autoselect-window-state 'suspend) | 6688 | ((eq mouse-autoselect-window-state 'suspend) |
| 6649 | ;; Delayed autoselection was temporarily suspended, reenable it. | 6689 | ;; Delayed autoselection was temporarily suspended, reenable it. |