4

From what I understand, I should be able to get mouse scrolling to work in emacs nox mode with the following:

(require 'mouse)
(xterm-mouse-mode t)
(mouse-wheel-mode t)

(global-set-key (kbd "<wheel-up>") '(lambda () (interactive) (scroll-up 1)))
(global-set-key (kbd "<wheel-down>") '(lambda () (interactive) (scroll-down 1)))

But for some reason I'm not getting the or signals. Instead I get this from C-h k:

Wheel up:

mintty - ESC [ M ` X 1-
xterm  - ESC [ M ` ] &-

Wheel down:

mintty - ESC [ M a r --
xterm  - ESC [ M a J /-

If I scroll down more than once I get this:

down-mouse-66-

I'm providing examples between mintty and xterm to show that it does not appear to be limited by the terminal. It might be a Cygwin problem but I'm not sure. I AM getting escape sequences but I'm not sure how to map them. They are.. very strange.

Normally I'd used Ctrl-v in bash for something like this but obviously it just scrolls the window.

My cursor IS moving when I use the scroll wheel with these settings so it is being detected in some form but it's doing strange things I can't quite describe, like moving up several lines then jumping down again, but this may change with the context. Might there be a problem with mouse.el?

I'm not sure what to do with this.

  • How large is your window? Do the sequences vary based on where the mouse is? – Random832 Oct 7 '15 at 16:20
  • In my experience, feeding the string that I get out of C-h k right back into the kbd function usually does the right thing. For example (kbd "ESC [ M a r --") – nispio Jun 3 '16 at 0:40
0

You might use input-decode-map (or function-key-map).

(define-key input-decode-map "\033[M'X1-" (kbd "<wheel-up>"))

In my linux environment, I could bind normal keybind like C-M-g. But, not sure about mouse wheel. (FYI my configuration: https://github.com/yuutayamada/xterm-keybinder-el)

  • A nice try but no dice. I tried input-decode-map for this and couldn't find a combination that worked. I hadn't tried your suggestion but it only caused junk to be spewed into the buffer when I moved the wheel. I tried different variations of your suggestion as well including \033[MX1-` and \033[M'X1 etc. – Zhro Aug 7 '15 at 21:04
  • 1
    I am pretty sure it depends upon the type of underlying terminal you are using. For instance in iterm on a mac there are settings under Preferences->Advanced that can change this. But it would more satisfying it it could be set as wholly in emacs as possible. – Samantha Atkins Oct 31 '16 at 4:34
0

Another attempt. (A variant of yuutayamada's answer)

(define-key key-translation-map "\033[M'X1-" (kbd "<wheel-up>"))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.