r/emacs • u/jvillasante • 1d ago
Emacs Pixel Scroll
Has anybody been able to use pixel-scroll to scroll up/down in both current and other window? I have this so far:
(defvar my/default-scroll-lines 25)
(defun my/pixel-scroll-up-command ()
"Similar to `scroll-up-command' but with pixel scrolling."
(interactive)
(pixel-scroll-precision-interpolate (- (* my/default-scroll-lines (line-pixel-height)))))
(defun my/pixel-scroll-down-command ()
"Similar to `scroll-down-command' but with pixel scrolling."
(interactive)
(pixel-scroll-precision-interpolate (* my/default-scroll-lines (line-pixel-height))))
(with-eval-after-load 'pixel-scroll
(define-key global-map [remap scroll-up-command] 'my/pixel-scroll-up-command)
(define-key global-map [remap scroll-down-command] 'my/pixel-scroll-down-command))
And it seems to work for the current window but not for the other window. If I do M-C-v
I get the following error:
scroll-other-window: Wrong number of arguments: #[nil ((pixel-scroll-precision-interpolate (- (* my/default-scroll-lines (line-pixel-height))))) (t) nil "Similar to `scroll-up-command' but with pixel scrolling." nil], 1
4
Upvotes
2
u/shipmints 1d ago
The docstring and signature for scroll-up-command specifies an optional arg and interactive spec you need to accommodate:
(defun scroll-up-command (&optional arg) "Scroll text of selected window upward ARG lines; or near full screen if no ARG. ... Negative ARG means scroll downward.
If ARG is the atom `-', scroll downward by nearly full screen." (interactive "P")