Showing revision 1

2017-06-12 smart-next-window-or-buffer

Some time ago, I wrote about an Emacs command I started to use to switch between windows (if there is more than one of them) or buffers (otherwise). While it has proven very useful, since then I started to use multiple frames. It turned out that my command wasn’t all that useful then: it couldn’t switch to a buffer in another frame.

I then decided to bind f6 to next-multiframe-window from windmove.el, and it worked better. However, there was still one gotcha: sometimes I wanted it to switch to another window in the same frame, and it switched to another frame instead.

Well, how to teach Emacs what I really wanted? First I had to formalize it myself. Turns out, it was pretty simple. What I wanted was this:

Quite unexpectedly, the task of coding that was more difficult than I thought. The reason for that turned out to be the fact that other-buffer behaves strangely when the same buffer is visible in more than one frame (by default, it avoids such buffers). Of course, this being Emacs, by giving suitable parameters this behavior could be overridden. See the source and the relevant docstrings for details.

I have changed f6 to this command in my init.el and I’ll see whether it’s going to stick.

CategoryEnglish, CategoryBlog, CategoryEmacs