【Emacs】verticoの設定2024

こんな感じにしている.

(add-hook 'after-init-hook #'vertico-mode)

(with-eval-after-load 'vertico
  (setq vertico-cycle t)

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

  ;; vertico-directory
  (define-key vertico-map "DEL" #'vertico-directory-delete-char)
  (keymap-set vertico-map "C-l" #'vertico-directory-up)

  ;; vertico-quick
  (keymap-set vertico-map "M-q" #'vertico-quick-insert) ;; avy-likeに候補選択してミニバッファ入力
  (keymap-set vertico-map "C-q" #'vertico-quick-exit)   ;; avy-likeに候補選択して即時実行
  
  ;; 以下のサイトを参考にverticoにカーソルを導入し,かつカーソルの色をfaceにより指定した
  ;; https://qiita.com/nobuyuki86/items/4150d5ec433e62757951
  (require 'nerd-icons)
  (defvar +vertico-current-arrow t)
  (cl-defmethod vertico--format-candidate :around
    (cand prefix suffix index start &context
          ((and +vertico-current-arrow
                (not (bound-and-true-p vertico-flat-mode)))
           (eql t)))
    (setq cand (cl-call-next-method cand prefix suffix index start))
    (if (bound-and-true-p vertico-grid-mode)
        (if (= vertico--index index)
            (concat (nerd-icons-faicon "nf-fa-hand_o_right" :face 'nerd-icons-blue)
                    "\t" cand)
          (concat #("_" 0 1 (display " ")) cand))
      (if (= vertico--index index)
          (concat " " (nerd-icons-faicon "nf-fa-hand_o_right" :face 'nerd-icons-blue)
                  "\t" cand)
        (concat "\t" cand))))

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