4

How to make buffers accessible only from one frame(window) and not accessible from another and vice versa? So I want to have each frame with its own buffers.

I'm on OS X.

4 Answers 4

3

The only way I can think of is launching a new instance of Emacs instead of opening a new frame normally. You can set C-x 5 2 to start emacs instead of creating a new frame:

(defun start-other-emacs ()
  "Start another Emacs process to open an independent Emacs window."
  (interactive)
  ;;; Run the command "emacs", piping output into a 
  ;;; buffer called "*other-emacs*"
  (start-process "emacs" "*other-emacs*" "emacs"))
(global-set-key (kbd "C-x 5 2") 'start-other-emacs)

Unfortunately, this isn't terribly fast unless you have a more optimized Emacs config than I do!

1
  • Thanks, good enough for me. I guess, then it was more a question how to open second Emacs Instance on OS X. For those who'll come up with same question: Launching it from command line via /Applications/Emacs.app/Contents/MacOS/Emacs is the way
    – welldan97
    Sep 24, 2014 at 4:59
6

Generally you can't have frame-local list of buffers. It might have been possible when buffer-alist was exposed at Lisp level (but even like that I'm not too sure), but that possibility is now gone.

The next best thing is to pretend you do. Packages like perspective.el can help in this regard: they avoid presenting buffers that are not "contained" in the current perspective. You can then activate different perspectives in different frames to implement your scenario.

2
  • Cheers, for pointing at perspective
    – welldan97
    Sep 24, 2014 at 5:00
  • This version of perspective is even better: github.com/Bad-ptr/persp-mode.el
    – Nisba
    Aug 24, 2017 at 1:15
1

Your question is not very clear (to me, at least). Just what do you mean by "accessible"? (displayed without selecting? selected as current buffer?) And what do you mean here by "and vice versa"? And what does "each frame with its own buffers" (plural?) mean?

Taking a wild guess, perhaps you mean that you want a single buffer (not two or more) shown in each frame. And perhaps you want the frame to show only that buffer. (No, I realize that this is not at all what you said. But what you said is anyway unclear to me.)

If so, then to use a separate frame by default for most buffer-displaying commands, try setting option pop-up-frames to t. (Or customize the complex option display-buffer-alist.) And to prevent other buffers from being shown in the same frame, make the buffer's window dedicated -- see the Elisp manual, node Dedicated Windows.

But if you do only those things then you will wind up somewhat disappointed, as Emacs does not always behave well with one-buffer-per-frame.

If you want a relatively coherent setup that provides one-buffer-per-frame behavior, consider trying One On One Emacs. Try library oneonone.el, for example. To make all windows dedicated you can customize special-display-regexps so that it matches all buffer names. (Or again, you can fiddle with customizing option display-buffer-alist.)

0

There is also frame-purpose:

makes it easy to open purpose-specific frames that only show certain buffers, e.g. by buffers’ major mode, their filename or directory, etc, with custom frame/X-window titles, icons, and other frame parameters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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