In emacs, how to force switch to a different buffer in a dedicated window

emacs

Is there a command or shortcut to force to replace the buffer in a dedicated window with another buffer?

When trying to switch to a different buffer using C-x b or M-x switch-to-buffer it says "Cannot switch buffers in a dedicated window".

So, I need a way to either un-dedicate the window (which was opened as dedicated by some applications such as gdb) or be able to switch to a different buffer on that same window using shortcuts or overrides.

Best Answer

Evaluating (set-window-dedicated-p (frame-selected-window) nil) should un-dedicate the current window.

See https://www.gnu.org/software/emacs/manual/html_node/elisp/Dedicated-Windows.html for documentation on dedicated windows.