3

I can make a buffer dedicated to a frame using the following snippet I got from other posts

(defun toggle-window-dedicated () "Toggle whether the current active window is dedicated or not" (interactive) (message (if (let (window (get-buffer-window (current-buffer))) (set-window-dedicated-p window (not (window-dedicated-p window)))) "Window '%s' is dedicated" "Window '%s' is normal") (current-buffer))) (global-set-key (kbd "C-c d") 'toggle-window-dedicated) 

Now from from another frame if I want to switch to the dedicated buffer then a copy of the buffer is opened. This is not the behavior I want. I want the focus to switch to the dedicated frame. The solution posted here : switch-to-buffer does not work.

1 Answer 1

2
  1. If you want to switch to a buffer that is in another frame, use C-x 5 b, not C-x 4 b or C-x b. IOW, just use C-x 5 b for your buffer that is in a dedicated window, after using your toggle command.

  2. If you want to have certain buffers always be in dedicated windows in their own frames, you can use option special-display-buffer-names or special-display-regexps.

    For example, if you customize special-display-buffer-names to be (("foo.el")) then whenever you use a command that displays buffer foo.el it is shown in its own frame, in a dedicated window.

    (Personally, I set special-display-regexps to ("[ ]?[*][^*]+[*]"), so all buffers with names matching *...* are in dedicated windows in their own frames.)

    [If you prefer to mess with display-buffer-alist instead, be my guest and have fun. Emacs insists that special-display-(regexps|buffer-names) are obsolete. But thankfully they still work fine. Hopefully they will always continue to work fine.]

4
  • :). Thanks for the C-x 5 b tip. I guess the question now is it possible to still use C-x b but it redirects to C-x 5 b for dedicated windows. I will look more into special-display-regexps (is a neat approach) and display-buffer-alist. My emacs fu is not up to par yet but hope to be their soon. Commented Dec 30, 2017 at 2:25
  • See #2 above. If you do that then C-x b automatically does what you are asking. Commented Dec 30, 2017 at 17:55
  • I know what I have to do but I don't how to achieve that in the code base above. Specifically, the elisp directive should be (setq special-display-buffer-names (current-buffer)) where current-buffer is obtained as shown in the above snippet. I need to figure how to chain this directive with the above snippet. Commented Dec 30, 2017 at 22:52
  • No. current-buffer returns a buffer, not a buffer name (a string). If you don't know the names of the buffers that you want to make special-display and you don't know even a pattern (regexp) that all of their names will match, then you cannot use the two options I mentioned. You'll perhaps have to wrestle with using display-buffer-alist. And what I said was not intended as something to do to your toggle-* code. It was a response to your question about to make a given buffer have a dedicated window and then switch to it in its own frame. Commented Dec 31, 2017 at 0:12

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.