aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2011-09-01 13:04:30 -0400
committerChong Yidong2011-09-01 13:04:30 -0400
commit437014c8adcd604bdec350015d89eab1d7c12ec2 (patch)
tree0f99a4185c3a4be031f3ee75af62d88cea64aa66
parent6ed17f119f52dee3199a3efbdf8a92b93f5f8fd0 (diff)
downloademacs-437014c8adcd604bdec350015d89eab1d7c12ec2.tar.gz
emacs-437014c8adcd604bdec350015d89eab1d7c12ec2.zip
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.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/view.el6
-rw-r--r--lisp/window.el104
3 files changed, 72 insertions, 50 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b4b95fb4074..e51cdb9137a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12011-09-01 Chong Yidong <cyd@stupidchicken.com>
2
3 * window.el (display-buffer): Restore interactive spec.
4 (display-buffer-same-window, display-buffer-other-window): New
5 functions.
6 (pop-to-buffer-1): New function. Use the above.
7 (pop-to-buffer, pop-to-buffer-same-window): Use it.
8 (pop-to-buffer-other-window, pop-to-buffer-other-frame): Deleted.
9
10 * view.el (view-buffer-other-window, view-buffer-other-frame):
11 Just use pop-to-buffer.
12
12011-09-01 Thierry Volpiatto <thierry.volpiatto@gmail.com> 132011-09-01 Thierry Volpiatto <thierry.volpiatto@gmail.com>
2 14
3 * vc/vc-rcs.el (vc-rcs-responsible-p): Handle directories. (Bug#9391) 15 * vc/vc-rcs.el (vc-rcs-responsible-p): Handle directories. (Bug#9391)
diff --git a/lisp/view.el b/lisp/view.el
index be011d217fc..96fecd9df1c 100644
--- a/lisp/view.el
+++ b/lisp/view.el
@@ -338,7 +338,8 @@ Optional argument EXIT-ACTION is either nil or a function with buffer as
338argument. This function is called when finished viewing buffer. Use 338argument. This function is called when finished viewing buffer. Use
339this argument instead of explicitly setting `view-exit-action'." 339this argument instead of explicitly setting `view-exit-action'."
340 (interactive "bIn other window view buffer:\nP") 340 (interactive "bIn other window view buffer:\nP")
341 (pop-to-buffer-other-window buffer) 341 (let ((pop-up-windows t))
342 (pop-to-buffer buffer t))
342 (view-mode-enter nil exit-action)) 343 (view-mode-enter nil exit-action))
343 344
344;;;###autoload 345;;;###autoload
@@ -358,7 +359,8 @@ Optional argument EXIT-ACTION is either nil or a function with buffer as
358argument. This function is called when finished viewing buffer. Use 359argument. This function is called when finished viewing buffer. Use
359this argument instead of explicitly setting `view-exit-action'." 360this argument instead of explicitly setting `view-exit-action'."
360 (interactive "bView buffer in other frame: \nP") 361 (interactive "bView buffer in other frame: \nP")
361 (pop-to-buffer-other-frame buffer) 362 (let ((pop-up-frames t))
363 (pop-to-buffer buffer t))
362 (view-mode-enter nil exit-action)) 364 (view-mode-enter nil exit-action))
363 365
364;;;###autoload 366;;;###autoload
diff --git a/lisp/window.el b/lisp/window.el
index 50deb035420..11f4920c24f 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -4674,6 +4674,7 @@ This is an ACTION just like in `display-buffer-alist'.")
4674 4674
4675(defun display-buffer (&optional buffer-or-name action frame) 4675(defun display-buffer (&optional buffer-or-name action frame)
4676 "Display BUFFER in some window." 4676 "Display BUFFER in some window."
4677 (interactive "BDisplay buffer:\nP")
4677 (let* ((buffer (window-normalize-buffer-to-display buffer-or-name)) 4678 (let* ((buffer (window-normalize-buffer-to-display buffer-or-name))
4678 (buffer-name (buffer-name buffer)) 4679 (buffer-name (buffer-name buffer))
4679 (user-action 4680 (user-action
@@ -4736,6 +4737,27 @@ its documentation for additional customization information."
4736 ;;(make-frame-visible (window-frame old-window)) 4737 ;;(make-frame-visible (window-frame old-window))
4737 )) 4738 ))
4738 4739
4740;;; Functions for use via `display-buffer-alist'.
4741
4742(defun display-buffer-same-window (buffer alist)
4743 "Display BUFFER in the selected window, and return the window.
4744If BUFFER cannot be displayed in the selected window (usually
4745because it is dedicated to another buffer), return nil."
4746 (let ((norecord (cadr (assq 'norecord alist))))
4747 (cond
4748 ((eq buffer (window-buffer))
4749 (selected-window))
4750 ((not (or (window-minibuffer-p) (window-dedicated-p)))
4751 (set-window-buffer nil buffer)
4752 (selected-window)))))
4753
4754(defun display-buffer-other-window (buffer alist)
4755 "Display BUFFER in another window, and return BUFFER.
4756If BUFFER cannot be displayed in another window, just return nil."
4757 (display-buffer-default buffer t))
4758
4759;;; Display + selection commands:
4760
4739(defun pop-to-buffer (buffer-or-name &optional other-window norecord) 4761(defun pop-to-buffer (buffer-or-name &optional other-window norecord)
4740 "Select buffer BUFFER-OR-NAME in some window, preferably a different one. 4762 "Select buffer BUFFER-OR-NAME in some window, preferably a different one.
4741BUFFER-OR-NAME may be a buffer, a string \(a buffer name), or 4763BUFFER-OR-NAME may be a buffer, a string \(a buffer name), or
@@ -4759,20 +4781,7 @@ of `display-buffer' for additional customization information.
4759Optional third arg NORECORD non-nil means do not put this buffer 4781Optional third arg NORECORD non-nil means do not put this buffer
4760at the front of the list of recently selected ones." 4782at the front of the list of recently selected ones."
4761 (interactive "BPop to buffer:\nP") 4783 (interactive "BPop to buffer:\nP")
4762 (let ((buffer (window-normalize-buffer-to-display buffer-or-name)) 4784 (pop-to-buffer-1 buffer-or-name (if other-window t nil) norecord))
4763 (old-window (selected-window))
4764 (old-frame (selected-frame))
4765 new-window new-frame)
4766 (set-buffer buffer)
4767 (setq new-window (display-buffer buffer other-window))
4768 (setq new-frame (window-frame new-window))
4769 (if (eq old-frame new-frame)
4770 ;; Make sure new-window gets selected (Bug#8615), (Bug#6954).
4771 (select-window new-window norecord)
4772 ;; `display-buffer' has chosen another frame, make sure it gets
4773 ;; input focus and is risen.
4774 (select-frame-set-input-focus new-frame norecord))
4775 buffer))
4776 4785
4777(defun pop-to-buffer-same-window (&optional buffer-or-name norecord) 4786(defun pop-to-buffer-same-window (&optional buffer-or-name norecord)
4778 "Pop to buffer specified by BUFFER-OR-NAME in the selected window. 4787 "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
4781buffer. Optional arguments BUFFER-OR-NAME and NORECORD are as 4790buffer. Optional arguments BUFFER-OR-NAME and NORECORD are as
4782for `pop-to-buffer'." 4791for `pop-to-buffer'."
4783 (interactive "BPop to buffer in selected window:\nP") 4792 (interactive "BPop to buffer in selected window:\nP")
4784 (let ((buffer (window-normalize-buffer-to-display buffer-or-name))) 4793 (pop-to-buffer-1 buffer-or-name 'same-window norecord))
4785 (cond 4794
4786 ((eq buffer (window-buffer)) 4795(defun pop-to-buffer-1 (buffer-or-name window-choice norecord)
4787 (unless norecord 4796 (set-buffer (window-normalize-buffer-to-display
4788 (select-window (selected-window))) 4797 ;; BUFFER-OR-NAME nil means another buffer.
4789 (set-buffer buffer)) 4798 (or buffer-or-name
4790 ((or (window-minibuffer-p) (window-dedicated-p)) 4799 (other-buffer (current-buffer)))))
4791 (pop-to-buffer buffer norecord)) 4800 (let ((old-window (selected-window))
4792 (t 4801 (old-frame (selected-frame))
4793 (set-window-buffer nil buffer) 4802 (same-window-buffer-names same-window-buffer-names)
4794 (unless norecord 4803 (same-window-regexps same-window-regexps))
4795 (select-window (selected-window))) 4804 (if (eq window-choice t)
4796 (set-buffer buffer))))) 4805 (setq same-window-buffer-names nil
4797 4806 same-window-regexps nil))
4798(defun pop-to-buffer-other-window (&optional buffer-or-name norecord) 4807 (let* ((action
4799 "Pop to buffer specified by BUFFER-OR-NAME in another window. 4808 ;; Based on the WINDOW-CHOICE argument, choose an action
4800The selected window will be used only if there is no other 4809 ;; argument to pass to `display-buffer'.
4801choice. Windows on the selected frame are preferred to windows 4810 (cond
4802on other frames. Optional arguments BUFFER-OR-NAME and NORECORD 4811 ((null window-choice)
4803are as for `pop-to-buffer'." 4812 '((display-buffer-other-window display-buffer-same-window)))
4804 (interactive "BPop to buffer in another window:\nP") 4813 ((eq window-choice 'same-window)
4805 (let ((pop-up-windows t) 4814 '((display-buffer-same-window display-buffer-other-window)))
4806 same-window-buffer-names same-window-regexps) 4815 (t
4807 (pop-to-buffer buffer-or-name t norecord))) 4816 '((display-buffer-other-window)))))
4808 4817 (window (display-buffer (current-buffer) action))
4809(defun pop-to-buffer-other-frame (&optional buffer-or-name norecord) 4818 (frame (window-frame window)))
4810 "Pop to buffer specified by BUFFER-OR-NAME on another frame. 4819 (if (eq frame old-frame)
4811The selected frame will be used only if there's no other choice. 4820 ;; Make sure new window gets selected (Bug#8615), (Bug#6954).
4812Optional arguments BUFFER-OR-NAME and NORECORD are as for 4821 (select-window window norecord)
4813`pop-to-buffer'." 4822 ;; If `display-buffer' has chosen another frame, make sure it
4814 (interactive "BPop to buffer on another frame:\nP") 4823 ;; gets input focus.
4815 (let ((pop-up-frames t) 4824 (select-frame-set-input-focus frame norecord))
4816 same-window-buffer-names same-window-regexps) 4825 (current-buffer))))
4817 (pop-to-buffer buffer-or-name t norecord)))
4818 4826
4819(defun read-buffer-to-switch (prompt) 4827(defun read-buffer-to-switch (prompt)
4820 "Read the name of a buffer to switch to, prompting with PROMPT. 4828 "Read the name of a buffer to switch to, prompting with PROMPT.