簡単に言えば、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)