Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set-window-buffer does not work in dedicated window #201

Open
rothmichaels opened this issue May 21, 2015 · 2 comments
Open

set-window-buffer does not work in dedicated window #201

rothmichaels opened this issue May 21, 2015 · 2 comments

Comments

@rothmichaels
Copy link
Contributor

When working on #198, I was able to come to a better understanding of the issues I brought up with monkey-patch.el in #153.

live-mp-new-basic-save-buffer calls set-window-buffer to move the buffer that is pending a save to the current window. According to the documentation for set-window-buffer, it will throw an error if called from a dedicated window:

This function throws an error when WINDOW is strongly dedicated to its
buffer (that is `window-dedicated-p' returns t for WINDOW) and does not
already display BUFFER-OR-NAME.

Some modes, such as ediff-mode, use a dedicated window as a control panel for enter commands to be run on buffers in other windows. In ediff-mode for example, the frame is divided into windows for the three buffers involved with the merge (base, current, and merged) and a fourth dedicated window for the *Ediff Control Panel*. When entering commands, including saving the merge, the *Ediff Control Panel* is the current selected window and a call to set-window-buffer will throw an error.

One solution is to replace the call to (set-window-buffer (frame-selected-window) (current-buffer)) with (switch-to-buffer (current-buffer)). If switch-to-buffer will not give you your desired behavior, then I would suggest replacing the call only when in a dedicated buffer:

(let ((the-window (frame-selected-window))
  (if (window-dedicated-p the-window)
    (switch-to-buffer (current-window))
    (set-window-buffer the-window)))

If you like one of these solutions, let me know and I'll make a pull request.

@rothmichaels
Copy link
Contributor Author

Don't worry, that's everything I've found / could think of so that's the last issue/pull-request for now ;)

rothmichaels added a commit to rothmichaels/emacs-live that referenced this issue Jul 7, 2015
@rothmichaels
Copy link
Contributor Author

My apologies, my suggestion above was incorrect (somehow must have pasted the wrong thing while working on debugging this). Here is what I meant to suggest.

(let ((the-window (frame-selected-window))
      (the-buffer (current-buffer)))
  (if (window-dedicated-p the-window)
      (switch-to-buffer the-buffer)
    (set-window-buffer the-window the-buffer)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant