Tuesday, October 24, 2006

Xemacs and mouse scroll on Mac X and Solaris

Lately I come across of a problem of how to make mouse scroll and two buttons available in XEmacs on Mac X 10.4. Many may know that on iMac there is one button mouse without scroll, but I was pretty annoyed by this fact so I changed Apples mouse to Microsoft's
mouse:-). Of course, it works perfectly, however there is problem with Xemcas which, by default, doesn't recognize actions associated with scroll and additional buttons. I found solution working on my Mac here.

The solution to my problems was to add to the end my Xemacs configuration file (Users/my_user_name/.xemacs/init.el) following lines:

(define-key global-map 'button4
'(lambda (&rest args)
(interactive)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-down 5)
(select-window curwin)
)))
(define-key global-map [(shift button4)]
'(lambda (&rest args)
(interactive)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-down 1)
(select-window curwin)
)))
(define-key global-map [(control button4)]
'(lambda (&rest args)
(interactive)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-down)
(select-window curwin)
)))

(define-key global-map 'button5
'(lambda (&rest args)
(interactive)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-up 5)
(select-window curwin)
)))
(define-key global-map [(shift button5)]
'(lambda (&rest args)
(interactive)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-up 1)
(select-window curwin)
)))
(define-key global-map [(control button5)]
'(lambda (&rest args)
(interactive)
(let ((curwin (selected-window)))
(select-window (car (mouse-pixel-position)))
(scroll-up)
(select-window curwin)
)))

This is what I was looking for, and what's the most important - it worked.

In addition to that, I did exactly the same thing to my XEmacs on my Solaris server (I use X11 to work remotely on Solaris from my Mac). It worked also.

No comments:

Post a Comment