Search code examples
emacsconfigurationkey-bindings

Compose emacs key sequence for special keys on an unix keyboard


I 've a unix keyboard on a FreeBSD 12 work station with 10 special keys.

Stop  Again
Props Undo
Front Copy
Open  Paste
Find  Cut

and try to use them for short-cuts under Emacs 26.3 in graphics mode. Some of the key symbol names are mapped via the X11 driver to XF86-Key names like:

Copy   - XF86Copy
Cut    - XF86Cut
Paste  - XF86Paste

and some of the key symbol names remain in the Sun-Key namespace like:

Props  -  SunProps
Front  -  SunFront
Open   -  SunOpen.

I want to use the SunFront key, to call some menu items under Emacs but get a strange result for the extended version of such a sequence. The both key binding definitions

(global-set-key [SunFront] 'buffer-menu-open)
(global-set-key [(control SunFront)] 'buffer-menu-open)

are working well and open the buffer menue. But if I try to extend the sequence:

(global-set-key [(control SunFront) (control b)] 'buffer-menu-open)

I got the error

global-set-key: Key sequence <C-SunFront> C-b starts with non-prefix key <C-SunFront>

. On the other hand the sequence:

(global-set-key [(control XF86Copy) (control b)] 'buffer-menu-open)

works well and opens the expected menu. What is the right way to define the emacs key sequence for the SunFront setup?


Solution

  • The error you get is because you already bound (in that same keymap) [(control SunFront)] to a command, so the new define-key would overwrite that definition. You can eliminate the error by explicitly overwriting the old def before adding the new one:

    (global-set-key [(control SunFront)] nil)
    (global-set-key [(control SunFront) (control b)] 'buffer-menu-open)
    

    But most likely all you need to do is to remove the previous binding instead.