Currently I work with ruby and rspec. I really like the idea of having a separate frame in another monitor showing me the compilation buffer. My current setup uses a 'code' frame (in which I do actual work) and a 'test-result' frame (in which I see rspec results)

The problem is that when I try to open some compilation error or file in the 'test-result' frame, the window splits in that frame. What I would really like to do is for it to open in my 'code' frame.

I already use the option display-buffer-reuse-frames. I also tried to set the compilation results window dedicated, but whenever emacs try to open a new window, a new frame would be created (which is particularly awful if you use Helm.)

Is there some easy way to achieve this ?

  • 1
    Using emacs as an IDE would be so much more convenient if there was an easy to "pin" a buffer in place so that it always appears in the same spot from now on. One of the Visual Studio features that I miss most when using emacs is the simple and intuitive way to split, pin, dock, hide, and otherwise manipulate windows. – nispio Sep 26 '14 at 20:35
  • 1
    Yep. I also come from a vs background, and I miss this too, although I feel emacs clean-no-button-no-bullshit interface is better most of the time. – Renan Ranelli Sep 26 '14 at 20:41
  • @nispio I do not use VS so can you specify what you mean by "pin". Emacs frames are usually exclusive and do not change unless you interact with them. – Vamsi Sep 26 '14 at 21:42
  • @vamsi: VS uses lot of little windows that you can attach to the top/bottom/sides of your frame, or you can pop them out and create a new frame. You can dock a window against the edges of a frame and set it up to auto-hide. For example, the compilation output window will magically pop up from the bottom when compilation starts, and hide itself again shortly after compilation ends. If you don't want the window to auto-hide, you can pin it in place, and then un-pin it again when you are done referencing it. – nispio Sep 26 '14 at 21:53
  • @nispio I see. I use popwin.el from MELPA to popup compile and help buffers which persist till C-g is pressed. If I need them fulltime, I just switch to them in another window. I have not thought about pinning windows because emacs does split-windows-sensibly. – Vamsi Sep 26 '14 at 22:05

You need to configure the 600-pound gorilla that is display-buffer-alist which determines how display-buffer chooses where to display a buffer. It makes display-buffer-reuse-frames obsolete in newer emacsen. Here is a config that should guide you (atleast in emacs 24.3).

;; all buffers, try to reuse windows across all frames
(add-to-list 'display-buffer-alist
           '(".*". (display-buffer-reuse-window .
                                  ((reusable-frames . t)))))

;; except for compilation buffers where you want new and dedicated frames when necessary
(add-to-list 'display-buffer-alist
         '("^\\*Compile-Log\\*". ((display-buffer-reuse-window
                                   display-buffer-pop-up-frame) .
                                  ((reusable-frames . t)
                                  (inhibit-same-window . t)))))

As you can see I use a regexp to match the compile-log buffer. The documentation of display-buffer should give you an idea of what is happening. Just a heads up that it is not the most enjoyable piece of documentation you will ever read. I added them sequentially so the compile-log regexp will be matched ahead of the generic regexp. Adapt the regexp to your needs.

EDIT To make any frame unsplittable you can eval M-: (set-frame-parameter nil 'unsplittable t) in that particular frame. Replace nil with required FRAME if doing it from elisp. Between these two settings, it should make the compilation frame exclusive unless you specifically find a file in that frame.

  • The thing is that I don't want to open new frames all the time. What I want is to restrict all windows to the 'code' frame, with the exception of the 'compilation-log' buffer, which should be always displayed in the 'test' frame. I couldn't find a way to redirect all new windows to my main 'code' frame. Maybe I wasn't clear enough in the question =( – Renan Ranelli Sep 26 '14 at 20:43
  • This should only open a new frame for the compilation log that too only if there is no existing frame. Can you tell me what is going wrong. See edit about how to make any frame unsplittable. – Vamsi Sep 26 '14 at 21:35

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.