简而言之,我只是在 TAB 键上设置了键绑定,但是现在当我将 TAB 推入迷你缓冲区以自动完成命令时,它会失败并显示以下消息:The mark is not set now, so there is no region
.
换句话说,当我的光标位于缓冲区(而不是迷你缓冲区)中时,我只需要 TAB 键绑定。
在下面的示例中,当我在缓冲区中处于文本/基本模式时,如何将选项卡设置为缩进,而不会在迷你缓冲区中丢失自动完成功能?我有以下功能和键绑定:
;; Shift the selected region right if distance is postive, left if
;; negative
(defun shift-region (distance)
(let ((mark (mark)))
(save-excursion
(indent-rigidly (region-beginning) (region-end) distance)
(push-mark mark t t)
;; Tell the command loop not to deactivate the mark
;; for transient mark mode
(setq deactivate-mark nil))))
(defun shift-right ()
(interactive)
(shift-region 2))
(defun shift-left ()
(interactive)
(shift-region -2))
;; Bind (shift-right) and (shift-left) function to your favorite keys. I use
;; the following so that Ctrl-Shift-Right Arrow moves selected text one
;; column to the right, Ctrl-Shift-Left Arrow moves selected text one
;; column to the left:
;; (global-set-key [C-S-right] 'shift-right)
;; (global-set-key [C-S-left] 'shift-left)
(global-set-key [tab] 'shift-right)
(global-set-key [backtab] 'shift-left)
问题很简单,您将命令绑定到[tab]
而不是为了"\t"
. tab
表示 GUI 下的 TAB 键,但在 tty 下 Emacs 会接收 TAB 字符(即?\t
),所以当你击中tab
Emacs 首先寻找tab
绑定,如果没有,则function-key-map
重新映射将其变成?\t
并再次尝试。迷你缓冲区仅绑定"\t"
,所以任何全局绑定[tab]
将优先。
简而言之,使用(global-set-key "\t" 'shift-right)
这个问题将会消失。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)