emacsframe

emacs follow-mode across frames


Is there a way to get behavior like you find in follow-mode but have it across multiple windows in separate frames?

I've gotta work with some nasty legacy code that has seven page bricks of eight-level-deep nested for loops with lots'a goto's and it helps to see as much of the code as possible (in order to adequately understand and rewrite it without breaking everything else).

The more code I can see at once, the better.


Solution

  • This restriction is set explicitly by follow-all-followers in its call to get-buffer-window-list, so it could be lifted with this change:

       (let ((windows (get-buffer-window-list
    -                  (window-buffer win) 'no-minibuf (window-frame win))))
    +                  (window-buffer win) 'no-minibuf t)))
    

    You could redefine that like so:

    (defun my-follow-all-followers (&optional win)
      "Like `follow-all-followers' but for all frames.
    Passes t as the ALL-FRAMES arg to `get-buffer-window-list'."
      (unless (window-live-p win)
        (setq win (selected-window)))
      (let ((windows (get-buffer-window-list
                      (window-buffer win) 'no-minibuf t)))
        (sort windows #'follow--window-sorter)))
    
    (advice-add 'follow-all-followers :override #'my-follow-all-followers)
    

    There are some deficiencies you'll notice pretty quickly (e.g. you may need to arrange the frames manually), but it facilitates the basic requirement of utilising all frames, and you should be able to get it working.

    I would also suggest that FrameMove with WindMove might prove very useful for this arrangement.