123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- (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))
- ((memq this-command '(scroll-up scroll-up-command))
- (call-interactively 'scroll-all-page-down-all))
- ((memq this-command '(scroll-down scroll-down-command))
- (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 shared scrolling in same-frame windows (Scroll-All mode).
- With a prefix argument ARG, enable Scroll-All mode if ARG is
- positive, and disable it otherwise. If called from Lisp, enable
- the mode if ARG is omitted or nil.
- When Scroll-All mode is enabled, scrolling commands invoked 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)
|