What does “s-[keyname]” refer to in Emacs, and how do I tell Emacs to ignore it?

随声附和 提交于 2019-12-03 01:22:23
Martin Geisler

It's the Super key, like M- is the Meta key (alt key on a PC keyboard, Command key on your keyboard) and C- is the Control key.

I have of course never actually seen a super key on my keyboard... they are from a long gone era. Wikipedia has an image of this impressive "Space Cadet keyboard" which has all the modifiers you'll ever need:

Simon Wright

With plain Emacs 23.1 on a Macbook Pro, I can map the right option key to super by

(setq ns-right-option-modifier 'super)

Your other choice seems to be the function key, which would be ns-function-modifier. However, fn might have other uses, whereas Emacs’ default is to map ns-right-option-modifier to ’left (ie, the same effect as the left option key, which I at any rate need to get the # character!), so the right option key is to some extent redundant.

Left-handers may want to reverse this.

For the question about what the s-[key] means, on ubuntu box it means the Windows® shaped key. What it means on the OSX systems, I do not know.

As for maximizing windows, could you try this? (It should work, iif OSX runs an X server somewhere underneath it all)

(if (equal (window-system) 'x)
  (progn
   (defun toggle-fullscreen ()
     "Toggles fullscreen"
     (interactive)
     (x-send-client-message nil 0 nil "_NET_WM_STATE" 32
              '(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0))
     (x-send-client-message nil 0 nil "_NET_WM_STATE" 32
              '(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))) 

   (global-set-key (kbd "C-c C-y") 'x-clipboard-yank)
   (global-set-key (kbd "M-RET") 'toggle-fullscreen)))

This little snippet is what I use to toggle fullscreen on my *nix computers. And yanking from X's clipboard is a neat ability to have.

As for how to set keybindings, use global-set-key for mode independent keybindings. (Add it to your .emacs file if you want it to be permanent.)

(setq ns-command-modifier nil)

That is supposed to do what you want. However, it's having somewhat unpredictable behaviour on machine when I test it, so be warned.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!