7

When calling ido-find-file it's possible to type ~/ to replace the current working directory with your home directory automatically:

Find file: /etc/{...} # after typing ~/ becomes:
Find file: ~/{...}

How can I replicate this but for a custom directory such as user-emacs-directory and when pressing a key instead of inserting text in the minibuffer? For example:

Find file: /var/log/{...} # after pressing F6 becomes:
Find file: ~/.emacs.d/{...}
7

I was just about to make a blog post about this (I'll do it later anyway):

(defun oleh-ido-setup-hook ()
  (define-key ido-file-dir-completion-map "~"
    (lambda ()
      (interactive)
      (ido-set-current-directory "~/")
      (setq ido-exit 'refresh)
      (exit-minibuffer))))

(add-hook 'ido-setup-hook 'oleh-ido-setup-hook)

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.