简单地说,我只是在 TAB 键上设置了一个键绑定,但是现在当我在 minibuffer 中按下 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)