(defun scroll-all-function-all (func arg)
"Apply function FUNC with argument ARG to all visible windows."
(let ((num-windows (count-windows))
(count 1))
(when (> num-windows 1)
(other-window 1)
(while (< count num-windows)
(condition-case nil
(funcall func arg)
(error nil)
)
(other-window 1)
(setq count (1+ count))))))
(defun scroll-all-scroll-down-all (arg)
"Scroll down in all visible windows."
(interactive "p")
(scroll-all-function-all 'next-line arg))
(defun scroll-all-scroll-up-all (arg)
"Scroll up in all visible windows."
(interactive "p")
(scroll-all-function-all 'previous-line arg))
(defun scroll-all-page-down-all (arg)
"Page down in all visible windows."
(interactive "P")
(scroll-all-function-all 'scroll-up arg))
(defun scroll-all-page-up-all (arg)
"Page up in all visible windows."
(interactive "P")
(scroll-all-function-all 'scroll-down arg))
(defun scroll-all-beginning-of-buffer-all (arg)
"Go to the beginning of the buffer in all visible windows."
(interactive "P")
(scroll-all-function-all 'beginning-of-buffer arg))
(defun scroll-all-end-of-buffer-all (arg)
"Go to the end of the buffer in all visible windows."
(interactive "P")
(scroll-all-function-all 'end-of-buffer arg))
(defun scroll-all-check-to-scroll ()
"Check `this-command' to see if a scroll is to be done."
(cond ((eq this-command 'next-line)
(call-interactively 'scroll-all-scroll-down-all))
((eq this-command 'previous-line)
(call-interactively 'scroll-all-scroll-up-all))
((eq this-command 'scroll-up)
(call-interactively 'scroll-all-page-down-all))
((eq this-command 'scroll-down)
(call-interactively 'scroll-all-page-up-all))
((eq this-command 'beginning-of-buffer)
(call-interactively 'scroll-all-beginning-of-buffer-all))
((eq this-command 'end-of-buffer)
(call-interactively 'scroll-all-end-of-buffer-all))))
(define-minor-mode scroll-all-mode
"Toggle Scroll-All minor mode.
With ARG, turn Scroll-All minor mode on if ARG is positive, off otherwise.
When Scroll-All mode is on, scrolling commands entered in one window
apply to all visible windows in the same frame."
nil " *SL*" nil
:global t
:group 'windows
:group 'scrolling
(if scroll-all-mode
(add-hook 'post-command-hook 'scroll-all-check-to-scroll)
(remove-hook 'post-command-hook 'scroll-all-check-to-scroll)))
(provide 'scroll-all)