diff options
| author | Eli Zaretskii | 2012-11-17 20:00:16 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2012-11-17 20:00:16 +0200 |
| commit | cf2d22b874ca2df0072e32ee641e8efffe4abd6d (patch) | |
| tree | 1795142ec7861fc85c61adc90f03265b69041556 /lisp/window.el | |
| parent | 3c4ca7155293ffc2d04708007131bcbc882d8913 (diff) | |
| parent | 6ad30855c02908fdd99d9b11943719e185e65ee3 (diff) | |
| download | emacs-cf2d22b874ca2df0072e32ee641e8efffe4abd6d.tar.gz emacs-cf2d22b874ca2df0072e32ee641e8efffe4abd6d.zip | |
Merge from trunk.
Diffstat (limited to 'lisp/window.el')
| -rw-r--r-- | lisp/window.el | 125 |
1 files changed, 66 insertions, 59 deletions
diff --git a/lisp/window.el b/lisp/window.el index 30ee622cfe6..9ac3a4ecda0 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -2571,8 +2571,7 @@ move it as far as possible in the desired direction." | |||
| 2571 | Interactively, if no argument is given, make the selected window | 2571 | Interactively, if no argument is given, make the selected window |
| 2572 | one line taller. If optional argument HORIZONTAL is non-nil, | 2572 | one line taller. If optional argument HORIZONTAL is non-nil, |
| 2573 | make selected window wider by DELTA columns. If DELTA is | 2573 | make selected window wider by DELTA columns. If DELTA is |
| 2574 | negative, shrink selected window by -DELTA lines or columns. | 2574 | negative, shrink selected window by -DELTA lines or columns." |
| 2575 | Return nil." | ||
| 2576 | (interactive "p") | 2575 | (interactive "p") |
| 2577 | (let ((minibuffer-window (minibuffer-window))) | 2576 | (let ((minibuffer-window (minibuffer-window))) |
| 2578 | (cond | 2577 | (cond |
| @@ -2605,8 +2604,7 @@ Interactively, if no argument is given, make the selected window | |||
| 2605 | one line smaller. If optional argument HORIZONTAL is non-nil, | 2604 | one line smaller. If optional argument HORIZONTAL is non-nil, |
| 2606 | make selected window narrower by DELTA columns. If DELTA is | 2605 | make selected window narrower by DELTA columns. If DELTA is |
| 2607 | negative, enlarge selected window by -DELTA lines or columns. | 2606 | negative, enlarge selected window by -DELTA lines or columns. |
| 2608 | Also see the `window-min-height' variable. | 2607 | Also see the `window-min-height' variable." |
| 2609 | Return nil." | ||
| 2610 | (interactive "p") | 2608 | (interactive "p") |
| 2611 | (let ((minibuffer-window (minibuffer-window))) | 2609 | (let ((minibuffer-window (minibuffer-window))) |
| 2612 | (cond | 2610 | (cond |
| @@ -3049,8 +3047,10 @@ WINDOW must be a live window and defaults to the selected one." | |||
| 3049 | (set-marker (nth 2 entry) point)) | 3047 | (set-marker (nth 2 entry) point)) |
| 3050 | ;; Make new markers. | 3048 | ;; Make new markers. |
| 3051 | (list (copy-marker start) | 3049 | (list (copy-marker start) |
| 3052 | (copy-marker point))))) | 3050 | (copy-marker |
| 3053 | 3051 | ;; Preserve window-point-insertion-type | |
| 3052 | ;; (Bug#12588). | ||
| 3053 | point window-point-insertion-type))))) | ||
| 3054 | (set-window-prev-buffers | 3054 | (set-window-prev-buffers |
| 3055 | window (cons entry (window-prev-buffers window)))))))) | 3055 | window (cons entry (window-prev-buffers window)))))))) |
| 3056 | 3056 | ||
| @@ -4555,13 +4555,17 @@ element is BUFFER." | |||
| 4555 | ;; If WINDOW has a quit-restore parameter, reset its car. | 4555 | ;; If WINDOW has a quit-restore parameter, reset its car. |
| 4556 | (setcar (window-parameter window 'quit-restore) 'same)) | 4556 | (setcar (window-parameter window 'quit-restore) 'same)) |
| 4557 | ;; WINDOW shows another buffer. | 4557 | ;; WINDOW shows another buffer. |
| 4558 | (set-window-parameter | 4558 | (with-current-buffer (window-buffer window) |
| 4559 | window 'quit-restore | 4559 | (set-window-parameter |
| 4560 | (list 'other | 4560 | window 'quit-restore |
| 4561 | ;; A quadruple of WINDOW's buffer, start, point and height. | 4561 | (list 'other |
| 4562 | (list (window-buffer window) (window-start window) | 4562 | ;; A quadruple of WINDOW's buffer, start, point and height. |
| 4563 | (window-point window) (window-total-size window)) | 4563 | (list (current-buffer) (window-start window) |
| 4564 | (selected-window) buffer)))) | 4564 | ;; Preserve window-point-insertion-type (Bug#12588). |
| 4565 | (copy-marker | ||
| 4566 | (window-point window) window-point-insertion-type) | ||
| 4567 | (window-total-size window)) | ||
| 4568 | (selected-window) buffer))))) | ||
| 4565 | ((eq type 'window) | 4569 | ((eq type 'window) |
| 4566 | ;; WINDOW has been created on an existing frame. | 4570 | ;; WINDOW has been created on an existing frame. |
| 4567 | (set-window-parameter | 4571 | (set-window-parameter |
| @@ -5170,11 +5174,12 @@ is higher than WINDOW." | |||
| 5170 | (error nil)))) | 5174 | (error nil)))) |
| 5171 | 5175 | ||
| 5172 | (defun window--display-buffer (buffer window type &optional alist dedicated) | 5176 | (defun window--display-buffer (buffer window type &optional alist dedicated) |
| 5173 | "Display BUFFER in WINDOW and make its frame visible. | 5177 | "Display BUFFER in WINDOW. |
| 5174 | TYPE must be one of the symbols `reuse', `window' or `frame' and | 5178 | TYPE must be one of the symbols `reuse', `window' or `frame' and |
| 5175 | is passed unaltered to `display-buffer-record-window'. Set | 5179 | is passed unaltered to `display-buffer-record-window'. ALIST is |
| 5176 | `window-dedicated-p' to DEDICATED if non-nil. Return WINDOW if | 5180 | the alist argument of `display-buffer'. Set `window-dedicated-p' |
| 5177 | BUFFER and WINDOW are live." | 5181 | to DEDICATED if non-nil. Return WINDOW if BUFFER and WINDOW are |
| 5182 | live." | ||
| 5178 | (when (and (buffer-live-p buffer) (window-live-p window)) | 5183 | (when (and (buffer-live-p buffer) (window-live-p window)) |
| 5179 | (display-buffer-record-window type window buffer) | 5184 | (display-buffer-record-window type window buffer) |
| 5180 | (unless (eq buffer (window-buffer window)) | 5185 | (unless (eq buffer (window-buffer window)) |
| @@ -5187,10 +5192,10 @@ BUFFER and WINDOW are live." | |||
| 5187 | (let ((parameter (window-parameter window 'quit-restore)) | 5192 | (let ((parameter (window-parameter window 'quit-restore)) |
| 5188 | (height (cdr (assq 'window-height alist))) | 5193 | (height (cdr (assq 'window-height alist))) |
| 5189 | (width (cdr (assq 'window-width alist)))) | 5194 | (width (cdr (assq 'window-width alist)))) |
| 5190 | (when (or (memq type '(window frame)) | 5195 | (when (or (eq type 'window) |
| 5191 | (and (eq (car parameter) 'same) | 5196 | (and (eq (car parameter) 'same) |
| 5192 | (memq (nth 1 parameter) '(window frame)))) | 5197 | (eq (nth 1 parameter) 'window))) |
| 5193 | ;; Adjust height of new window or frame. | 5198 | ;; Adjust height of window if asked for. |
| 5194 | (cond | 5199 | (cond |
| 5195 | ((not height)) | 5200 | ((not height)) |
| 5196 | ((numberp height) | 5201 | ((numberp height) |
| @@ -5201,19 +5206,12 @@ BUFFER and WINDOW are live." | |||
| 5201 | (* (window-total-size (frame-root-window window)) | 5206 | (* (window-total-size (frame-root-window window)) |
| 5202 | height)))) | 5207 | height)))) |
| 5203 | (delta (- new-height (window-total-size window)))) | 5208 | (delta (- new-height (window-total-size window)))) |
| 5204 | (cond | 5209 | (when (and (window--resizable-p window delta nil 'safe) |
| 5205 | ((and (window--resizable-p window delta nil 'safe) | 5210 | (window-combined-p window)) |
| 5206 | (window-combined-p window)) | 5211 | (window-resize window delta nil 'safe)))) |
| 5207 | (window-resize window delta nil 'safe)) | ||
| 5208 | ((or (eq type 'frame) | ||
| 5209 | (and (eq (car parameter) 'same) | ||
| 5210 | (eq (nth 1 parameter) 'frame))) | ||
| 5211 | (set-frame-height | ||
| 5212 | (window-frame window) | ||
| 5213 | (+ (frame-height (window-frame window)) delta)))))) | ||
| 5214 | ((functionp height) | 5212 | ((functionp height) |
| 5215 | (ignore-errors (funcall height window)))) | 5213 | (ignore-errors (funcall height window)))) |
| 5216 | ;; Adjust width of a window or frame. | 5214 | ;; Adjust width of window if asked for. |
| 5217 | (cond | 5215 | (cond |
| 5218 | ((not width)) | 5216 | ((not width)) |
| 5219 | ((numberp width) | 5217 | ((numberp width) |
| @@ -5224,18 +5222,12 @@ BUFFER and WINDOW are live." | |||
| 5224 | (* (window-total-size (frame-root-window window) t) | 5222 | (* (window-total-size (frame-root-window window) t) |
| 5225 | width)))) | 5223 | width)))) |
| 5226 | (delta (- new-width (window-total-size window t)))) | 5224 | (delta (- new-width (window-total-size window t)))) |
| 5227 | (cond | 5225 | (when (and (window--resizable-p window delta t 'safe) |
| 5228 | ((and (window--resizable-p window delta t 'safe) | 5226 | (window-combined-p window t)) |
| 5229 | (window-combined-p window t)) | 5227 | (window-resize window delta t 'safe)))) |
| 5230 | (window-resize window delta t 'safe)) | ||
| 5231 | ((or (eq type 'frame) | ||
| 5232 | (and (eq (car parameter) 'same) | ||
| 5233 | (eq (nth 1 parameter) 'frame))) | ||
| 5234 | (set-frame-width | ||
| 5235 | (window-frame window) | ||
| 5236 | (+ (frame-width (window-frame window)) delta)))))) | ||
| 5237 | ((functionp width) | 5228 | ((functionp width) |
| 5238 | (ignore-errors (funcall width window)))))) | 5229 | (ignore-errors (funcall width window)))))) |
| 5230 | |||
| 5239 | window)) | 5231 | window)) |
| 5240 | 5232 | ||
| 5241 | (defun window--maybe-raise-frame (frame) | 5233 | (defun window--maybe-raise-frame (frame) |
| @@ -5295,13 +5287,19 @@ See `display-buffer' for details.") | |||
| 5295 | "Alist of conditional actions for `display-buffer'. | 5287 | "Alist of conditional actions for `display-buffer'. |
| 5296 | This is a list of elements (CONDITION . ACTION), where: | 5288 | This is a list of elements (CONDITION . ACTION), where: |
| 5297 | 5289 | ||
| 5298 | CONDITION is either a regexp matching buffer names, or a function | 5290 | CONDITION is either a regexp matching buffer names, or a |
| 5299 | that takes a buffer and returns a boolean. | 5291 | function that takes two arguments - a buffer name and the |
| 5292 | ACTION argument of `display-buffer' - and returns a boolean. | ||
| 5300 | 5293 | ||
| 5301 | ACTION is a cons cell (FUNCTION . ALIST), where FUNCTION is a | 5294 | ACTION is a cons cell (FUNCTION . ALIST), where FUNCTION is a |
| 5302 | function or a list of functions. Each such function should | 5295 | function or a list of functions. Each such function should |
| 5303 | accept two arguments: a buffer to display and an alist of the | 5296 | accept two arguments: a buffer to display and an alist of the |
| 5304 | same form as ALIST. See `display-buffer' for details." | 5297 | same form as ALIST. See `display-buffer' for details. |
| 5298 | |||
| 5299 | `display-buffer' scans this alist until it either finds a | ||
| 5300 | matching regular expression or the function specified by a | ||
| 5301 | condition returns non-nil. In any of these cases, it adds the | ||
| 5302 | associated action to the list of actions it will try." | ||
| 5305 | :type `(alist :key-type | 5303 | :type `(alist :key-type |
| 5306 | (choice :tag "Condition" | 5304 | (choice :tag "Condition" |
| 5307 | regexp | 5305 | regexp |
| @@ -5335,15 +5333,16 @@ specified, e.g. by the user options `display-buffer-alist' or | |||
| 5335 | `display-buffer-base-action'. See `display-buffer'.") | 5333 | `display-buffer-base-action'. See `display-buffer'.") |
| 5336 | (put 'display-buffer-fallback-action 'risky-local-variable t) | 5334 | (put 'display-buffer-fallback-action 'risky-local-variable t) |
| 5337 | 5335 | ||
| 5338 | (defun display-buffer-assq-regexp (buffer-name alist) | 5336 | (defun display-buffer-assq-regexp (buffer-name alist action) |
| 5339 | "Retrieve ALIST entry corresponding to BUFFER-NAME." | 5337 | "Retrieve ALIST entry corresponding to BUFFER-NAME. |
| 5338 | ACTION is the action argument passed to `display-buffer'." | ||
| 5340 | (catch 'match | 5339 | (catch 'match |
| 5341 | (dolist (entry alist) | 5340 | (dolist (entry alist) |
| 5342 | (let ((key (car entry))) | 5341 | (let ((key (car entry))) |
| 5343 | (when (or (and (stringp key) | 5342 | (when (or (and (stringp key) |
| 5344 | (string-match-p key buffer-name)) | 5343 | (string-match-p key buffer-name)) |
| 5345 | (and (symbolp key) (functionp key) | 5344 | (and (functionp key) |
| 5346 | (funcall key buffer-name alist))) | 5345 | (funcall key buffer-name action))) |
| 5347 | (throw 'match (cdr entry))))))) | 5346 | (throw 'match (cdr entry))))))) |
| 5348 | 5347 | ||
| 5349 | (defvar display-buffer--same-window-action | 5348 | (defvar display-buffer--same-window-action |
| @@ -5453,8 +5452,8 @@ argument, ACTION is t." | |||
| 5453 | (funcall display-buffer-function buffer inhibit-same-window) | 5452 | (funcall display-buffer-function buffer inhibit-same-window) |
| 5454 | ;; Otherwise, use the defined actions. | 5453 | ;; Otherwise, use the defined actions. |
| 5455 | (let* ((user-action | 5454 | (let* ((user-action |
| 5456 | (display-buffer-assq-regexp (buffer-name buffer) | 5455 | (display-buffer-assq-regexp |
| 5457 | display-buffer-alist)) | 5456 | (buffer-name buffer) display-buffer-alist action)) |
| 5458 | (special-action (display-buffer--special-action buffer)) | 5457 | (special-action (display-buffer--special-action buffer)) |
| 5459 | ;; Extra actions from the arguments to this function: | 5458 | ;; Extra actions from the arguments to this function: |
| 5460 | (extra-action | 5459 | (extra-action |
| @@ -6068,22 +6067,26 @@ of `fit-frame-to-buffer-max-height' and `window-min-height'." | |||
| 6068 | :group 'help) | 6067 | :group 'help) |
| 6069 | 6068 | ||
| 6070 | (defcustom fit-frame-to-buffer-bottom-margin 4 | 6069 | (defcustom fit-frame-to-buffer-bottom-margin 4 |
| 6071 | "Bottom margin for `fit-frame-to-buffer'. | 6070 | "Bottom margin for the command `fit-frame-to-buffer'. |
| 6072 | This is the number of lines `fit-frame-to-buffer' leaves free at the | 6071 | This is the number of lines that function leaves free at the bottom of |
| 6073 | bottom of the display in order to not obscure the system task bar." | 6072 | the display, in order to not obscure any system task bar or panel. |
| 6073 | If you do not have one (or if it is vertical) you might want to | ||
| 6074 | reduce this. If it is thicker, you might want to increase this." | ||
| 6075 | ;; If you set this too small, fit-frame-to-buffer can shift the | ||
| 6076 | ;; frame up to avoid the panel. | ||
| 6074 | :type 'integer | 6077 | :type 'integer |
| 6075 | :version "24.3" | 6078 | :version "24.3" |
| 6076 | :group 'windows) | 6079 | :group 'windows) |
| 6077 | 6080 | ||
| 6078 | (defun fit-frame-to-buffer (&optional frame max-height min-height) | 6081 | (defun fit-frame-to-buffer (&optional frame max-height min-height) |
| 6079 | "Adjust height of FRAME to display its buffer's contents exactly. | 6082 | "Adjust height of FRAME to display its buffer contents exactly. |
| 6080 | FRAME can be any live frame and defaults to the selected one. | 6083 | FRAME can be any live frame and defaults to the selected one. |
| 6081 | 6084 | ||
| 6082 | Optional argument MAX-HEIGHT specifies the maximum height of | 6085 | Optional argument MAX-HEIGHT specifies the maximum height of FRAME. |
| 6083 | FRAME and defaults to the height of the display below the current | 6086 | It defaults to the height of the display below the current |
| 6084 | top line of FRAME minus FIT-FRAME-TO-BUFFER-BOTTOM-MARGIN. | 6087 | top line of FRAME, minus `fit-frame-to-buffer-bottom-margin'. |
| 6085 | Optional argument MIN-HEIGHT specifies the minimum height of | 6088 | Optional argument MIN-HEIGHT specifies the minimum height of FRAME. |
| 6086 | FRAME." | 6089 | The default corresponds to `window-min-height'." |
| 6087 | (interactive) | 6090 | (interactive) |
| 6088 | (setq frame (window-normalize-frame frame)) | 6091 | (setq frame (window-normalize-frame frame)) |
| 6089 | (let* ((root (frame-root-window frame)) | 6092 | (let* ((root (frame-root-window frame)) |
| @@ -6160,6 +6163,10 @@ defaults to `window-min-height'. Both MAX-HEIGHT and MIN-HEIGHT | |||
| 6160 | are specified in lines and include the mode line and header line, | 6163 | are specified in lines and include the mode line and header line, |
| 6161 | if any. | 6164 | if any. |
| 6162 | 6165 | ||
| 6166 | If WINDOW is a full height window, then if the option | ||
| 6167 | `fit-frame-to-buffer' is non-nil, this calls the function | ||
| 6168 | `fit-frame-to-buffer' to adjust the frame height. | ||
| 6169 | |||
| 6163 | Return the number of lines by which WINDOW was enlarged or | 6170 | Return the number of lines by which WINDOW was enlarged or |
| 6164 | shrunk. If an error occurs during resizing, return nil but don't | 6171 | shrunk. If an error occurs during resizing, return nil but don't |
| 6165 | signal an error. | 6172 | signal an error. |