bling / fzf.el

A front-end for fzf

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Working directory is changed when opening file with fzf

4ice opened this issue · comments

If I use M-x fzf to find a file and I open it, my working directory is changed to the folder of the opened file. This means that when I later want to use fzf again, the search is very limited. Is there a setting to disable this?

i'd recommend installing https://github.com/bbatsov/projectile, which fzf will detect and use the correct project directory.

I had the same issue. I got around it by customizing the fzf/directory-start variable to "~" and use fzf-directory, so it always starts from my home folder. Also, I modified this func

(defun fzf-directory ()
  "Starts a fzf session at the specified directory."
  (interactive)
  (fzf/start (ido-read-directory-name "Directory: " fzf/directory-start)))

to

(defun fzf-directory ()
  "Starts a fzf session at the specified directory."
  (interactive)
  (fzf/start fzf/directory-start))

so it doesn't prompt me for a folder every time.

I'm curious how fzf managed to narrow down to its previous found folder, I don't know too much elisp, I guess it's the default-directory variable that is constantly get updated every time fzf() is called? But even if I comment out these

    (with-current-buffer buf
      (setq default-directory directory))

it still narrows down to the last visited folder.