在Windows上从Emacs映射Caps Lock以进行控制 [英] Mapping Caps Lock to Control from within Emacs on Windows

查看:138
本文介绍了在Windows上从Emacs映射Caps Lock以进行控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阅读这些 问题或<关于在Windows中的emacs映射Caps Lock到控件的一个href =http://www.emacswiki.org/emacs/MovingTheCtrlKey#toc​​12 =nofollow noreferrer> EmacsWiki文章,最好的答案似乎涉及到注册表。我的问题是用户无法修改机器的注册表,因为他们没有管理员权限。有没有办法从emacs内进行映射? 这篇文章非常亲密,甚至说:正如人们所说,您当然可以将Caps-Lock映射到其他键,例如Control键。但是我不知道如何表示控制键(使用各种参考看起来很全面,但可能不是以Windows为中心),尝试像

 (setq w32-enable -caps-lock nil)
(global-set-key [capslock]'[control])

 (setq w32-enable-caps-lock nil)
(global-set-key [ capslock]'ctl-x-map)

似乎不起作用。

解决方案

我知道这不是真的回答你的问题,但Trey Jackson基本上解释了这个问题。要单独检测控制键,需要Windows上的低级键盘挂钩,我认为Emacs不会实现。



一种方法(涉及外部程序,但不需要管理员权限)是使用 AutoHotkey 。所有你需要的是以下2行脚本:

  CapsLock :: Ctrl 
LCtrl :: Capslock
只要emacs打开,你需要运行这个脚本,但是幸运的是Autohotkey是非常低调的应用程序(通常需要大约一个在内存中只有几百Kb)。您可以例如在.emacs中执行此脚本,以便每当打开emacs时,您的控制键和capslock键都会被交换。


When reading either of these questions or the EmacsWiki article about mapping Caps Lock to Control in emacs in Windows, the best answers seem to involve the registry. My question is what a user can do when they can't modify the registry of the machine because they don't have admin rights. Is there a way to do the mapping from within emacs? This article comes oh-so-close, even saying, "As people have mentioned, you can of course map Caps-Lock to other keys instead, for example the Control key." But I can't figure out how to represent the control key (using various references that look pretty comprehensive but might not be Windows-centric), trying things like

(setq w32-enable-caps-lock nil)
(global-set-key [capslock] '[control])

and

(setq w32-enable-caps-lock nil)
(global-set-key [capslock] 'ctl-x-map)

which don't seem to work.

解决方案

I know this does not really answer your question, but Trey Jackson basically explained the problem. To detect control key alone requires low-level keyboard hook on Windows, which I don't think Emacs implements.

One way (involving external program, but does not require admin right) is to use AutoHotkey. All you need is the following 2 line script:

CapsLock::Ctrl
LCtrl::Capslock

You will need to run this script whenever emacs is open, but thankfully Autohotkey is pretty low profile application (usually takes about a few hundreds Kb in memory only). You can for example execute this script in your .emacs so that your control key and capslock key are swapped whenever emacs is opened.

这篇关于在Windows上从Emacs映射Caps Lock以进行控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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