是否可以使emacs作为修饰键插入fn键? [英] Is it possible to make emacs interpet an fn key as a modifier key?

查看:147
本文介绍了是否可以使emacs作为修饰键插入fn键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使emacs作为修改键插入fn键?我可以绑定f6,f.ex.我有这个:

 (setq ns- function-modifier'hyper);设置Mac的Fn键键入Hype 

并尝试这样做:

 (setq< f6>'hyper)

但是后者不起作用。



我不希望将操作系统作为一个整体将f9看作某种修饰符键(使得可以更容易在其他应用程序中使用功能键用于不同的目的)。



编辑:似乎一个可能的解决方案是绑定 f9 Cx @ h ,但是当我尝试获取函数的文档 Cx @ Cx @ h 我没有得到任何结果。 (它只显示一个文档的功能,如果我实际上做了一个命令,然后注意到 hx 被从codeCx @ hx 所以如果有一些方法可以通过函数将 Cx @ h 绑定到一个密钥(我猜想一个宏可以工作,但是我更喜欢在可能的时候使用elisp)我想这会解决我的问题。



http://www.gnu.org/software/emacs/manual/html_node/emacs/Modifier-Keys.html


即使您的键盘缺少这些附加的修饰键,您可以
使用Cx @输入:Cx @ h将超级标志添加到下一个
字符,Cx @ s添加了超级标志,Cx @ a添加了alt
标志,例如,Cx @ h Ca是进入Hyper-Control-a的一种方式
(不幸的是因为没有办法为同一个字符使用Cx @
两次添加两个修饰符第一个在Cx上的
上工作。)



解决方案

如果你希望它作为一个超级修饰符,这意味着你将它与被修改的键结合在一起,那么不,这就是操作系统级的东西,所以你需要在Emacs之外处理它。 xmodmap 是Unix下的标准方法,如果内存服务器已经读取了它在OSX中的工作。



您可以将 Cx @ h event-apply-hyper-modifier )调用的函数绝对绑定到另一个键序列,但是。



确定该函数名称的原因是该绑定是所谓的翻译键盘映射之一,翻译键盘映射阅读键序列,而不是完整键序列的绑定。因此,不能使用 C-h k (读取密钥序列)。 OTOH注意到,您可以仍然使用 Cx @ Ch 查看包含 Cx @ 前缀, > g (elisp)翻译Keymaps RET



通常, event-apply - * - 修饰符函数(用于shift,control,meta(您的Alt键) ,超级,超级和超级(不是Alt键))从用户读取下一个键,然后将所需的修饰符应用于该键,将结果传递,就像使用实际修饰符键一样键入。 / p>

以下(我已从我的另一个答案)将使用键盘上的数字键来表示所有修改键。



然后,您可以键入序列 hx 作为 < kp-5> x

 (define-key function-key-map(kbd< kp-1>)'event-apply-control-modifier) 
(define-key function-key-map(kbd< kp-2>)'event-apply-meta-modifier)
(define-key function-key-map(kbd< ; kp-3>)'event-apply-super-modifier)
(define-key function-key-map(kbd< kp-4>)'event-apply-shift-modifier)
(define-key function-key-map(kbd< kp-5>)'event-apply-hyper-modifier)
(define-key function-key-map(kbd kp-6>)'event-apply-alt-modifier)

nb对于 F9 使用(kbd< f9>)


Is it possible to make emacs interpet an fn key as a modifier key? Can I bind f6, f.ex. to hyper?

I had this:

(setq ns-function-modifier 'hyper) ; set Mac's Fn key to type Hype

And tried to do this:

(setq <f6> 'hyper)

But the latter did not work.

I'd prefer not making the OS as a whole see f9 as some sort of modifier key (making it possible to more easily use the function keys for different purposes in other apps).

Edit: It seems like one possible solution is to bind f9 to C-x @ h but when I try to get the documentation for the function C-x @ or C-x @ h I don't get any result. (It only shows a documentation for the function if I actually do a command and then notes that h-x was "translated" from C-x @ h x. So if there's some way to bind C-x @ hto a key via a function (I guess a macro could work, but I prefer using elisp when possible) I suppose that would solve my problem.

http://www.gnu.org/software/emacs/manual/html_node/emacs/Modifier-Keys.html

Even if your keyboard lacks these additional modifier keys, you can enter it using C-x @: C-x @ h adds the "hyper" flag to the next character, C-x @ s adds the "super" flag, and C-x @ a adds the "alt" flag. For instance, C-x @ h C-a is a way to enter Hyper-Control-a. (Unfortunately, there is no way to add two modifiers by using C-x @ twice for the same character, because the first one goes to work on the C-x.)

解决方案

If you want it to act as a hyper modifier in the sense that you hold it down in conjunction with the key being modified, then no -- that's an OS-level thing, so you would need to take care of it outside of Emacs. xmodmap is the standard approach under Unix, and if memory serves I've read that it works in OSX.

You can absolutely bind the function called by C-x @ h (event-apply-hyper-modifier) to another key sequence, however.

The reason you had trouble determining that function name was that the binding is in one of the so-called "translation keymaps" which "specify translations to make while reading key sequences, rather than bindings for complete key sequences." Hence C-hk (which reads a key sequence) can't be used to establish that. OTOH note that you can still use C-x@C-h to see everything with the C-x@ prefix, which does give you the information you were after.

For more details, see C-hig (elisp) Translation Keymaps RET

In general, the event-apply-*-modifier functions (for shift, control, meta (your Alt key), super, hyper, & alt (not your Alt key)) read the next key from the user, and then apply the required modifier to that key, passing the result through as if it had been typed using the real modifier key.

The following (which I've lifted from another answer of mine) would use the number keys on the keypad to represent all the modifier keys.

You could then type the sequence h-x as <kp-5>x

(define-key function-key-map (kbd "<kp-1>") 'event-apply-control-modifier)
(define-key function-key-map (kbd "<kp-2>") 'event-apply-meta-modifier)
(define-key function-key-map (kbd "<kp-3>") 'event-apply-super-modifier)
(define-key function-key-map (kbd "<kp-4>") 'event-apply-shift-modifier)
(define-key function-key-map (kbd "<kp-5>") 'event-apply-hyper-modifier)
(define-key function-key-map (kbd "<kp-6>") 'event-apply-alt-modifier)

n.b. For F9 use (kbd "<f9>").

这篇关于是否可以使emacs作为修饰键插入fn键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆