diff options
| author | Martin Rudalics | 2011-06-26 18:17:30 +0200 |
|---|---|---|
| committer | Martin Rudalics | 2011-06-26 18:17:30 +0200 |
| commit | 355f2e07082d7fc4d30cd0c1fab444799db6d6a7 (patch) | |
| tree | e7d33a894e7ac8100ee8412dfa48ebdb2635faf6 | |
| parent | 60a0884e784668ab9cb0f6c984803efccdecce53 (diff) | |
| download | emacs-355f2e07082d7fc4d30cd0c1fab444799db6d6a7.tar.gz emacs-355f2e07082d7fc4d30cd0c1fab444799db6d6a7.zip | |
Fix some more display-buffer related bugs.
* window.el (display-buffer-normalize-argument): Rename to
display-buffer-normalize-arguments. Handle special meaning of
LABEL argument. Respect special-display-function when popping
up a new frame. Fix code searching for a window showing the
buffer on another frame.
(display-buffer-normalize-specifiers): Call
display-buffer-normalize-arguments.
(display-buffer-in-window): Don't undedicate the window if its
buffer remains the same.
Reported by Drew Adams <drew.adams@oracle.com>.
(display-buffer-alist): Add choice for same-window macro
specfier.
(display-buffer): Mention special meaning of LABEL argument in
doc-string. Fix quoting. Don't pop up a new frame even as
fallback.
| -rw-r--r-- | lisp/ChangeLog | 18 | ||||
| -rw-r--r-- | lisp/window.el | 141 |
2 files changed, 112 insertions, 47 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0dde4aa62bb..c726864ebcc 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,21 @@ | |||
| 1 | 2011-06-26 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * window.el (display-buffer-normalize-argument): Rename to | ||
| 4 | display-buffer-normalize-arguments. Handle special meaning of | ||
| 5 | LABEL argument. Respect special-display-function when popping | ||
| 6 | up a new frame. Fix code searching for a window showing the | ||
| 7 | buffer on another frame. | ||
| 8 | (display-buffer-normalize-specifiers): Call | ||
| 9 | display-buffer-normalize-arguments. | ||
| 10 | (display-buffer-in-window): Don't undedicate the window if its | ||
| 11 | buffer remains the same. | ||
| 12 | Reported by Drew Adams <drew.adams@oracle.com>. | ||
| 13 | (display-buffer-alist): Add choice for same-window macro | ||
| 14 | specfier. | ||
| 15 | (display-buffer): Mention special meaning of LABEL argument in | ||
| 16 | doc-string. Fix quoting. Don't pop up a new frame even as | ||
| 17 | fallback. | ||
| 18 | |||
| 1 | 2011-06-26 Juanma Barranquero <lekktu@gmail.com> | 19 | 2011-06-26 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 20 | ||
| 3 | * bs.el (bs-cycle-next): Pass current buffer to `bury-buffer' to | 21 | * bs.el (bs-cycle-next): Pass current buffer to `bury-buffer' to |
diff --git a/lisp/window.el b/lisp/window.el index e8278bb9986..ddbfdcf2454 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -4537,7 +4537,12 @@ using the location specifiers `same-window' or `other-frame'." | |||
| 4537 | 4537 | ||
| 4538 | ;; Macro specifiers. | 4538 | ;; Macro specifiers. |
| 4539 | (list | 4539 | (list |
| 4540 | :tag "Same frame only" | 4540 | :tag "Same window" |
| 4541 | :format "%t%v" | ||
| 4542 | :inline t | ||
| 4543 | (const :format "\n" same-window)) | ||
| 4544 | (list | ||
| 4545 | :tag "Same frame" | ||
| 4541 | :format "%t%v" | 4546 | :format "%t%v" |
| 4542 | :inline t | 4547 | :inline t |
| 4543 | (const :format "\n" same-frame)) | 4548 | (const :format "\n" same-frame)) |
| @@ -4552,7 +4557,7 @@ using the location specifiers `same-window' or `other-frame'." | |||
| 4552 | :inline t | 4557 | :inline t |
| 4553 | (const :format "\n" same-frame-other-window)) | 4558 | (const :format "\n" same-frame-other-window)) |
| 4554 | (list | 4559 | (list |
| 4555 | :tag "Other frame only" | 4560 | :tag "Other frame" |
| 4556 | :format "%t%v" | 4561 | :format "%t%v" |
| 4557 | :inline t | 4562 | :inline t |
| 4558 | (const :format "\n" other-frame)) | 4563 | (const :format "\n" other-frame)) |
| @@ -4737,7 +4742,9 @@ documentation of `display-buffer-alist' for a description." | |||
| 4737 | (dedicated (cdr (assq 'dedicated specifiers))) | 4742 | (dedicated (cdr (assq 'dedicated specifiers))) |
| 4738 | (no-other-window (cdr (assq 'no-other-window specifiers)))) | 4743 | (no-other-window (cdr (assq 'no-other-window specifiers)))) |
| 4739 | ;; Show BUFFER in WINDOW. | 4744 | ;; Show BUFFER in WINDOW. |
| 4740 | (set-window-dedicated-p window nil) | 4745 | (unless (eq buffer (window-buffer window)) |
| 4746 | ;; If we show another buffer in WINDOW, undedicate it first. | ||
| 4747 | (set-window-dedicated-p window nil)) | ||
| 4741 | (set-window-buffer window buffer) | 4748 | (set-window-buffer window buffer) |
| 4742 | (when dedicated | 4749 | (when dedicated |
| 4743 | (set-window-dedicated-p window dedicated)) | 4750 | (set-window-dedicated-p window dedicated)) |
| @@ -5305,48 +5312,73 @@ user preferences expressed in `display-buffer-alist'." | |||
| 5305 | (or (car list) (cdr list))))) | 5312 | (or (car list) (cdr list))))) |
| 5306 | (when value (cdr value)))) | 5313 | (when value (cdr value)))) |
| 5307 | 5314 | ||
| 5308 | (defun display-buffer-normalize-argument (buffer-name specifiers label other-frame) | 5315 | (defun display-buffer-normalize-arguments (buffer-name specifiers label other-frame) |
| 5309 | "Normalize second argument of `display-buffer'. | 5316 | "Normalize second and third argument of `display-buffer'. |
| 5310 | BUFFER-NAME is the name of the buffer that shall be displayed, | 5317 | BUFFER-NAME is the name of the buffer that shall be displayed, |
| 5311 | SPECIFIERS is the second argument of `display-buffer'. LABEL the | 5318 | SPECIFIERS is the second argument of `display-buffer'. LABEL is |
| 5312 | same argument of `display-buffer'. OTHER-FRAME non-nil means use | 5319 | the same argument of `display-buffer'. OTHER-FRAME non-nil means |
| 5313 | other-frame for other-window." | 5320 | use other-frame for other-window." |
| 5314 | (let (normalized entry) | 5321 | (let (normalized entry specifier pars) |
| 5322 | (setq specifier | ||
| 5323 | (cond | ||
| 5324 | ((not specifiers) | ||
| 5325 | nil) | ||
| 5326 | ((listp specifiers) | ||
| 5327 | ;; If SPECIFIERS is a list, we assume it is a list of specifiers. | ||
| 5328 | (dolist (specifier specifiers) | ||
| 5329 | (cond | ||
| 5330 | ((consp specifier) | ||
| 5331 | (setq normalized (cons specifier normalized))) | ||
| 5332 | ((eq specifier 'other-window) | ||
| 5333 | ;; `other-window' must be treated separately. | ||
| 5334 | (let ((entry (assq (if other-frame | ||
| 5335 | 'other-frame | ||
| 5336 | 'same-frame-other-window) | ||
| 5337 | display-buffer-macro-specifiers))) | ||
| 5338 | (dolist (item (cdr entry)) | ||
| 5339 | (setq normalized (cons item normalized))))) | ||
| 5340 | ((symbolp specifier) | ||
| 5341 | ;; Might be a macro specifier, try to expand it (the cdr is a | ||
| 5342 | ;; list and we have to reverse it later, so do it one at a | ||
| 5343 | ;; time). | ||
| 5344 | (let ((entry (assq specifier display-buffer-macro-specifiers))) | ||
| 5345 | (dolist (item (cdr entry)) | ||
| 5346 | (setq normalized (cons item normalized))))))) | ||
| 5347 | ;; Reverse list. | ||
| 5348 | (nreverse normalized)) | ||
| 5349 | ((setq entry (assq specifiers display-buffer-macro-specifiers)) | ||
| 5350 | ;; A macro specifier. | ||
| 5351 | (cdr entry)) | ||
| 5352 | ((or other-frame (with-no-warnings pop-up-frames)) | ||
| 5353 | ;; `special-display-p' group. | ||
| 5354 | (if (and (with-no-warnings special-display-function) | ||
| 5355 | ;; `special-display-p' returns either t or a list | ||
| 5356 | ;; of frame parameters to pass to | ||
| 5357 | ;; `special-display-function'. | ||
| 5358 | (setq pars (with-no-warnings | ||
| 5359 | (special-display-p buffer-name)))) | ||
| 5360 | (list (list 'fun-with-args | ||
| 5361 | (with-no-warnings special-display-function) | ||
| 5362 | (when (listp pars) pars))) | ||
| 5363 | ;; Pop up another frame. | ||
| 5364 | (cddr (assq 'other-frame display-buffer-macro-specifiers)))) | ||
| 5365 | (t | ||
| 5366 | ;; In any other case pop up a new window. | ||
| 5367 | (cdr (assq 'same-frame-other-window | ||
| 5368 | display-buffer-macro-specifiers))))) | ||
| 5369 | |||
| 5370 | ;; Handle the old meaning of the LABEL argument of `display-buffer'. | ||
| 5315 | (cond | 5371 | (cond |
| 5316 | ((not specifiers) | 5372 | ((or (memq label '(visible 0 t)) (frame-live-p label)) |
| 5317 | nil) | 5373 | ;; LABEL must be one of visible (and visible frame), 0 (any |
| 5318 | ((listp specifiers) | 5374 | ;; visible or iconfied frame), t (any frame), or a live frame. |
| 5319 | ;; If SPECIFIERS is a list, we assume it is a list of specifiers. | 5375 | (cons `(reuse-window nil same ,label) specifier)) |
| 5320 | (dolist (specifier specifiers) | 5376 | ((or other-frame |
| 5321 | (cond | 5377 | (with-no-warnings pop-up-frames) |
| 5322 | ((consp specifier) | 5378 | (with-no-warnings display-buffer-reuse-frames)) |
| 5323 | (setq normalized (cons specifier normalized))) | 5379 | (cons '(reuse-window nil same 0) specifier)) |
| 5324 | ((eq specifier 'other-window) | ||
| 5325 | ;; `other-window' must be treated separately. | ||
| 5326 | (let ((entry (assq (if other-frame | ||
| 5327 | 'other-frame | ||
| 5328 | 'same-frame-other-window) | ||
| 5329 | display-buffer-macro-specifiers))) | ||
| 5330 | (dolist (item (cdr entry)) | ||
| 5331 | (setq normalized (cons item normalized))))) | ||
| 5332 | ((symbolp specifier) | ||
| 5333 | ;; Might be a macro specifier, try to expand it (the cdr is a | ||
| 5334 | ;; list and we have to reverse it later, so do it one at a | ||
| 5335 | ;; time). | ||
| 5336 | (let ((entry (assq specifier display-buffer-macro-specifiers))) | ||
| 5337 | (dolist (item (cdr entry)) | ||
| 5338 | (setq normalized (cons item normalized))))))) | ||
| 5339 | ;; Reverse list. | ||
| 5340 | (nreverse normalized)) | ||
| 5341 | ((setq entry (assq specifiers display-buffer-macro-specifiers)) | ||
| 5342 | ;; A macro specifier. | ||
| 5343 | (cdr entry)) | ||
| 5344 | ((or other-frame (with-no-warnings pop-up-frames)) | ||
| 5345 | ;; Pop up another frame. | ||
| 5346 | (cdr (assq 'other-frame display-buffer-macro-specifiers))) | ||
| 5347 | (t | 5380 | (t |
| 5348 | ;; In any other case pop up a new window. | 5381 | specifier)))) |
| 5349 | (cdr (assq 'same-frame-other-window display-buffer-macro-specifiers)))))) | ||
| 5350 | 5382 | ||
| 5351 | (defun display-buffer-normalize-options (buffer-or-name) | 5383 | (defun display-buffer-normalize-options (buffer-or-name) |
| 5352 | "Subroutine of `display-buffer-normalize-specifiers'. | 5384 | "Subroutine of `display-buffer-normalize-specifiers'. |
| @@ -5560,7 +5592,7 @@ specifiers: | |||
| 5560 | ;; Overriding user specifiers. | 5592 | ;; Overriding user specifiers. |
| 5561 | (car list) | 5593 | (car list) |
| 5562 | ;; Application specifiers. | 5594 | ;; Application specifiers. |
| 5563 | (display-buffer-normalize-argument | 5595 | (display-buffer-normalize-arguments |
| 5564 | buffer-name specifiers label other-frame) | 5596 | buffer-name specifiers label other-frame) |
| 5565 | ;; Emacs 23 compatibility specifiers. | 5597 | ;; Emacs 23 compatibility specifiers. |
| 5566 | (unless display-buffer-normalize-options-inhibit | 5598 | (unless display-buffer-normalize-options-inhibit |
| @@ -5623,6 +5655,21 @@ override SPECIFIERS by adding an entry to `display-buffer-alist' | |||
| 5623 | whose car contains LABEL and whose cdr specifies the preferred | 5655 | whose car contains LABEL and whose cdr specifies the preferred |
| 5624 | alternative display method. | 5656 | alternative display method. |
| 5625 | 5657 | ||
| 5658 | The following values of LABEL have a special meaning and allow to | ||
| 5659 | specify the set of frames to investigate when the buffer already | ||
| 5660 | appears in a window: | ||
| 5661 | |||
| 5662 | `visible' - the set of visible frames. | ||
| 5663 | |||
| 5664 | 0 - the set of visible or iconified frames. | ||
| 5665 | |||
| 5666 | t - the set of all frames. | ||
| 5667 | |||
| 5668 | A live frame - the set containing that frame as its only element. | ||
| 5669 | |||
| 5670 | If the buffer is already displayed in a window on a frame in the | ||
| 5671 | specified set, return that window. | ||
| 5672 | |||
| 5626 | The method to display the buffer is derived by combining the | 5673 | The method to display the buffer is derived by combining the |
| 5627 | values of `display-buffer-alist' and SPECIFIERS. Highest | 5674 | values of `display-buffer-alist' and SPECIFIERS. Highest |
| 5628 | priority is given to overriding elements of | 5675 | priority is given to overriding elements of |
| @@ -5676,12 +5723,12 @@ this list as arguments." | |||
| 5676 | (or (and (window-live-p window) window) | 5723 | (or (and (window-live-p window) window) |
| 5677 | ;; Try reusing a window showing BUFFER on any visible or | 5724 | ;; Try reusing a window showing BUFFER on any visible or |
| 5678 | ;; iconfied frame. | 5725 | ;; iconfied frame. |
| 5679 | (display-buffer-reuse-window buffer '(nil buffer 0)) | 5726 | (display-buffer-reuse-window buffer `(nil ,buffer 0)) |
| 5680 | ;; Try reusing a window not showing BUFFER on any visible or | 5727 | ;; Try reusing a window not showing BUFFER on any visible or |
| 5681 | ;; iconified frame. | 5728 | ;; iconified frame. |
| 5682 | (display-buffer-reuse-window buffer '(nil other 0)) | 5729 | (display-buffer-reuse-window buffer '(nil other 0)) |
| 5683 | ;; Try making a new frame. | 5730 | ;; Eli says it's better to never try making a new frame. |
| 5684 | (display-buffer-pop-up-frame buffer) | 5731 | ;; (display-buffer-pop-up-frame buffer) |
| 5685 | ;; Try using a weakly dedicated window. | 5732 | ;; Try using a weakly dedicated window. |
| 5686 | (display-buffer-reuse-window | 5733 | (display-buffer-reuse-window |
| 5687 | buffer '(nil nil t) '((reuse-window-dedicated . weak))) | 5734 | buffer '(nil nil t) '((reuse-window-dedicated . weak))) |
| @@ -6726,7 +6773,7 @@ value of `display-buffer-alist'." | |||
| 6726 | (when (or display-buffer-reuse-frames pop-up-frames) | 6773 | (when (or display-buffer-reuse-frames pop-up-frames) |
| 6727 | ;; "0" (all visible and iconified frames) is hardcoded in | 6774 | ;; "0" (all visible and iconified frames) is hardcoded in |
| 6728 | ;; Emacs 23. | 6775 | ;; Emacs 23. |
| 6729 | 0)) | 6776 | 0)) |
| 6730 | (unless (memq even-window-heights '(nil unset)) | 6777 | (unless (memq even-window-heights '(nil unset)) |
| 6731 | (cons 'reuse-window-even-sizes t))) | 6778 | (cons 'reuse-window-even-sizes t))) |
| 6732 | no-custom) | 6779 | no-custom) |