6

I have configured my emacs as follows, and I would like to open and operate the source files only in the first window(*scratch*).

But the sr-speedbar loves to open the new file in the lastest window(e.g. the newly open *shell* window).

How can I stop it from opening files in some unwanted windows?

enter image description here

ppn029012
  • 580
  • 1
  • 6
  • 20
  • 1
    **(A)** You can set a certain window as dedicated so that the display-buffer family of functions avoids it -- http://www.gnu.org/software/emacs/manual/html_node/elisp/Dedicated-Windows.html **(B)** You can adjust the display-buffer-alist to your liking -- https://www.gnu.org/software/emacs/manual/html_node/elisp/Display-Action-Functions.html and http://www.gnu.org/software/emacs/manual/html_node/elisp/Choosing-Window.html **(C)** You can adjust the source code of speedbar to your liking. – lawlist Apr 28 '15 at 20:17
  • I have tried **(A)**, and I set the \*shell* window as a dedication, but sr-speedbar insists in opening the file by spliting the last window(i.e. \*shell*), and ignoring the scratch window. – ppn029012 Apr 29 '15 at 05:41
  • A cursory word-search of the `sr-speedbar.el` library for the term `split-window` pulls up two results: http://www.emacswiki.org/emacs/sr-speedbar.el I personally like option **(C)** -- modify the source and make it do what you want. Instead of `split-window`..., perhaps you want to use `display-buffer` to select an **existing** window? . . . (modifying the code as needed to accommodate that new revision). – lawlist Apr 29 '15 at 06:04

3 Answers3

1

I've run into this problem as well. My solution, which I can personally recommend, is to use the purpose package.

It allows you to dedicate specific windows to specific "purposes" which each have user-configurable associated modes; for instance, the edit purpose might have prog-mode associated with it, the view purpose might have `info-mode associated with it, etc. Any time a new buffer is to be opened, if there is a window currently dedicated to that purpose, Emacs will force said buffer to be opened in that dedicated window.

As an example, my default Emacs "workspace" consists of one large edit window, one comm window for IRC, and two admin windows -- one for RSS and another for email.

Highly recommend.

Jonathan Jin
  • 485
  • 1
  • 3
  • 15
1

To open only in single windows do customize the emacs initialization file (in Ubuntu (18.04.01) it in (~/.emacs ) and add the

(setq inhibit-splash-screen t)       ;; Don't show initial Emacs-logo and info 
0

What I do is set the buffers that I do not want to change to sticky-buffer-mode. (Just do M-x sticky-buffer-mode when you have the buffer selected). Use this command to toggle the mode. A sticky buffer will not change, so if you make your shell sticky you should get what you want.

Dino Dini
  • 433
  • 3
  • 6