给Emacs安装一个脚踏板: 用Windows/Menu键作为key modifier

巴蛮子 posted @ 2010年12月13日 05:22 in Emacs with tags emacs , 6235 阅读

是不是觉得Emacs的按键都很长,很难记(比如打开文件是C-x C-f,矩形填充是C-x r t,CEDET跳转是C-c . j)?  想要修改吧,各个键都有自己本来的含义,Emacs留给用户的只有C-c a到C-c Z(以及其它更长更复杂的按键)。所以才会有“Emacs用户都恨不得给电脑安装两个脚踏板的说法。

ergoemacs ( http://code.google.com/p/ergoemacs/ )的keybinding是个好东西,尤其是对于普通用户,你可以用C-c拷贝、C-v粘贴, C-z恢复,C-o打开文件。 不过跟 上面同样的问题,对于老手,原来习惯的按键用不上了(尤其是是找不到原来的M-x了!);而且要是习惯了这样的按键,换个地方又无所适从了。

有没有即保留原来的按键,又能支持新的方式呢?

除了真的安装一个脚踏板, 我也不知道这个问题是否真的有答案。不过我无疑中发现了可以用目前常见键盘上的Windows键和Menu键来作为新的key modifier(可用作super或者hyper)。在Windows下只要用(setq w32-lwindow-modifier 'super)初始化一下就行了,然后它就能将Windows+i识别为S-i,于是你就可以绑定到函数了。(在Linux下如何设置待有时间再来研究)

下面是我根据这个思路搞的配置,将Menu键(在键盘右边,Emacs里面叫做apps键)和左边的Windows键都设定为hyper了,然后可以用H-c来拷贝, H-o来打开文件。

注 意对于windows键相关的组合,如果已经注册为系统热键(Windows自带的Win+r/Win+e或者程序通过RegisterHotKey注册 的),则系统优先使用,Emacs抢不到(我原本是想将Windows设置为super,Menu设置为hyper,这样就有两个"脚踏板"了,但由于我 已经用别的工具注册了大部分Windows+?键,而且键盘左边又没有Menu键,所以最后将左边的Windows和右边的Menu都绑定到了 hyper)

 

;;(setq w32-pass-apps-to-system nil)
(setq w32-apps-modifier 'hyper)

(setq w32-pass-lwindow-to-system nil)
(setq w32-lwindow-modifier 'hyper)


;; editing
(global-set-key (kbd "H-c") 'kill-ring-save) ;; copy
(global-set-key (kbd "H-x") 'kill-region) ;; cut
(global-set-key (kbd "H-v") 'yank) ;; paste

(global-set-key (kbd "H-a") 'mark-whole-buffer) ;; select all

(if (featurep 'undo-trees)
(progn
(global-set-key (kbd "H-z") 'undo-tree-undo)
(global-set-key (kbd "H-S-z") 'undo-tree-redo)
(global-set-key (kbd "H-y") 'undo-tree-redo))
(progn
(global-set-key (kbd "H-z") 'undo)
(if (featurep 'redo)
(progn
(global-set-key (kbd "H-S-z") 'redo)
(global-set-key (kbd "H-y") 'redo)))))



;; files
;;(global-set-key (kbd "H-n") 'create-empty-buffer) ;;FIXME
(global-set-key (kbd "H-o") 'menu-find-file-existing)
(global-set-key (kbd "H-s") 'save-buffer)
(global-set-key (kbd "H-S-s") 'write-file)

;; search
(global-set-key (kbd "H-f") 'isearch-forward)
(global-set-key (kbd "H-h") 'query-replace)
(global-set-key [H-f3] 'nonincremental-repeat-search-forward)
(global-set-key [C-H-f3] 'nonincremental-repeat-search-backward)

;; bookmarks (within buffer)
(if (featurep 'bm)
    (progn
      (global-set-key [H-f2] 'bm-next)
      (global-set-key [C-H-f2] 'bm-toggle)
      (global-set-key [S-H-f2] 'bm-previous)))

;; completion (Emacs default: M-TAB - lisp-complete-symbol, M-/ - dabbrev-expand)
(global-set-key (kbd "H-/") 'hippie-expand)

 

 
Avatar_small
sparrow 说:
2011年6月02日 16:13

super键在终端下好像无效。不知道是rxvt屏蔽了,还是就是不能用。

Avatar_small
巴蛮子 说:
2011年6月12日 14:16

@sparrow: 我也没找到方法。这些键似乎rxvt就没有传给应用程序。在console下可以试试showkey命令(终端下不管用)

另外可以看看我新写的博文,里面提供了一些workaround: [emacs] 关于快捷键设置的方案选择http://www.cnblogs.com/bamanzi/archive/2011/05/28/emacs-key-modifiers.html

Avatar_small
civaget 说:
2023年12月12日 01:15

구글 seo, with its intricate web of strategies, offers websites the chance to not just exist online but to thrive by dominating search engine rankings.

Avatar_small
civaget 说:
2023年12月13日 19:08

Find tranquility at 울산오피, where a client-centered approach, experienced team, and holistic services await to enhance your well-being.

Avatar_small
civaget 说:
2023年12月18日 23:01

If you haven't been to 인천오피 yet, you're missing out. The spa retreat is a sanctuary, and their massages are simply exceptional. A must-visit!

Avatar_small
civaget 说:
2023年12月24日 21:42

오피쓰 is a pioneer in the industry, combining real-time chat with transparency and personalized content.

Avatar_small
civaget 说:
2023年12月26日 22:34

I'm always in the know with 스포츠중계's live scores and updates.

Avatar_small
civaget 说:
2024年1月02日 19:06

I'm grateful for 부산비비기's massage suggestions.

Avatar_small
civaget 说:
2024年1月03日 16:25

Officetel enthusiast's haven: 오피가이드 is a haven for officetel enthusiasts like you.

Avatar_small
civaget 说:
2024年1月08日 21:28

Their commitment to transparency in pricing sets High Kick 레깅스룸 apart. No hidden fees, just a straightforward and enjoyable experience.

Avatar_small
civaget 说:
2024年1月11日 20:30

오피스타 is my top choice for finding nearby massage parlors. It's quick and easy to use.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter