質問

.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)))))

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

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

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

ありがとう!

役に立ちましたか?

解決

私はsmart-tabのメンテナーで、 GitHubから入手できます。最新バージョンでは、読み取り専用バッファーまたはミニバッファーでオフになるマイナーモードが定義されており、ido-modeやmagitなどが適切に機能します。また、org-modeなど、indent-for-tab-commandとは異なるコマンドをキーに実行させたい状況の処理にも優れています。 GitHubバージョンを使用することを強くお勧めします。これにより、グローバルキーバインディングを使用した基本バージョンの多くの頭痛の種が回避されます。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top