ripgrep fzf and emacs

Ripgrep and FZF in Emacs

One of the things I’ve missed in the Vim to Emacs migration is solid recursive fuzzy file search. I tried bling/fzf.el, and ended up spending the weekend working on it.

Rather than just work with fuzzy file search, I got way too into the possibility of using fzf as a general completion engine. Fzf.el already had a decent way of invoking fzf (spawn a terminal buffer and shell out) but the real potential is in the programmability.

My code/fork exposes fzf by saying given a list and a function, the user can select an item with FZF and it will be passed to the function. It becomes trivial to run your own actions:

; Example
(fzf-with-entries (list "a" "b" "c") 'print)

; Open recent file
(defun fzf-recentf ()
  (fzf-with-entries recentf-list
    (lambda (f) (when (file-exists-p f) (find-file f))))

; Recursive fuzzy file search
; (resolve-directory will use the projectile root if set)
(defun fzf-find-file (&optional directory)
  (let ((d (fzf/resolve-directory directory)))
    (lambda (x)
        (let ((f (expand-file-name x d)))
        (when (file-exists-p f)
            (find-file f))))