Emacs: Make custom scrolling function follow mouse but not change keyboard focus

无人久伴 提交于 2019-12-06 05:43:51

You should not redefine <mouse-4> and <mouse-5>, but instead:

(mouse-wheel-mode 1)

(defvar alternating-scroll-down-next t)
(defvar alternating-scroll-up-next t)

(defun alternating-scroll-down-line (&optional arg)
  (when alternating-scroll-down-next
    (scroll-down-line (or arg 1)))
  (setq alternating-scroll-down-next (not alternating-scroll-down-next)))

(defun alternating-scroll-up-line (&optional arg)
  (when alternating-scroll-up-next
    (scroll-up-line (or arg 1)))
  (setq alternating-scroll-up-next (not alternating-scroll-up-next)))

(setq mwheel-scroll-up-function 'alternating-scroll-up-line)
(setq mwheel-scroll-down-function 'alternating-scroll-down-line)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!