other-frame cycles through the open frames in a fixed order. This can be pretty inconvenient for example when the compiling log of LaTeX comes to the front, I want to switch back to my
.tex document and I have plenty of other frame opened at the same time. On the major GUIs I know the window or application switching command switch between the most recent ones (and on can access the other ones by repeating the command).
Here's some code I ended up writing to accomplish this. Add the following to your
init.el file, and bind a key to
(defvar my-recent-frames '()) (defun my-frame-record-selected () "Record the currently selected frame. Add this to the focus-in-hook." (let ((f (selected-frame))) (setq my-recent-frames (cons f (remove f my-recent-frames))))) (add-hook 'focus-in-hook #'my-frame-record-selected) (defun my-goto-most-recent-frame () "Jump to most recently active frame before the current frame." (interactive) (unless (null my-recent-frames) (select-frame-set-input-focus (car (cdr my-recent-frames)))))