4

The function 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).

Lenar Hoyt
  • 1,173
  • 7
  • 25
  • I realize you want the most recent, but there are functions available by Googling that work with ido, or selecting a frame by name, or selecting a frame by letter (of available options), or selecting a frame by number (of available options). That way you can go immediately to whichever frame you really want. Off hand, I don't know of a most-recent select frame function -- but if it doesn't exist, I'm sure someone will write it up. – lawlist Apr 02 '16 at 00:26

1 Answers1

1

Here's some code I ended up writing to accomplish this. Add the following to your init.el file, and bind a key to my-goto-most-recent-frame:

(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)))))

Mark
  • 828
  • 10
  • 16