2017-02-26 other-window-or-switch-buffer

Some time ago I decided to bind f6 to other-window. I lived happily with that binding, but then something struck me. My f6 key was completely useless when I had only one window in the current frame. What a waste! So, I decided to code this.

(defun other-window-or-switch-buffer ()
  "Call `other-window' if more than one window is visible, switch
to next buffer otherwise."
  (interactive)
  (if (one-window-p)
	  (switch-to-buffer nil)
	(other-window 1)))

(global-set-key (kbd "<f6>") #'other-window-or-switch-buffer)

Now f6 cycles through my most recently used two buffers if I have only one window. (This partially supersedes my other command described here, so maybe I’ll bind C-z b without the prefix argument to something else – we’ll see.)

CategoryEnglish, CategoryBlog, CategoryEmacs