]> code.delx.au - gnu-emacs/commitdiff
Reintroduce pop-to-buffer-same-window; use it for previous users of same-window-*.
authorChong Yidong <cyd@stupidchicken.com>
Thu, 22 Sep 2011 16:15:52 +0000 (12:15 -0400)
committerChong Yidong <cyd@stupidchicken.com>
Thu, 22 Sep 2011 16:15:52 +0000 (12:15 -0400)
* 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
lisp/ChangeLog
lisp/cmuscheme.el
lisp/cus-edit.el
lisp/info.el
lisp/mail/sendmail.el
lisp/progmodes/inf-lisp.el
lisp/shell.el
lisp/window.el

index 5278fb3a6bda89f40eee34ed397e7c9fcbba6f42..8017e711203ffbb96d1cc4224ce3732a9699d1dc 100644 (file)
@@ -1,3 +1,15 @@
+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,
index 6eb2aa761351542e26a7ca75d6da9b369710caae..7c1351eefd4d3062d902af9eb66de8b08a3ffa09 100644 (file)
@@ -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)
index 620ecdba40cb3669bbfa40c32a0261c54cfef753..9ba8b27c693e08844e0587c18b7021c527a472e9 100644 (file)
@@ -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
index ea23cf355686e95e4969a8fd275a47d49dd73228..4ccbeba2a47ad08ea592619c8646586e32ca494f 100644 (file)
@@ -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."
index 6bcf65945b5514255f9c39f7707a85f9636c8d3f..dedb571993451408166ca9e68075b600e4fe697a 100644 (file)
@@ -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
index 0765f74a1cf5eb656782bcf0b07d6132a8899cd2..636766b36e717219729a3485208fe1f8bc0b336c 100644 (file)
@@ -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)
index 8c5781f9333356dca0aa531210f35ec971bb3444..96c0d27372ef4d2d35228d074e8ade0bb85937de 100644 (file)
@@ -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))
index 843115d2e5c3ec94a39433a8630d20b7d52d0572..fb74c4392470dc66f4a2ad972f8f096327c2bf37 100644 (file)
@@ -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.