以下の関数を使う。 consult-lineと実質的な働きは変わらないのがメリット。 つまり、 consult-ripgrepの設定(migemo化など)が活きるので、例えばconsult-line系に限定したmigemo化の設定は不要となる点。 そのほか、consult-lineをmigemo化すると、最初の数文字の入力で表示がもたつく(おそらくmigemoに関する正規表現の展開がデカイ)ので、今回のconsult-ripgrep-single-fileによりそれを回避したスムーズな入力と候補絞り込みが実現できる。
(defun consult-ripgrep-single-file () "Call `consult-ripgrep' for the current buffer (a single file)." (interactive) (let ((consult-project-function (lambda (x) nil)) (consult-ripgrep-args (concat "rg " "--null " "--line-buffered " "--color=never " "--line-number " "--smart-case " "--no-heading " "--max-columns=1000 " "--max-columns-preview " "--with-filename " (shell-quote-argument buffer-file-name)))) (consult-ripgrep)))