mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-18 02:47:36 +00:00
Fix display-buffer interactive spec, and fixes for pop-to-buffer*.
* lisp/window.el (display-buffer): Restore interactive spec. (display-buffer-same-window, display-buffer-other-window): New functions. (pop-to-buffer-1): New function. Use the above. (pop-to-buffer, pop-to-buffer-same-window): Use it. (pop-to-buffer-other-window, pop-to-buffer-other-frame): Deleted. * lisp/view.el (view-buffer-other-window, view-buffer-other-frame): Just use pop-to-buffer.
This commit is contained in:
parent
6ed17f119f
commit
437014c8ad
3 changed files with 71 additions and 49 deletions
|
|
@ -1,3 +1,15 @@
|
|||
2011-09-01 Chong Yidong <cyd@stupidchicken.com>
|
||||
|
||||
* window.el (display-buffer): Restore interactive spec.
|
||||
(display-buffer-same-window, display-buffer-other-window): New
|
||||
functions.
|
||||
(pop-to-buffer-1): New function. Use the above.
|
||||
(pop-to-buffer, pop-to-buffer-same-window): Use it.
|
||||
(pop-to-buffer-other-window, pop-to-buffer-other-frame): Deleted.
|
||||
|
||||
* view.el (view-buffer-other-window, view-buffer-other-frame):
|
||||
Just use pop-to-buffer.
|
||||
|
||||
2011-09-01 Thierry Volpiatto <thierry.volpiatto@gmail.com>
|
||||
|
||||
* vc/vc-rcs.el (vc-rcs-responsible-p): Handle directories. (Bug#9391)
|
||||
|
|
|
|||
|
|
@ -338,7 +338,8 @@ Optional argument EXIT-ACTION is either nil or a function with buffer as
|
|||
argument. This function is called when finished viewing buffer. Use
|
||||
this argument instead of explicitly setting `view-exit-action'."
|
||||
(interactive "bIn other window view buffer:\nP")
|
||||
(pop-to-buffer-other-window buffer)
|
||||
(let ((pop-up-windows t))
|
||||
(pop-to-buffer buffer t))
|
||||
(view-mode-enter nil exit-action))
|
||||
|
||||
;;;###autoload
|
||||
|
|
@ -358,7 +359,8 @@ Optional argument EXIT-ACTION is either nil or a function with buffer as
|
|||
argument. This function is called when finished viewing buffer. Use
|
||||
this argument instead of explicitly setting `view-exit-action'."
|
||||
(interactive "bView buffer in other frame: \nP")
|
||||
(pop-to-buffer-other-frame buffer)
|
||||
(let ((pop-up-frames t))
|
||||
(pop-to-buffer buffer t))
|
||||
(view-mode-enter nil exit-action))
|
||||
|
||||
;;;###autoload
|
||||
|
|
|
|||
102
lisp/window.el
102
lisp/window.el
|
|
@ -4674,6 +4674,7 @@ This is an ACTION just like in `display-buffer-alist'.")
|
|||
|
||||
(defun display-buffer (&optional buffer-or-name action frame)
|
||||
"Display BUFFER in some window."
|
||||
(interactive "BDisplay buffer:\nP")
|
||||
(let* ((buffer (window-normalize-buffer-to-display buffer-or-name))
|
||||
(buffer-name (buffer-name buffer))
|
||||
(user-action
|
||||
|
|
@ -4736,6 +4737,27 @@ its documentation for additional customization information."
|
|||
;;(make-frame-visible (window-frame old-window))
|
||||
))
|
||||
|
||||
;;; Functions for use via `display-buffer-alist'.
|
||||
|
||||
(defun display-buffer-same-window (buffer alist)
|
||||
"Display BUFFER in the selected window, and return the window.
|
||||
If BUFFER cannot be displayed in the selected window (usually
|
||||
because it is dedicated to another buffer), return nil."
|
||||
(let ((norecord (cadr (assq 'norecord alist))))
|
||||
(cond
|
||||
((eq buffer (window-buffer))
|
||||
(selected-window))
|
||||
((not (or (window-minibuffer-p) (window-dedicated-p)))
|
||||
(set-window-buffer nil buffer)
|
||||
(selected-window)))))
|
||||
|
||||
(defun display-buffer-other-window (buffer alist)
|
||||
"Display BUFFER in another window, and return BUFFER.
|
||||
If BUFFER cannot be displayed in another window, just return nil."
|
||||
(display-buffer-default buffer t))
|
||||
|
||||
;;; Display + selection commands:
|
||||
|
||||
(defun pop-to-buffer (buffer-or-name &optional other-window norecord)
|
||||
"Select buffer BUFFER-OR-NAME in some window, preferably a different one.
|
||||
BUFFER-OR-NAME may be a buffer, a string \(a buffer name), or
|
||||
|
|
@ -4759,20 +4781,7 @@ of `display-buffer' for additional customization information.
|
|||
Optional third arg NORECORD non-nil means do not put this buffer
|
||||
at the front of the list of recently selected ones."
|
||||
(interactive "BPop to buffer:\nP")
|
||||
(let ((buffer (window-normalize-buffer-to-display buffer-or-name))
|
||||
(old-window (selected-window))
|
||||
(old-frame (selected-frame))
|
||||
new-window new-frame)
|
||||
(set-buffer buffer)
|
||||
(setq new-window (display-buffer buffer other-window))
|
||||
(setq new-frame (window-frame new-window))
|
||||
(if (eq old-frame new-frame)
|
||||
;; Make sure new-window gets selected (Bug#8615), (Bug#6954).
|
||||
(select-window new-window norecord)
|
||||
;; `display-buffer' has chosen another frame, make sure it gets
|
||||
;; input focus and is risen.
|
||||
(select-frame-set-input-focus new-frame norecord))
|
||||
buffer))
|
||||
(pop-to-buffer-1 buffer-or-name (if other-window t nil) norecord))
|
||||
|
||||
(defun pop-to-buffer-same-window (&optional buffer-or-name norecord)
|
||||
"Pop to buffer specified by BUFFER-OR-NAME in the selected window.
|
||||
|
|
@ -4781,40 +4790,39 @@ the selected window, usually because it is dedicated to another
|
|||
buffer. Optional arguments BUFFER-OR-NAME and NORECORD are as
|
||||
for `pop-to-buffer'."
|
||||
(interactive "BPop to buffer in selected window:\nP")
|
||||
(let ((buffer (window-normalize-buffer-to-display buffer-or-name)))
|
||||
(cond
|
||||
((eq buffer (window-buffer))
|
||||
(unless norecord
|
||||
(select-window (selected-window)))
|
||||
(set-buffer buffer))
|
||||
((or (window-minibuffer-p) (window-dedicated-p))
|
||||
(pop-to-buffer buffer norecord))
|
||||
(t
|
||||
(set-window-buffer nil buffer)
|
||||
(unless norecord
|
||||
(select-window (selected-window)))
|
||||
(set-buffer buffer)))))
|
||||
(pop-to-buffer-1 buffer-or-name 'same-window norecord))
|
||||
|
||||
(defun pop-to-buffer-other-window (&optional buffer-or-name norecord)
|
||||
"Pop to buffer specified by 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
|
||||
are as for `pop-to-buffer'."
|
||||
(interactive "BPop to buffer in another window:\nP")
|
||||
(let ((pop-up-windows t)
|
||||
same-window-buffer-names same-window-regexps)
|
||||
(pop-to-buffer buffer-or-name t norecord)))
|
||||
|
||||
(defun pop-to-buffer-other-frame (&optional buffer-or-name norecord)
|
||||
"Pop to buffer specified by BUFFER-OR-NAME on another frame.
|
||||
The selected frame will be used only if there's no other choice.
|
||||
Optional arguments BUFFER-OR-NAME and NORECORD are as for
|
||||
`pop-to-buffer'."
|
||||
(interactive "BPop to buffer on another frame:\nP")
|
||||
(let ((pop-up-frames t)
|
||||
same-window-buffer-names same-window-regexps)
|
||||
(pop-to-buffer buffer-or-name t norecord)))
|
||||
(defun pop-to-buffer-1 (buffer-or-name window-choice norecord)
|
||||
(set-buffer (window-normalize-buffer-to-display
|
||||
;; BUFFER-OR-NAME nil means another buffer.
|
||||
(or buffer-or-name
|
||||
(other-buffer (current-buffer)))))
|
||||
(let ((old-window (selected-window))
|
||||
(old-frame (selected-frame))
|
||||
(same-window-buffer-names same-window-buffer-names)
|
||||
(same-window-regexps same-window-regexps))
|
||||
(if (eq window-choice t)
|
||||
(setq same-window-buffer-names nil
|
||||
same-window-regexps nil))
|
||||
(let* ((action
|
||||
;; Based on the WINDOW-CHOICE argument, choose an action
|
||||
;; argument to pass to `display-buffer'.
|
||||
(cond
|
||||
((null window-choice)
|
||||
'((display-buffer-other-window display-buffer-same-window)))
|
||||
((eq window-choice 'same-window)
|
||||
'((display-buffer-same-window display-buffer-other-window)))
|
||||
(t
|
||||
'((display-buffer-other-window)))))
|
||||
(window (display-buffer (current-buffer) action))
|
||||
(frame (window-frame window)))
|
||||
(if (eq frame old-frame)
|
||||
;; Make sure new window gets selected (Bug#8615), (Bug#6954).
|
||||
(select-window window norecord)
|
||||
;; If `display-buffer' has chosen another frame, make sure it
|
||||
;; gets input focus.
|
||||
(select-frame-set-input-focus frame norecord))
|
||||
(current-buffer))))
|
||||
|
||||
(defun read-buffer-to-switch (prompt)
|
||||
"Read the name of a buffer to switch to, prompting with PROMPT.
|
||||
|
|
|
|||
Loading…
Reference in a new issue