0

I use ivy-mode for completion. I don't usually want to see the dot files ("./" and "../") when selecting files/directories, so I've set (setq ivy-extra-directories nil). I also want to use the selectable prompt option: (setq ivy-use-selectable-prompt t).

Mostly, this is fine. However, there's one unfortunate interaction. When I want to start an R session with the ESS package, I'm prompted for the buffer I want to start in. Of course, the list doesn't include the current directory ./, since I've configured it not to. And the prompt from ESS requires a match from the list of directories, which prevents me from selecting the empty prompt.

This means the default directory selected will be the first directory within the current directory, and if I want to select the current directory I need to back up one level and select it from there. This is awkward.

How can I configure ESS and/or ivy to allow me to start R in the current directory by default, while maintaining my ivy configurations globally?

0

The function in ESS that sets the directory is ess-prompt-for-directory. By applying an :around advice, we can temporarily add the dot files back to the ivy-mode completion targets:

(defun tws-ess-ivy-fix (orig-fun &rest args)
  "Temporarily add dot files to the list of directories offered."
  (let ((ivy-extra-directories '("../" "./")))
    (apply orig-fun args)))

(advice-add 'ess-prompt-for-directory :around #'tws-ess-ivy-fix)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.