helmを使って最近開いたディレクトリを開く

Emacs dired 最近開いたディレクトリに一瞬で移動する - Web学び


を見ていて、ディレクトリ onlyの recentfというのがあっても
いいかなってことで実装してみました。

コード

my/helm-recentfみたいに実装すると、C-uプレフィックスをつけた
場合はディレクトリ onlyで helm-recentfが使えます。

;; helm recentf only directories
(defvar helm-c-recentf-directory-source
  '((name . "Recentf Directry")
    (candidates . (lambda ()
                    (loop for file in recentf-list
                          when (file-directory-p file)
                          collect file)))
    (type . file)))

(defun my/helm-recentf (arg)
  (interactive "P")
  (if current-prefix-arg
      (helm-other-buffer helm-c-recentf-directory-source "*helm recentf*")
    (call-interactively 'helm-recentf)))

イメージ

こんな感じでディレクトリのみが対象となります。