0

I found ESC-prefix and Control-X-prefix defined in keymap.c:

initial_define_key (global_map, 033, "ESC-prefix");
initial_define_key (global_map, Ctl ('X'), "Control-X-prefix");

But no matter what I try I can't add a map for Super (Hyper) key.
And this isn't working

Lisp_Object s_map;
...
s_map = Fmake_keymap (Qnil);
Fset (intern_c_string ("s-map"), s_map);
Ffset (intern_c_string ("S-prefix"), s_map);
...
initial_define_key (global_map, 0xffeb, "S-prefix");  // tried many codes
...
initial_define_key (s_map, 'z', "my-function");

Nothing:

s-z is undefined

I also have a question what #define Ctl(c) ((c)&037) does? Because 037 is no a key code of any Control (left or right).

Can you provide a working example of adding a key map to the source code?

Drew
  • 75,699
  • 9
  • 109
  • 225
Sergey
  • 211
  • 1
  • 6
  • Are you asking how to add a keymap and a keymap variable to *the Emacs C source code*? Or do you just want to define a keymap and a keymap variable (e.g., in your own Lisp code)? – Drew Aug 28 '15 at 06:24
  • I want to understand how this is done in source code. Can't sleep well if I don't understand something). I just hack sources now and have questions. – Sergey Aug 28 '15 at 06:29
  • It may depend on the OS, e.g., it would likely be different for an OSX build `--with-ns`: **Qsuper** / `ns_command_modifier` / `ns-command-modifier` in `nsterm.m` and `ns-win.el`. You might also try grepping for **Qsuper** and **super_modifier** in `xterm.c` and `w32fns.c` and `globals.h` I hope you are able to get *some* sleep eventually -- obsessions and sleep seldom mix. – lawlist Aug 28 '15 at 07:25
  • 1
    By the way, `super` and `hyper` are two different keys. Not sure if you know it. – MatthewRock Aug 28 '15 at 08:18
  • @MatthewRock yes I know – Sergey Aug 28 '15 at 09:17
  • Since Super and Hyper are modifiers, maybe emacs doesn't handle them like other keypresses. Did you try adding a keymap for e.g. `s-z` itself ? – YoungFrog Aug 28 '15 at 15:50
  • But Meta and Control are also modifiers. I wanted to do the same thing. Now I just use `(global-set-key (kbd "s-z") ...` in bindings.el – Sergey Aug 28 '15 at 19:01
  • re `(c)&037`: it refers to [ASCII control codes](https://en.wikipedia.org/wiki/Ascii#ASCII_control_code_chart), not the CTRL keyboard key. – npostavs Aug 31 '15 at 15:12

0 Answers0