[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
switch-buffer to use other window if dedicated window (was: Jumping to C
From: |
Drew Adams |
Subject: |
switch-buffer to use other window if dedicated window (was: Jumping to C source from *Help*) |
Date: |
Thu, 8 Apr 2004 10:27:13 -0700 |
Forgive me if this is not too germane or up-to-date.
To me, it makes sense for `switch-to-buffer' to use another window if the
selected window is dedicated.
FWIW, here's the redefinition of `switch-to-buffer' that I use (Emacs 20 -
sorry):
;; 1) Uses `read-buffer' in interactive spec.
;; 2) If current window is dedicated, then use another window.
;; NOTE: Emacs versions >= 19.34 signal an error if dedicated window,
;; instead of using another one. Don't know what the 19.28 version
did.
;; 3) `fit-frame-if-one-window' if `fit-frame-when-switch-to-p'.
(defun switch-to-buffer (buffer &optional norecord)
"Select buffer BUFFER in current window, unless the window is dedicated.
If current window is dedicated (`window-dedicated-p'), then another window
is used. BUFFER may be a buffer or its name.
Optional second arg NORECORD non-nil =>
Do not put BUFFER at front of list of recently selected buffers.
*WARNING*: This is NOT the way to work on another buffer temporarily
within a Lisp program! Use `set-buffer' instead, to avoid messing
with window-buffer correspondences.
`fit-frame-if-one-window' if `fit-frame-when-switch-to-p'."
(interactive
(list (read-buffer "Switch to buffer: " nil 'existing)))
(if (window-dedicated-p (selected-window))
(switch-to-buffer-other-window buffer)
(old-switch-to-buffer buffer norecord))
(fit-frame-if-one-window-and-cond fit-frame-when-switch-to-p))
[FYI -
Function `fit-frame-if-one-window-and-cond' shrink-wraps the frame of the
selected window if variable (user option) `fit-frame-when-switch-to-p' is
non-nil.
Function `read-buffer' reads the name of a buffer and returns it as a
string.
Prompts with first arg, PROMPT (a string).
The default buffer is named by the optional 2nd arg, DEFAULT, if a
string or buffer, or by `another-buffer' if nil.
Non-nil optional 3rd arg, EXISTING, means to allow only names of
existing buffers.]
- Drew
-----Original Message-----
From: address@hidden
[mailto:address@hidden Behalf Of
Stefan Monnier
Sent: Thursday, April 08, 2004 9:47 AM
To: Juri Linkov
Cc: address@hidden
Subject: Re: Jumping to C source from *Help*
> - (pop-to-buffer (car location))
> + (switch-to-buffer (car location))
That signals an error when the *Help* buffer is on a dedicated window (as
is the case for me). I spend a lot of time getting rid of such misuses of
switch-to-buffer, so I strongly oppose this patch.
Of course, the right way to fix it might be to make switch-to-buffer
delegate to pop-to-buffer rather than signal an error. But last time
I suggested it, Richard did not like it.
Stefan
- Re: Jumping to C source from *Help*, (continued)
- Re: Jumping to C source from *Help*, Juanma Barranquero, 2004/04/06
- Re: Jumping to C source from *Help*, Stefan Monnier, 2004/04/08
- switch-buffer to use other window if dedicated window (was: Jumping to C source from *Help*),
Drew Adams <=
- Re: Jumping to C source from *Help*, Richard Stallman, 2004/04/09
- Re: Jumping to C source from *Help*, Kim F. Storm, 2004/04/10
- Re: Jumping to C source from *Help*, Stefan Monnier, 2004/04/11
- Re: Jumping to C source from *Help*, Glenn Morris, 2004/04/12
- Re: Jumping to C source from *Help*, Richard Stallman, 2004/04/14
- Re: Jumping to C source from *Help*, Glenn Morris, 2004/04/15
- Re: Jumping to C source from *Help*, Richard Stallman, 2004/04/19
- Re: Jumping to C source from *Help*, Kim F. Storm, 2004/04/19
- Re: Jumping to C source from *Help*, Glenn Morris, 2004/04/19
- RE: Jumping to C source from *Help*, Drew Adams, 2004/04/20