From 9b9c9e3acbd2285e87e0233d4cfc83c65f2235d1 Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Thu, 16 Jun 2011 09:31:51 +0200 Subject: Improve cohabitation of pop-up-frames and second argument of display-buffer (bug#8865). * window.el (display-buffer-normalize-specifiers-1): Respect current value of pop-up-frames for most reasonable values of second argument of display-buffer (Bug#8865). --- lisp/window.el | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'lisp/window.el') diff --git a/lisp/window.el b/lisp/window.el index 5493893d4c1..1661fedfe25 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -3453,9 +3453,8 @@ specific buffers." ;; (bw-finetune wins) ;; (message "Done in %d rounds" round) )) - - +;;; Displaying buffers. (defconst display-buffer-default-specifiers '((reuse-window nil same visible) (pop-up-window (largest . nil) (lru . nil)) @@ -4909,9 +4908,12 @@ BUFFER-OR-NAME and return that buffer." (defun display-buffer-normalize-specifiers-1 (specifiers) "Subroutine of `display-buffer-normalize-specifiers'. SPECIFIERS is the SPECIFIERS argument of `display-buffer'." - (let (normalized) + (let (normalized entry) (cond + ((not specifiers) + nil) ((listp specifiers) + ;; If SPECIFIERS is a list, we assume it is a list of specifiers. (dolist (specifier specifiers) (cond ((consp specifier) @@ -4924,21 +4926,17 @@ SPECIFIERS is the SPECIFIERS argument of `display-buffer'." (dolist (item (cdr entry)) (setq normalized (cons item normalized))))))) ;; Reverse list. - (setq normalized (nreverse normalized))) - ;; The two cases below must come from the SPECIFIERS argument of - ;; `display-buffer'. - ((eq specifiers 't) - ;; Historically t means "other window". Eventually we should get - ;; rid of this. - (setq normalized - (cdr (assq 'other-window display-buffer-macro-specifiers)) - normalized)) - ((symbolp specifiers) - ;; We allow scalar specifiers in calls of `display-buffer'. - (let ((entry (assq specifiers display-buffer-macro-specifiers))) - (when entry (setq normalized (cdr entry)))))) - - normalized)) + (nreverse normalized)) + ((and (not (eq specifiers 'other-window)) + (setq entry (assq specifiers display-buffer-macro-specifiers))) + ;; A macro specifier. + (cdr entry)) + ((memq pop-up-frames '(nil unset)) + ;; Pop up a new window. + (cdr (assq 'other-window display-buffer-macro-specifiers))) + (t + ;; Pop up a new frame. + (cdr (assq 'other-frame display-buffer-macro-specifiers)))))) (defun display-buffer-normalize-specifiers-2 (&optional buffer-or-name) "Subroutine of `display-buffer-normalize-specifiers'. -- cgit v1.2.3 From 981d5c0932ed7a9cf66e48fb5d220151722a31c0 Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Thu, 16 Jun 2011 10:55:08 +0200 Subject: Fix doc-strings of switch-to-buffer family functions (bug#8875). (switch-to-buffer-same-frame, switch-to-buffer-other-window) (switch-to-buffer-other-window-same-frame) (switch-to-buffer-other-frame): Fix doc-strings. Reported by Drew Adams (Bug#8875). --- lisp/ChangeLog | 4 ++++ lisp/window.el | 16 ++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'lisp/window.el') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b4b726c7407..92939d77fe4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -3,6 +3,10 @@ * window.el (display-buffer-normalize-specifiers-1): Respect current value of pop-up-frames for most reasonable values of second argument of display-buffer (Bug#8865). + (switch-to-buffer-same-frame, switch-to-buffer-other-window) + (switch-to-buffer-other-window-same-frame) + (switch-to-buffer-other-frame): Fix doc-strings. Reported by Drew + Adams (Bug#8875). 2011-06-15 Stefan Monnier diff --git a/lisp/window.el b/lisp/window.el index 1661fedfe25..71723818794 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -5511,8 +5511,8 @@ functions should call `pop-to-buffer-same-window' instead." (defun switch-to-buffer-same-frame (buffer-or-name &optional norecord) "Switch to buffer BUFFER-OR-NAME in a window on the selected frame. Another frame will be used only if there is no other choice. -Optional arguments BUFFER-OR-NAME and NORECORD have the same -meaning as for `switch-to-buffer'. +Arguments BUFFER-OR-NAME and NORECORD have the same meaning as +for `switch-to-buffer'. This function is intended for interactive use only. Lisp functions should call `pop-to-buffer-same-frame' instead." @@ -5525,8 +5525,8 @@ functions should call `pop-to-buffer-same-frame' instead." "Switch to buffer BUFFER-OR-NAME in another window. The selected window will be used only if there is no other choice. Windows on the selected frame are preferred to windows -on other frames. Optional arguments BUFFER-OR-NAME and NORECORD -have the same meaning as for `switch-to-buffer'. +on other frames. Arguments BUFFER-OR-NAME and NORECORD have the +same meaning as for `switch-to-buffer'. This function is intended for interactive use only. Lisp functions should call `pop-to-buffer-other-window' instead." @@ -5538,8 +5538,8 @@ functions should call `pop-to-buffer-other-window' instead." (defun switch-to-buffer-other-window-same-frame (buffer-or-name &optional norecord) "Switch to buffer BUFFER-OR-NAME in another window on the selected frame. The selected window or another frame will be used only if there -is no other choice. Optional arguments BUFFER-OR-NAME and -NORECORD have the same meaning as for `switch-to-buffer'. +is no other choice. Arguments BUFFER-OR-NAME and NORECORD have +the same meaning as for `switch-to-buffer'. This function is intended for interactive use only. Lisp functions should call `pop-to-buffer-other-window-same-frame' @@ -5552,8 +5552,8 @@ instead." (defun switch-to-buffer-other-frame (buffer-or-name &optional norecord) "Switch to buffer BUFFER-OR-NAME on another frame. The same frame will be used only if there is no other choice. -Optional arguments BUFFER-OR-NAME and NORECORD have the same -meaning as for `switch-to-buffer'. +Arguments BUFFER-OR-NAME and NORECORD have the same meaning +as for `switch-to-buffer'. This function is intended for interactive use only. Lisp functions should call `pop-to-buffer-other-frame' instead." -- cgit v1.2.3 From 9c2755e9b449297d3eba5d2004dca16af6a13bab Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Thu, 16 Jun 2011 11:21:56 +0200 Subject: Never ever pop up a new frame in noninteractive mode (bug#8857). (display-buffer): Don't check noninteractive when calling display-buffer-pop-up-frame. (display-buffer-pop-up-frame): Never pop up a frame in noninteractive mode (Bug#8857). --- lisp/ChangeLog | 4 ++++ lisp/window.el | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'lisp/window.el') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 92939d77fe4..77ee2fe27a6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -7,6 +7,10 @@ (switch-to-buffer-other-window-same-frame) (switch-to-buffer-other-frame): Fix doc-strings. Reported by Drew Adams (Bug#8875). + (display-buffer): Don't check noninteractive when calling + display-buffer-pop-up-frame. + (display-buffer-pop-up-frame): Never pop up a frame in + noninteractive mode (Bug#8857). 2011-06-15 Stefan Monnier diff --git a/lisp/window.el b/lisp/window.el index 71723818794..5f9e761b3d7 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -4704,7 +4704,8 @@ non-nil means to make a new frame on graphic displays only. SPECIFIERS must be a list of buffer display specifiers, see the documentation of `display-buffer-alist' for a description." - (unless (and graphic-only (not (display-graphic-p))) + (unless (or (and graphic-only (not (display-graphic-p))) + noninteractive) (let* ((selected-window (selected-window)) (function (or (cdr (assq 'pop-up-frame-function specifiers)) 'make-frame)) @@ -5299,8 +5300,8 @@ this list as arguments." ;; Try reusing a window not showing BUFFER on any visible or ;; iconified frame. (display-buffer-reuse-window buffer '(nil other 0)) - ;; Try making a new frame (but not in batch mode). - (and (not noninteractive) (display-buffer-pop-up-frame buffer)) + ;; Try making a new frame. + (display-buffer-pop-up-frame buffer) ;; Try using a weakly dedicated window. (display-buffer-reuse-window buffer '(nil nil t) '((reuse-window-dedicated . weak))) -- cgit v1.2.3 From 67222e1dfff23c792ecdd4995dd144c1b41027c9 Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Thu, 16 Jun 2011 16:01:46 +0200 Subject: Have enlarge-/shrink-window not report errors in most cases (bug#8862). * window.el (enlarge-window, shrink-window): Don't report an error when the window can't be resized as requested (Bug#8862). --- lisp/ChangeLog | 2 ++ lisp/window.el | 28 +++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) (limited to 'lisp/window.el') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 77ee2fe27a6..b5d76e3f533 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -11,6 +11,8 @@ display-buffer-pop-up-frame. (display-buffer-pop-up-frame): Never pop up a frame in noninteractive mode (Bug#8857). + (enlarge-window, shrink-window): Don't report an error when the + window can't be resized as requested (Bug#8862). 2011-06-15 Stefan Monnier diff --git a/lisp/window.el b/lisp/window.el index 5f9e761b3d7..aa874b8e503 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -2044,7 +2044,18 @@ make selected window wider by DELTA columns. If DELTA is negative, shrink selected window by -DELTA lines or columns. Return nil." (interactive "p") - (resize-window (selected-window) delta horizontal)) + (cond + ((zerop delta)) + ((window-size-fixed-p nil horizontal) + (error "Selected window has fixed size")) + ((window-resizable-p nil delta horizontal) + (resize-window nil delta horizontal)) + (t + (resize-window + nil (if (> delta 0) + (window-max-delta nil horizontal) + (- (window-min-delta nil horizontal))) + horizontal)))) (defun shrink-window (delta &optional horizontal) "Make selected window DELTA lines smaller. @@ -2054,7 +2065,18 @@ make selected window narrower by DELTA columns. If DELTA is negative, enlarge selected window by -DELTA lines or columns. Return nil." (interactive "p") - (resize-window (selected-window) (- delta) horizontal)) + (cond + ((zerop delta)) + ((window-size-fixed-p nil horizontal) + (error "Selected window has fixed size")) + ((window-resizable-p nil (- delta) horizontal) + (resize-window nil (- delta) horizontal)) + (t + (resize-window + nil (if (> delta 0) + (- (window-min-delta nil horizontal)) + (window-max-delta nil horizontal)) + horizontal)))) (defun maximize-window (&optional window) "Maximize WINDOW. @@ -4932,7 +4954,7 @@ SPECIFIERS is the SPECIFIERS argument of `display-buffer'." (setq entry (assq specifiers display-buffer-macro-specifiers))) ;; A macro specifier. (cdr entry)) - ((memq pop-up-frames '(nil unset)) + ((with-no-warnings (memq pop-up-frames '(nil unset))) ;; Pop up a new window. (cdr (assq 'other-window display-buffer-macro-specifiers))) (t -- cgit v1.2.3