2

I'm trying to run M-= on a region of text, but nothing happens. I think the shortcut is registered (I don't get a message like "M-= is undefined") but the execution stops for some reason and there is no output.

If I run the command that the shortcut is bound to manually, count-words-region, it works fine. It also works if I type Esc =.

I added (global-set-key (kbd "M-=") 'count-words-region) to my initialization file, just to be sure that it is bound, but no effect. In fact, even if I bind some other function to M-=, pressing it has no effect.

I suspected that a recent update of the desktop environment might have redefined M-= (I'm using KDE), but currently nothing seems to be bound to that key.

How to debug this?

Update. If I run M-= through xev, I get the following output:

Alt pressed:

KeyPress event, serial 40, synthetic NO, window 0x5800001,
    root 0x1c9, subw 0x0, time 3737607, (61,104), root:(1461,133),
    state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

= pressed:

FocusOut event, serial 40, synthetic NO, window 0x5800001,
    mode NotifyGrab, detail NotifyAncestor

FocusOut event, serial 40, synthetic NO, window 0x5800001,
    mode NotifyUngrab, detail NotifyPointer

FocusIn event, serial 40, synthetic NO, window 0x5800001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 40, synthetic NO, window 0x0,
    keys:  4294967241 0   32  0   0   0   0   0   1   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

= released:

KeyRelease event, serial 40, synthetic NO, window 0x5800001,
    root 0x1c9, subw 0x0, time 3738919, (61,104), root:(1461,133),
    state 0x8, keycode 21 (keysym 0x3d, equal), same_screen YES,
    XLookupString gives 1 bytes: (3d) "="
    XFilterEvent returns: False

Alt released:

KeyRelease event, serial 40, synthetic NO, window 0x5800001,
    root 0x1c9, subw 0x0, time 3739829, (61,104), root:(1461,133),
    state 0x8, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

Does this mean the shortcut is handled by another process and how to find out which one?

  • I'd use something like xev to check what key is actually being sent, plus I'd look very closely at the KDE keyboard shortcut settings to see if the update added a binding for that key – rpluim Nov 15 '18 at 15:50
  • What does evaluating (lookup-key global-map (kbd "M-=")) say? But it sounds like something (e.g. your window mgr) is preventing Emacs from seeing that key. Be sure you test starting from emacs -Q, to remove other stuff in your init file from the equation. – Drew Nov 15 '18 at 16:11
  • @Drew It says it is bound to count-words-region. – Raul Laasner Nov 15 '18 at 16:19
  • @rpluim I ran the key combination through xev. See the update. – Raul Laasner Nov 15 '18 at 16:21
  • You should be seeing at least a KeyPress event with a keysym of Meta_L or similar. Maybe KDE is filtering Meta, as @Drew suggested. – rpluim Nov 15 '18 at 16:27
1

What worked for me was to bind M-= to a command under KDE settings and then unbind that command. By first binding it to something it automatically unbinds whatever it was bound to before. This way you can reset the shortcut even if you don't know what it originally bound to. Now M-= works again in Emacs and is not captured by another process.

UPDATE

Unfortunately, this is not a permanent solution for me. The shortcut resets every time the computer restarts or, more specifically, when Kwin restarts. You can test by issuing killall kwin_x11 and kwin_x11 &. See related bug report here.

  • @DoMiNeLa10 It turns out that it's not the full solution (see the edit) and thus I can't really accept it as the final answer. – Raul Laasner Dec 16 '18 at 2:39

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.