1

I'm using sr-speedbar to manage a list of buffers. After M-x sr-speedbar-toggle, I switch to the speedbar window, press b to switch into Quick Buffer mode, and then press Enter to select a buffer. In this example my main window is displaying *scratch* and I am pressing Enter on the *Messages* buffer.

I want *Messages* to open in the main window, but instead it opens in a new split window.

Here is how it appears before pressing Enter on the speedbar window:

sr-speedbar before pressing Enter

Actual behavior: The *Messages* buffer opens in a new split window.

sr-speedbar actual behavior

Desired behavior: The *Messages* buffer should open in the previously active window.

sr-speedbar desired behavior

How can I configure emacs to achieve the desired behavior?

  • Let us first identify the cause of the behavior observed by the original poster ... Open a current version of Emacs with no user-configuration (aka Emacs -q). Download sr-speedbar.el from Emacs wiki: emacswiki.org/emacs/download/sr-speedbar.el . Open the file sr-speedbar.el and type M-x eval-buffer. Now arrange the windows / buffers so that the *Messages* buffer exists (but is buried) and the *scratch* buffer is the only window visible. Type M-x sr-speedbar-toggle. Type C-x o to switch to the *SPEEDBAR* window.... – lawlist May 15 at 18:42
  • Type the letter b to view the buffers in the *SPEEDBAR* window. Place the cursor on the *Messages* buffer-name and type M-x eval-expression RET (aka M-:) and in the minibuffer type (text-properties-at (point)) and RET. [The output visible in the minibuffer is truncated ..., but what we need just so happens to be visible. To see what got truncated is beyond the scope of this example ....] We observe the following output: (speedbar-token t speedbar-function speedbar-buffer-click .... Now that we know the function name that we are interested in, ... – lawlist May 15 at 18:42
  • ... we can type M-x find-function RET speedbar-buffer-click RET. We see two (2) possibilities with the if/then statement ... one if dframe-power-click is non-nil, and the other if it is nil ... We start with the first option by going back to the *SPEEDBAR* window (because we do not yet know whether we are dealing with a buffer-local variable), and we type M-x describe-variable RET (aka C-h v) and type dframe-power-click and RET. We see in the *Help* buffer that the variable is global (i.e., not buffer-local) and ... – lawlist May 15 at 18:42
  • ... we discover that it relates to a S-mouse activity situation, which does not apply to us. By process of elimination, we now know that the portion of the function responsible for the behavior at issue is: (switch-to-buffer text). We run a few more tests by going back to the *SPEEDBAR* window and evaluating (window-dedicated-p) and see that it is non-nil; i.e., the window is dedicated. From the *SPEEDBAR* window with only the *scratch* buffer visible in the other window, we evaluate (switch-to-buffer "*Messages*") and observe the same behavior described by the O.P. ... – lawlist May 15 at 18:43
  • I am linking a recent question without an answer (at the moment, at least) entitled "Getting a sorted window list", as this current question contains component that appears to be similar: emacs.stackexchange.com/q/50463/2287 – lawlist May 16 at 1:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.