首页 > 解决方案 > CTL-] 的正确名称是什么?

问题描述

从我的 .emacs 中:

(defun flip-window () "Flip this window" (interactive)
       (switch-to-buffer (other-buffer)))

;; later
(global-set-key [(control ?])] 'flip-window)

效果很好,但我有两个问题:

  1. 是否有内置函数可以翻转到最近访问的缓冲区?
  2. 虽然上述方法在 emacs 启动时有效,但在我尝试更新设置时会导致问题,存在由 ?] 引起的解析错误。那么有没有更好的方法来表达 control-] 击键?

标签: emacskey-bindings

解决方案


对问题2的回答。您可以在设置键绑定时尝试kbd功能。

像这样:

(global-set-key (kbd "C-]") 'flip-window)

对于问题 1:我想没有内置功能。Emacs redux 教我们像这样实现它:

(defun er-switch-to-previous-buffer ()
  "Switch to previously open buffer. Repeated invocations toggle between the two most recently open buffers."
  (interactive)
  (switch-to-buffer (other-buffer (current-buffer) 1)))

这是 Emacs Prelude 发行版的一部分。见https://emacsredux.com/blog/2013/04/28/switch-to-previous-buffer/


推荐阅读