In 1987, I wrote the code I'm going to paste in a moment. The mechanism used here to capture the initial function binding of switch-to-buffer doesn't work any more, resulting in infinite recursion. I guess that there's a right way to do this sort of thing now, could someone please fill me in?
(defvar *real-buffer-switcher* nil)
(defun improve-buffer-switch ()
(if *real-buffer-switcher* nil
(setq *real-buffer-switcher* (symbol-function 'switch-to-buffer))
(fset 'switch-to-buffer 'better-switch-to-buffer)
t))
;(setq *real-buffer-switcher* (symbol-function 'switch-to-buffer))
(defun better-switch-to-buffer (buffer-name &optional no-record)
(interactive "p") ; c-u c-x b goes ahead and creates. Note that
; buffer-name is fraudulently named so as to permit
; non-interactive calls.
;; first, filter out the noninteractive case.
(if (or (stringp buffer-name)
(bufferp buffer-name))
(funcall *real-buffer-switcher* buffer-name no-record)
;; interactive. Numeric arg?
(funcall *real-buffer-switcher*
(read-buffer "Buffer name: "
(other-buffer (current-buffer))
(= buffer-name 1)))))
(improve-buffer-switch)