AMANDEL%BRUSP.ANSP.BR@UICVM.UIC.EDU (02/21/90)
____________________________________________________________________
I just got GNUemacs installed under X, and after fiddling a bit
with the mouse-bound commands, decided I wanted to be able to scroll
emacs windows with the help of the mouse. Being new to emacs, X an Lisp
I designed this very simple command:
(defun x-mouse-scroll-down (arg)
"Scrolls down a page of the window the mouse is pointing at."
(setq curr-window (selected-window))
(x-mouse-select arg)
(scroll-down nil)
(select-window curr-window))
(defkey mouse-map x-button-m-left 'x-mouse-scroll-down)
There is a similar command for scrolling up. Notice that I do
not want to change anything about the selected window, unless that is
the window I am pointing at.
This command works fine except on one condition: when
scroll-down aborts, with the message "beginning of buffer". In that
case, the mouse window stays selected.
I have tried things like surrounding the call to scroll-down
with catch or save-excursion, to no avail. Is there a simple solution
to this problem?
By the way, here goes a suggestion to the X hackers out there:
the X-emacs interface would be much improved if, at user's request,
each emacs window could have scroll bars (vertical and horizontal).
Arnaldo Mandel
amandel@brusp.ansp.br
____________________________________________________________________sarantos@notecnirp.Princeton.EDU (Sarantos Kapidakis) (02/23/90)
Using condition-case, it works fine: (defun x-mouse-scroll-down (arg) "Scrolls down a page of the window the mouse is pointing at." (setq curr-window (selected-window)) (x-mouse-select arg) (condition-case nil (scroll-down nil) (beginning-of-buffer)) (select-window curr-window)) (defun x-mouse-scroll-up (arg) "Scrolls down a page of the window the mouse is pointing at." (setq curr-window (selected-window)) (x-mouse-select arg) (condition-case nil (scroll-up nil) (end-of-buffer)) (select-window curr-window)) (define-key mouse-map x-button-m-left 'x-mouse-scroll-down) (define-key mouse-map x-button-m-right 'x-mouse-scroll-up) sarantos