Commit 72258fe5 authored by Chong Yidong's avatar Chong Yidong
Browse files

Reintroduce pop-to-buffer-same-window; use it for previous users of same-window-*.

* window.el (pop-to-buffer-same-window): New (reinstated) fun.

* cmuscheme.el (run-scheme, switch-to-scheme):
* cus-edit.el (customize-group, custom-buffer-create)
(customize-browse):
* info.el (info):
* shell.el (shell):
* mail/sendmail.el (mail):
* progmodes/inf-lisp.el (inferior-lisp): Use it.

Fixes: debbugs:9532
parent 8f098516
2011-09-22 Chong Yidong <cyd@stupidchicken.com>
* window.el (pop-to-buffer-same-window): New (reinstated) fun.
* cmuscheme.el (run-scheme, switch-to-scheme):
* cus-edit.el (customize-group, custom-buffer-create)
(customize-browse):
* info.el (info):
* shell.el (shell):
* mail/sendmail.el (mail):
* progmodes/inf-lisp.el (inferior-lisp): Use it (Bug#9532).
2011-09-22 Richard Stallman <rms@gnu.org>
* textmodes/paragraphs.el (forward-sentence): When setting PAR-BEG,
......
......@@ -246,7 +246,7 @@ is run).
(inferior-scheme-mode)))
(setq scheme-program-name cmd)
(setq scheme-buffer "*scheme*")
(switch-to-buffer "*scheme*"))
(pop-to-buffer-same-window "*scheme*"))
(defun scheme-start-file (prog)
"Return the name of the start file corresponding to PROG.
......@@ -371,7 +371,7 @@ With argument, position cursor at end of buffer."
(interactive "P")
(if (or (and scheme-buffer (get-buffer scheme-buffer))
(scheme-interactively-start-process))
(switch-to-buffer scheme-buffer)
(pop-to-buffer-same-window scheme-buffer)
(error "No current process buffer. See variable `scheme-buffer'"))
(when eob-p
(push-mark)
......
......@@ -1111,15 +1111,19 @@ If OTHER-WINDOW is non-nil, display in another window."
(setq group (intern group))))
(let ((name (format "*Customize Group: %s*"
(custom-unlispify-tag-name group))))
(if (get-buffer name)
(switch-to-buffer name other-window)
(cond
((null (get-buffer name))
(funcall (if other-window
'custom-buffer-create-other-window
'custom-buffer-create)
(list (list group 'custom-group))
name
(concat " for group "
(custom-unlispify-tag-name group))))))
(custom-unlispify-tag-name group))))
(other-window
(switch-to-buffer-other-window name))
(t
(pop-to-buffer-same-window name)))))
;;;###autoload
(defun customize-group-other-window (&optional group)
......@@ -1533,7 +1537,7 @@ Optional NAME is the name of the buffer.
OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
SYMBOL is a customization option, and WIDGET is a widget for editing
that option."
(switch-to-buffer (custom-get-fresh-buffer (or name "*Customization*")))
(pop-to-buffer-same-window (custom-get-fresh-buffer (or name "*Customization*")))
(custom-buffer-create-internal options description))
;;;###autoload
......@@ -1721,7 +1725,7 @@ Otherwise use brackets."
(unless group
(setq group 'emacs))
(let ((name "*Customize Browser*"))
(switch-to-buffer (custom-get-fresh-buffer name)))
(pop-to-buffer-same-window (custom-get-fresh-buffer name)))
(Custom-mode)
(widget-insert (format "\
%s buttons; type RET or click mouse-1
......
......@@ -649,7 +649,8 @@ See a list of available Info commands in `Info-mode'."
(read-file-name "Info file name: " nil nil t))
(if (numberp current-prefix-arg)
(format "*info*<%s>" current-prefix-arg))))
(info-setup file-or-node (switch-to-buffer (or buffer "*info*"))))
(info-setup file-or-node
(pop-to-buffer-same-window (or buffer "*info*"))))
(defun info-setup (file-or-node buffer)
"Display Info node FILE-OR-NODE in BUFFER."
......
......@@ -1785,11 +1785,11 @@ The seventh argument ACTIONS is a list of actions to take
This is how Rmail arranges to mark messages `answered'."
(interactive "P")
(if (eq noerase 'new)
(switch-to-buffer (generate-new-buffer "*mail*"))
(pop-to-buffer-same-window (generate-new-buffer "*mail*"))
(and noerase
(not (get-buffer "*mail*"))
(setq noerase nil))
(switch-to-buffer "*mail*"))
(pop-to-buffer-same-window "*mail*"))
;; Avoid danger that the auto-save file can't be written.
(let ((dir (expand-file-name
......
......@@ -297,7 +297,7 @@ of `inferior-lisp-program'). Runs the hooks from
"inferior-lisp" (car cmdlist) nil (cdr cmdlist)))
(inferior-lisp-mode)))
(setq inferior-lisp-buffer "*inferior-lisp*")
(switch-to-buffer "*inferior-lisp*"))
(pop-to-buffer-same-window "*inferior-lisp*"))
;;;###autoload
(defalias 'run-lisp 'inferior-lisp)
......
......@@ -652,7 +652,7 @@ Otherwise, one argument `-i' is passed to the shell.
;; The buffer's window must be correctly set when we call comint (so
;; that comint sets the COLUMNS env var properly).
(switch-to-buffer buffer)
(pop-to-buffer-same-window buffer)
(unless (comint-check-proc buffer)
(let* ((prog (or explicit-shell-file-name
(getenv "ESHELL") shell-file-name))
......
......@@ -4861,6 +4861,28 @@ at the front of the list of recently selected ones."
(select-frame-set-input-focus frame norecord))
buffer))
(defun pop-to-buffer-same-window (buffer &optional norecord)
"Select buffer BUFFER in some window, preferably the same one.
This function behaves much like `switch-to-buffer', except it
displays with `special-display-function' if BUFFER has a match in
`special-display-buffer-names' or `special-display-regexps'.
Unlike `pop-to-buffer', this function prefers using the selected
window over popping up a new window or frame.
BUFFER may be a buffer, a string (a buffer name), or nil. If it
is a string not naming an existent buffer, create a buffer with
that name. If BUFFER is nil, choose some other buffer. Return
the buffer.
NORECORD, if non-nil means do not put this buffer at the front of
the list of recently selected ones."
(pop-to-buffer buffer
'((display-buffer--special
display-buffer-same-window)
(inhibit-same-window . nil))
norecord))
(defun read-buffer-to-switch (prompt)
"Read the name of a buffer to switch to, prompting with PROMPT.
Return the neame of the buffer as a string.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment