aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2011-09-22 12:15:52 -0400
committerChong Yidong2011-09-22 12:15:52 -0400
commit72258fe58401a16ab2ff671601c6d6068eb8b799 (patch)
treeebeff5690f1240a024e02ad42c7bb6fea1001570
parent8f0985161467a7018ba08ccf7c9f37cc7fc3edfe (diff)
downloademacs-72258fe58401a16ab2ff671601c6d6068eb8b799.tar.gz
emacs-72258fe58401a16ab2ff671601c6d6068eb8b799.zip
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
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/cmuscheme.el4
-rw-r--r--lisp/cus-edit.el14
-rw-r--r--lisp/info.el3
-rw-r--r--lisp/mail/sendmail.el4
-rw-r--r--lisp/progmodes/inf-lisp.el2
-rw-r--r--lisp/shell.el2
-rw-r--r--lisp/window.el22
8 files changed, 51 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5278fb3a6bd..8017e711203 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12011-09-22 Chong Yidong <cyd@stupidchicken.com>
2
3 * window.el (pop-to-buffer-same-window): New (reinstated) fun.
4
5 * cmuscheme.el (run-scheme, switch-to-scheme):
6 * cus-edit.el (customize-group, custom-buffer-create)
7 (customize-browse):
8 * info.el (info):
9 * shell.el (shell):
10 * mail/sendmail.el (mail):
11 * progmodes/inf-lisp.el (inferior-lisp): Use it (Bug#9532).
12
12011-09-22 Richard Stallman <rms@gnu.org> 132011-09-22 Richard Stallman <rms@gnu.org>
2 14
3 * textmodes/paragraphs.el (forward-sentence): When setting PAR-BEG, 15 * textmodes/paragraphs.el (forward-sentence): When setting PAR-BEG,
diff --git a/lisp/cmuscheme.el b/lisp/cmuscheme.el
index 6eb2aa76135..7c1351eefd4 100644
--- a/lisp/cmuscheme.el
+++ b/lisp/cmuscheme.el
@@ -246,7 +246,7 @@ is run).
246 (inferior-scheme-mode))) 246 (inferior-scheme-mode)))
247 (setq scheme-program-name cmd) 247 (setq scheme-program-name cmd)
248 (setq scheme-buffer "*scheme*") 248 (setq scheme-buffer "*scheme*")
249 (switch-to-buffer "*scheme*")) 249 (pop-to-buffer-same-window "*scheme*"))
250 250
251(defun scheme-start-file (prog) 251(defun scheme-start-file (prog)
252 "Return the name of the start file corresponding to PROG. 252 "Return the name of the start file corresponding to PROG.
@@ -371,7 +371,7 @@ With argument, position cursor at end of buffer."
371 (interactive "P") 371 (interactive "P")
372 (if (or (and scheme-buffer (get-buffer scheme-buffer)) 372 (if (or (and scheme-buffer (get-buffer scheme-buffer))
373 (scheme-interactively-start-process)) 373 (scheme-interactively-start-process))
374 (switch-to-buffer scheme-buffer) 374 (pop-to-buffer-same-window scheme-buffer)
375 (error "No current process buffer. See variable `scheme-buffer'")) 375 (error "No current process buffer. See variable `scheme-buffer'"))
376 (when eob-p 376 (when eob-p
377 (push-mark) 377 (push-mark)
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 620ecdba40c..9ba8b27c693 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -1111,15 +1111,19 @@ If OTHER-WINDOW is non-nil, display in another window."
1111 (setq group (intern group)))) 1111 (setq group (intern group))))
1112 (let ((name (format "*Customize Group: %s*" 1112 (let ((name (format "*Customize Group: %s*"
1113 (custom-unlispify-tag-name group)))) 1113 (custom-unlispify-tag-name group))))
1114 (if (get-buffer name) 1114 (cond
1115 (switch-to-buffer name other-window) 1115 ((null (get-buffer name))
1116 (funcall (if other-window 1116 (funcall (if other-window
1117 'custom-buffer-create-other-window 1117 'custom-buffer-create-other-window
1118 'custom-buffer-create) 1118 'custom-buffer-create)
1119 (list (list group 'custom-group)) 1119 (list (list group 'custom-group))
1120 name 1120 name
1121 (concat " for group " 1121 (concat " for group "
1122 (custom-unlispify-tag-name group)))))) 1122 (custom-unlispify-tag-name group))))
1123 (other-window
1124 (switch-to-buffer-other-window name))
1125 (t
1126 (pop-to-buffer-same-window name)))))
1123 1127
1124;;;###autoload 1128;;;###autoload
1125(defun customize-group-other-window (&optional group) 1129(defun customize-group-other-window (&optional group)
@@ -1533,7 +1537,7 @@ Optional NAME is the name of the buffer.
1533OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where 1537OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
1534SYMBOL is a customization option, and WIDGET is a widget for editing 1538SYMBOL is a customization option, and WIDGET is a widget for editing
1535that option." 1539that option."
1536 (switch-to-buffer (custom-get-fresh-buffer (or name "*Customization*"))) 1540 (pop-to-buffer-same-window (custom-get-fresh-buffer (or name "*Customization*")))
1537 (custom-buffer-create-internal options description)) 1541 (custom-buffer-create-internal options description))
1538 1542
1539;;;###autoload 1543;;;###autoload
@@ -1721,7 +1725,7 @@ Otherwise use brackets."
1721 (unless group 1725 (unless group
1722 (setq group 'emacs)) 1726 (setq group 'emacs))
1723 (let ((name "*Customize Browser*")) 1727 (let ((name "*Customize Browser*"))
1724 (switch-to-buffer (custom-get-fresh-buffer name))) 1728 (pop-to-buffer-same-window (custom-get-fresh-buffer name)))
1725 (Custom-mode) 1729 (Custom-mode)
1726 (widget-insert (format "\ 1730 (widget-insert (format "\
1727%s buttons; type RET or click mouse-1 1731%s buttons; type RET or click mouse-1
diff --git a/lisp/info.el b/lisp/info.el
index ea23cf35568..4ccbeba2a47 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -649,7 +649,8 @@ See a list of available Info commands in `Info-mode'."
649 (read-file-name "Info file name: " nil nil t)) 649 (read-file-name "Info file name: " nil nil t))
650 (if (numberp current-prefix-arg) 650 (if (numberp current-prefix-arg)
651 (format "*info*<%s>" current-prefix-arg)))) 651 (format "*info*<%s>" current-prefix-arg))))
652 (info-setup file-or-node (switch-to-buffer (or buffer "*info*")))) 652 (info-setup file-or-node
653 (pop-to-buffer-same-window (or buffer "*info*"))))
653 654
654(defun info-setup (file-or-node buffer) 655(defun info-setup (file-or-node buffer)
655 "Display Info node FILE-OR-NODE in BUFFER." 656 "Display Info node FILE-OR-NODE in BUFFER."
diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el
index 6bcf65945b5..dedb5719934 100644
--- a/lisp/mail/sendmail.el
+++ b/lisp/mail/sendmail.el
@@ -1785,11 +1785,11 @@ The seventh argument ACTIONS is a list of actions to take
1785 This is how Rmail arranges to mark messages `answered'." 1785 This is how Rmail arranges to mark messages `answered'."
1786 (interactive "P") 1786 (interactive "P")
1787 (if (eq noerase 'new) 1787 (if (eq noerase 'new)
1788 (switch-to-buffer (generate-new-buffer "*mail*")) 1788 (pop-to-buffer-same-window (generate-new-buffer "*mail*"))
1789 (and noerase 1789 (and noerase
1790 (not (get-buffer "*mail*")) 1790 (not (get-buffer "*mail*"))
1791 (setq noerase nil)) 1791 (setq noerase nil))
1792 (switch-to-buffer "*mail*")) 1792 (pop-to-buffer-same-window "*mail*"))
1793 1793
1794 ;; Avoid danger that the auto-save file can't be written. 1794 ;; Avoid danger that the auto-save file can't be written.
1795 (let ((dir (expand-file-name 1795 (let ((dir (expand-file-name
diff --git a/lisp/progmodes/inf-lisp.el b/lisp/progmodes/inf-lisp.el
index 0765f74a1cf..636766b36e7 100644
--- a/lisp/progmodes/inf-lisp.el
+++ b/lisp/progmodes/inf-lisp.el
@@ -297,7 +297,7 @@ of `inferior-lisp-program'). Runs the hooks from
297 "inferior-lisp" (car cmdlist) nil (cdr cmdlist))) 297 "inferior-lisp" (car cmdlist) nil (cdr cmdlist)))
298 (inferior-lisp-mode))) 298 (inferior-lisp-mode)))
299 (setq inferior-lisp-buffer "*inferior-lisp*") 299 (setq inferior-lisp-buffer "*inferior-lisp*")
300 (switch-to-buffer "*inferior-lisp*")) 300 (pop-to-buffer-same-window "*inferior-lisp*"))
301 301
302;;;###autoload 302;;;###autoload
303(defalias 'run-lisp 'inferior-lisp) 303(defalias 'run-lisp 'inferior-lisp)
diff --git a/lisp/shell.el b/lisp/shell.el
index 8c5781f9333..96c0d27372e 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -652,7 +652,7 @@ Otherwise, one argument `-i' is passed to the shell.
652 652
653 ;; The buffer's window must be correctly set when we call comint (so 653 ;; The buffer's window must be correctly set when we call comint (so
654 ;; that comint sets the COLUMNS env var properly). 654 ;; that comint sets the COLUMNS env var properly).
655 (switch-to-buffer buffer) 655 (pop-to-buffer-same-window buffer)
656 (unless (comint-check-proc buffer) 656 (unless (comint-check-proc buffer)
657 (let* ((prog (or explicit-shell-file-name 657 (let* ((prog (or explicit-shell-file-name
658 (getenv "ESHELL") shell-file-name)) 658 (getenv "ESHELL") shell-file-name))
diff --git a/lisp/window.el b/lisp/window.el
index 843115d2e5c..fb74c439247 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -4861,6 +4861,28 @@ at the front of the list of recently selected ones."
4861 (select-frame-set-input-focus frame norecord)) 4861 (select-frame-set-input-focus frame norecord))
4862 buffer)) 4862 buffer))
4863 4863
4864(defun pop-to-buffer-same-window (buffer &optional norecord)
4865 "Select buffer BUFFER in some window, preferably the same one.
4866This function behaves much like `switch-to-buffer', except it
4867displays with `special-display-function' if BUFFER has a match in
4868`special-display-buffer-names' or `special-display-regexps'.
4869
4870Unlike `pop-to-buffer', this function prefers using the selected
4871window over popping up a new window or frame.
4872
4873BUFFER may be a buffer, a string (a buffer name), or nil. If it
4874is a string not naming an existent buffer, create a buffer with
4875that name. If BUFFER is nil, choose some other buffer. Return
4876the buffer.
4877
4878NORECORD, if non-nil means do not put this buffer at the front of
4879the list of recently selected ones."
4880 (pop-to-buffer buffer
4881 '((display-buffer--special
4882 display-buffer-same-window)
4883 (inhibit-same-window . nil))
4884 norecord))
4885
4864(defun read-buffer-to-switch (prompt) 4886(defun read-buffer-to-switch (prompt)
4865 "Read the name of a buffer to switch to, prompting with PROMPT. 4887 "Read the name of a buffer to switch to, prompting with PROMPT.
4866Return the neame of the buffer as a string. 4888Return the neame of the buffer as a string.