アフィリエイト広告を利用しています

2022年06月29日

Emacs: Helm から Vertico に乗り換える

Helm の更新が止まってしまったようなので, 補完機能のインターフェースを新しい Vertico フレームワークに変えてみる.

Emacsの次世代ミニバッファ補完UI を参考にした.

上記のサイトに従って, MELPA から vertico, consult, marginalia, orderless, embark をインストールする.

init.el に加えた変更としては,
・ Helm の設定をコメントアウト
・ Vertico などの設定
がある.

Vertico 等の設定は
・ Vertico の GitHub にある README.org
・ Embark の GitHub にある README.org
で紹介されているものをほぼそのまま使った.

;;; Vertico
;; Enable vertico
(use-package vertico
:init
(vertico-mode)

;; Different scroll margin
(setq vertico-scroll-margin 0)

;; Show more candidates
(setq vertico-count 20)

;; Grow and shrink the Vertico minibuffer
(setq vertico-resize t)

;; Optionally enable cycling for `vertico-next' and `vertico-previous'.
(setq vertico-cycle t)
)

;; Persist history over Emacs restarts. Vertico sorts by history position.
(use-package savehist
:init
(savehist-mode))

;; A few more useful configurations...
(use-package emacs
:init
;; Add prompt indicator to `completing-read-multiple'.
;; We display [CRM], e.g., [CRM,] if the separator is a comma.
(defun crm-indicator (args)
(cons (format "[CRM%s] %s"
(replace-regexp-in-string
"\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" ""
crm-separator)
(car args))
(cdr args)))
(advice-add #'completing-read-multiple :filter-args #'crm-indicator)

;; Do not allow the cursor in the minibuffer prompt
(setq minibuffer-prompt-properties
'(read-only t cursor-intangible t face minibuffer-prompt))
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)

;; Emacs 28: Hide commands in M-x which do not work in the current mode.
;; Vertico commands are hidden in normal buffers.
;; (setq read-extended-command-predicate
;; #'command-completion-default-include-p)

;; Enable recursive minibuffers
(setq enable-recursive-minibuffers t))

;;; Optionally use the `orderless' completion style.
(use-package orderless
:ensure t
:custom
(completion-styles '(orderless basic))
(completion-category-overrides '((file (styles basic partial-completion)))))

;;; Consult
(require 'consult)

;;; Marginalia
(use-package marginalia
:ensure t
:config
(marginalia-mode))

(use-package embark
:ensure t

:bind
(("C-." . embark-act) ;; pick some comfortable binding
("M-." . embark-dwim) ;; good alternative: M-.
("C-h B" . embark-bindings)) ;; alternative for `describe-bindings'

:init

;; Optionally replace the key help with a completing-read interface
(setq prefix-help-command #'embark-prefix-help-command)

:config

;; Hide the mode line of the Embark live/completions buffers
(add-to-list 'display-buffer-alist
'("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
nil
(window-parameters (mode-line-format . none)))))

;; Consult users will also want the embark-consult package.
(use-package embark-consult
:ensure t
:after (embark consult)
:demand t ; only necessary if you have the hook below
;; if you want to have consult previews as you move around an
;; auto-updating embark collect buffer
:hook
(embark-collect-mode . consult-preview-at-point-mode))

Vertico を使うと, ファイルやバッファーなど, 何かを選択するタイミングでミニバッファーが縦に伸びてそこに補完候補が表示される.
視線の移動が少なくてよい.

また, Control-. にバインドした embark-act によって補完インターフェースで選択されているファイル, バッファー, ディレクトリーなどの対象へのアクションを選択できる.
たとえば, byte-compile-file や browse-url, dired などである.

同様に Meta-. にバインドした embark-dwim によって, 選択されている対象へのデフォルトのアクションを実行できる.

consult-goto-line (Meta-'-' にバインドした) を実行すると, 自動的にバッファー内の各行に行番号が付くので, それを見ながら行の移動が動的に行える.

まだ使い始めたばかりだが, 便利なので今後使っていくことにする.
タグ:Emacs29 Vertico
この記事へのコメント
コメントを書く

お名前:

メールアドレス:


ホームページアドレス:

コメント:

この記事へのトラックバックURL
https://fanblogs.jp/tb/11488404

この記事へのトラックバック
ファン
検索
<< 2024年04月 >>
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30        
最新記事
最新コメント
眼科の定期検査 〜 散歩 by コトタマ (02/15)
眼科の定期検査 by 三文字寄れば文殊のヒフミヨ (09/21)
本を読んで過ごす by 底彦 (12/13)
本を読んで過ごす by ねこ (12/12)
数学の計算をする by 底彦 (12/04)
タグクラウド
カテゴリアーカイブ
仕事(59)
社会復帰(22)
(40)
コンピューター(197)
(1343)
借金(8)
勉強(7)
(12)
数学(97)
運動(8)
日常生活(1316)
(198)
健康(33)
読書(19)
プロフィール

ブログランキング・にほんブログ村へ
にほんブログ村
にほんブログ村 メンタルヘルスブログ うつ病(鬱病)へ
にほんブログ村
にほんブログ村 科学ブログ 数学へ
にほんブログ村
にほんブログ村 IT技術ブログ プログラム・プログラマーへ
にほんブログ村