Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emacs follow-mode across frames

Tags:

emacs

frame

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.

like image 914
Ishpeck Avatar asked Oct 06 '12 00:10

Ishpeck


People also ask

How to go to previous buffer in Emacs?

Hold down Ctrl and click the left mouse button. Emacs displays a pop-up menu of current buffers by mode (Mac OS X). To cycle through all the buffers you have, type C-x → to go to the next buffer (in the buffer list) or C-x to go to the previous buffer.

How do I switch between windows in Emacs?

To select a different window, click with Mouse-1 on its mode line. With the keyboard, you can switch windows by typing C-x o ( other-window ).

How many buffers can be opened in Emacs?

This is because Emacs tracks buffer positions using that data type. For typical 64-bit machines, this maximum buffer size is 2^{61} - 2 bytes, or about 2 EiB. For typical 32-bit machines, the maximum is usually 2^{29} - 2 bytes, or about 512 MiB.

How to create a buffer in Emacs?

You can create new buffers with switch-to-buffer . Type C-x b , enter a buffer name, and press RET . If no buffer with that name exists, Emacs creates a new one automatically in Fundamental Mode. You may switch to any other mode as usual with M-x , e.g. M-x python-mode .


1 Answers

This restriction is set explicitly by follow-all-followers in its call to next-window.

Here's a rudimentary workaround. 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.

(defmacro with-temporary-advice (function class name &rest body)
  "Enable the specified advice, evaluate BODY, then disable the advice."
  `(progn
     (ad-enable-advice ,function ,class ,name)
     (ad-activate ,function)
     ,@body
     (ad-disable-advice ,function ,class ,name)
     (ad-activate ,function)))

(defadvice next-window (before my-next-window-all-frames disable)
  "Enforce the ALL-FRAMES argument to `next-window'."
  (ad-set-arg 2 'visible))

(defadvice follow-all-followers (around my-follow-all-frames activate)
  "Allow `follow-mode' to span frames."
  (with-temporary-advice
   'next-window 'before 'my-next-window-all-frames
   ad-do-it))

You might instead prefer to simply redefine the follow-all-followers function to do what you want.

like image 182
phils Avatar answered Oct 02 '22 08:10

phils