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/{...}
undostres
  • 1,793
  • 12
  • 15

1 Answers1

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)
abo-abo
  • 13,943
  • 1
  • 29
  • 43