ズズズなブログ

はてブロ出戻り組です〜

verticoの補完を見直し

Emacsのverticoの補完の挙動がイマイチしっくりこない。

bashの補完みたいにTAB押したら候補の共通部分の終わりまでズバッと入力してほしい。

公式のREADMEをよく読むと、どうすればいいか書いてあった。

https://github.com/minad/vertico?tab=readme-ov-file#completion-styles-and-tab-completion

The orderless completion style does not support expansion of a common candidate prefix, as supported by shells or the basic default completion system. The reason is that the Orderless input string is usually not a prefix. In order to support completing prefixes, combine orderless with substring in your completion-styles configuration.

orderless補完スタイルは、シェルや基本的なデフォルト補完システムでサポートされているような、共通の候補接頭辞の展開をサポートしていません。その理由は、orderless の入力文字列は通常接頭辞ではないからです。接頭辞の補完をサポートするには、補完スタイルの設定で orderless を substring と組み合わせます。

というわけで、そこの例を参考に以下のようにしたらうまく行った。

(use-package vertico
  :config
  (setq completion-styles '(substring orderless basic))

  :bind (:map vertico-map
           ("TAB" . minibuffer-complete)))

もう2年以上もしっくりこないまま使ってたけど、こんなことならもっと早くやっておくんだったよ。