荔园在线
荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀
[回到开始]
[上一篇][下一篇]
发信人: jjksam (<font color=green><b>Love</b></font>), 信区: Linux
标 题: [转载] Mouse Wheels in Emacs(转寄)
发信站: 荔园晨风BBS站 (Fri Nov 2 14:58:01 2001), 转信
【 以下文字转载自 jjksam 的信箱 】
【 原文由 jjksam@smth.org 所发表 】
发信人: althea (ヾ〆ゝゞ+牛奶巧克力=dark inside), 信区: Linux
标 题: Mouse Wheels in Emacs
发信站: BBS 水木清华站 (Tue Oct 30 07:39:36 2001)
Here's two useful functions I steal from someone else. You can use
them to scroll buffers UNDER the mouse point. It works both in X
and MS Windows (if you're using X, obviously you'll have to
configure X first and let it recognize the mouse type.)
Put them into your ~/.emacs, then it'll work by overriding the default
definitions.
Just want to share it with other emacs users :)
;; -----------------------------------------------------------------
;; MOUSE WHEEL SCROLLING
(defvar mouse-wheel-scroll-window-under-mouse t
"*When non-nil, wheel scrolling affects window beneath the mouse pointer,
else the current buffer.")
(defun mouse-wheel-scroll-line (event)
"Scroll the current buffer by `mouse-wheel-scroll-amount'.
If mouse-wheel-scroll-window-under-mouse is non-nil, scroll the window
beneath the mouse pointer, else scroll current buffer."
(interactive "e")
(let ((owin (selected-window)))
(save-excursion
(and mouse-wheel-scroll-window-under-mouse
(condition-case nil
(mouse-set-point event)
(error nil)))
(condition-case nil
(if (< (car (cdr (cdr event))) 0)
(scroll-up mouse-wheel-scroll-amount)
(scroll-down mouse-wheel-scroll-amount))
(error nil)))
(or (eq owin (selected-window))
(select-window owin))))
(defun mouse-wheel-scroll-screen (event)
"Scroll buffer by `mouse-wheel-scroll-amount'.
If mouse-wheel-scroll-window-under-mouse is non-nil, scroll the window
beneath the mouse pointer, else scroll current buffer."
(interactive "e")
(let ((owin (selected-window)))
(save-excursion
(and mouse-wheel-scroll-window-under-mouse
(condition-case nil
(mouse-set-point event)
(error nil)))
(condition-case nil
(if (< (car (cdr (cdr event))) 0)
(scroll-up)
(scroll-down))
(error nil)))
(or (eq owin (selected-window))
(select-window owin))))
--
争取每天至少犯十次错误。
※ 来源:·BBS 水木清华站 smth.org·[FROM: 162.105.203.39]
--
※ 转载:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 192.168.0.146]
[回到开始]
[上一篇][下一篇]
荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店