0

.emacs で次の smart-tab defun を使用して、単語を補完するか、標準のタブを実行します。

(global-set-key [(tab)] 'smart-tab)
(defun smart-tab ()
  "This smart tab is minibuffer compliant: it acts as usual in
    the minibuffer. Else, if mark is active, indents region. Else if
    point is at the end of a symbol, expands it. Else indents the
    current line."
  (interactive)
  (if (minibufferp)
      (unless (minibuffer-complete)
        (dabbrev-expand nil))
    (if mark-active
        (indent-region (region-beginning)
                       (region-end))
      (if (looking-at "\\_>")
          (dabbrev-expand nil)
        (indent-for-tab-command)))))

ただし、magit-statusgit Git 統合に使用している場合、以前は、変更されたファイルを選択し、タブをクリックして、そのファイルの差分を即座に表示し、変更された内容を確認できました。ただし、今タブを試みるたびに、ミニバッファーに次のエラーが表示されます。

indent-relative: Buffer is read-only: #<buffer *magit: my_project*

これにアプローチし、上記のスマートタブを特定のモードにのみ適用することについて何か考えはありますか?

ありがとう!

4

1 に答える 1

5

I am the maintainer of smart-tab, available from GitHub. The latest version defines a minor mode which turns itself off in a read-only buffer or the minibuffer, allowing things like ido-mode and magit to work properly. It also is better at handling situations where you want the key run a different command than indent-for-tab-command, such as org-mode. I highly recommend you use the GitHub version, as it avoids a lot of the headaches of the basic version with a global keybinding.

于 2009-10-22T02:58:28.697 に答える