0

Emacs 27.1

If I want to simultaneously scroll vertically two windows I use

M-x scroll-all-mode

OK. But this scrolls windows vertically.

But I need to scroll both windows horizontally. Is it possible?

1

1 Answer 1

1

If you inspect the definition of scroll-all-mode, you will find that it simply adds a post-command-hook that calls scroll-all-check-to-scroll.

Inspecting the scroll-all-check-to-scroll, we find that it simply dispatches to a 'scroll-all' version of the 'current command'.

So we can simply add sroll-all versions of the horizontal scrolling functions and extend the scroll-all-check-to-scroll to dispatch for those commands also.

Here follows an example for how to extend scroll-all functionality with forward-char:

(with-eval-after-load 'scroll-all
  (defun scroll-forward-all (arg)
    "Forward char in all visible windows.
ARG is like in `end-of-buffer'."
    (interactive "P")
    (scroll-all-function-all 'forward-char 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))
          ((eq this-command 'forward-char)
           (call-interactively 'scroll-forward-all)))))

You can extend for other scrolling functions in a similar way.

You can use C-h k to lookup the command bound to a key.

1
  • It's cool. Emacs 4ever :-) Commented Feb 28 at 8:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.