5

I'm running Emacs 25.1.1 on Debian. No particularly elaborate setup.

I recently bought a new mouse, a Logitech MX Anywhere 2S, though I am not using any of the "programmable" features. I simply use the mouse via Bluetooth. I haven't changed anything anywhere.

It works fine in every other application, but in Emacs, when I try to scroll, I get beeps and C-M-( [or C-M-)] is undefined. mouse-wheel-mode is enabled.

The other aspects of the mouse work as expected; I can paste using the middle button, for example.

Any thoughts on how to fix this?

  • What does C-h k tell you when you try to use the mouse wheel? – Drew Oct 9 '17 at 17:50
  • Same thing: "C-M-( is undefined" or "C-M-) is undefined". – user1235777 Oct 9 '17 at 18:36
  • Are you using GUI Emacs, or Emacs in a terminal? If it's a terminal, which terminal? If it's a GUI, run the program xev from a terminal, move the mouse into the xev window, and scroll the wheel up once without moving it. What appears in the terminal? (Maybe run xev >xev.log because you'll get a ton of mouse motion events.) – Gilles Jan 3 at 10:44
1

If your mouse wheel rotation is seen by Emacs as keys C-M-( and C-M-) then you presumably need to bind those two keys, to make the wheel work with Emacs.

For example:

(global-set-key (kbd "C-M-(") 'mwheel-scroll)
(global-set-key (kbd "C-M-)") 'mwheel-scroll)

Or whatever command is appropriate for your use (and platform).

But what are your values of these user options (use C-h v)?

  • mouse-wheel-down-event
  • mouse-wheel-up-event

mouse-wheel-mode uses the values of those two options to construct the keys that it binds to mwheel-scroll.

You might also do this, to find out what keys mouse-wheel-mode has bound to mwheel-scroll: C-h w mwheel-scroll.

  • 1
    Thank you. mouse-wheel-down-event is 'mouse-4', and mouse-wheel-up-event is 'mouse-5'. mwheel-scroll is on C-mouse-5, S-mouse-5, mouse-5, C-mouse-5, S-mouse-4, mouse-4. Adding the bindings you suggest above just gives me bad binding in mwheel-scroll. I note that holding down the control key while using the mouse wheel does result in the proper scrolling. But I'm confused about how this ended up, and how to get it to work normally. And also why the out-of-the-box situation changed with the new mouse. – user1235777 Oct 10 '17 at 9:51
  • Does your mouse have more than 3 buttons? If so, try the 4th and 5th buttons - they are likely mouse-4 and mouse-5. And consult the doc for your new mouse - it likely lets you configure what each button does. And if you don't change how it configures the buttons (including the wheel events) then you can switch them in Emacs - now that you know that you have mouse-4 bound to mouse-wheel-down-event etc. – Drew Oct 10 '17 at 14:13
  • Leaving aside the mouse functions themselves--the other buttons seem to do nothing, and there doesn't seem to be a Linux option for reprogramming the mouse--can you clarify how to switch this in Emacs? I've tried several options for binding C-M-( and ) to mouse-wheel-[up|down]-event, and get various errors. Thank you, I know this is a basic issue at this point. – user1235777 Oct 11 '17 at 9:27
  • I don't know the answers to your last questions. I would start by trying to check the doc for your mouse itself. Find out how to configure it, outside of Emacs. But hopefully someone else will be able to help you more. – Drew Oct 11 '17 at 14:33
0

It may be possible to adjust the mouse's configuration in Emacs, using some available X Window System utilities, such as xmodmap(1). There's also the imwheel utility, and the evdev input driver for the X Window System.

Although I'm not familiar with the specific configuration, I've found some documentation, such that provides some introductory information about these features of the X Window System. Along with the system manual pages, maybe it could be helpful towards determining a configuration that "Just works"

0
;; Fix mouse wheel
(global-set-key (kbd "C-M-(") (kbd "<mouse-4>"))
(global-set-key (kbd "C-M-)") (kbd "<mouse-5>"))

This is a combination of answer: https://emacs.stackexchange.com/a/36036/17985 and some comments, and this: https://emacs.stackexchange.com/a/49083/17985

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • 2
    I can't see why this would be usually a solution, so your answer needs to explain what it does enough for the reader to be able to judge whether it applies to his case. – Stefan Apr 23 at 17:36
  • I'm sorry @Stefan. Follow the context: emacs.stackexchange.com/questions/49073/… I don't know why this works, but it works. It was by trial and error. Feel free to discover, edit and improve. – Felipe Apr 26 at 22:49

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.