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
    Commented Oct 9, 2017 at 17:50
  • Same thing: "C-M-( is undefined" or "C-M-) is undefined". Commented Oct 9, 2017 at 18:36
  • 1
    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.) Commented Jan 3, 2019 at 10:44

4 Answers 4


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. Commented Oct 10, 2017 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
    Commented Oct 10, 2017 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. Commented Oct 11, 2017 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
    Commented Oct 11, 2017 at 14:33
;; 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

  • 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
    Commented Apr 23, 2019 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
    Commented Apr 26, 2019 at 22:49

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"


Your mouse wheel scroll mappings match my initial Emacs settings as well.

Add the following to your $HOME/.emacs file.

I find scrolling by four lines optimal.

;; Mouse wheel scroll
;; My scroll wheel is mapped to C-M-( C-M-)
(defun scroll-up-4-lines ()
  "Scroll up 4 lines."
  (scroll-up 4))

(defun scroll-down-4-lines ()
  "Scroll down 4 lines."
  (scroll-down 4))

(global-set-key (kbd "C-M-(") 'scroll-down-4-lines)
(global-set-key (kbd "C-M-)") 'scroll-up-4-lines)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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