I access a lot of files from a certain directory which is not ~ but say: D:\Mijn documenten\My Dropbox.

What is the quickest way to 'find' a file in that directory within a new Emacs session? Using bookmarks?


I typically switch to another buffer editing a file in that common directory so that when I C-x C-f to find a new file, the path is already showing the directory I want.

This works for new sessions because I have desktop-save-mode enabled to save my session when I exit emacs (and the only time I exit emacs is if I'm updating emacs or have to reboot my machine).

  • Ain't that many keys, especially if you didn't just used one ? Switching is C-x b <find one> RET, right ? – Nikana Reklawyks Oct 29 '12 at 15:07

ido is really nice for this exact reason. These are the sites where I first read about it:


You can open any directory you choose in dired. (C-xd and directory name.) You can search for the filename in the dired buffer.

If you simply want to change the current directory to be /something/else instead of ~, you can do M-x cd and change it to the directory you want. The next time you do C-x C-f to open a file, you will be in the different directory.


Also take a look at Speedbar.

Speedbar is another frame which displays information about the current buffer, allowing you to better navigate your sources.


I'd bind “going to that dir” to a single key, and C-x C-f from there.

(defun my-favorite-directory ()
    "Open where I often go."
    (find-file "/path/to/there"))
(global-set-key [f5] 'my-favorite-directory) ; Let it be a global bookmark.

Or, as you suggest, I'm sure you could use bookmarks.


Two packages that are good at this aside from the ones already mentioned:

  • Projectile
    • any version-controlled folder is a "project"
    • you can quickly jump to any project and then any file inside a project
    • add a .projectile file to identify other folders as "projects"
    • integrates with ido, helm, ivy (recommended)
  • emacs-fasd
    • thin layer on top of the command-line utility
    • jump to commonly used files and directories
    • integrates with ido, helm, ivy (recommended)

Of course, for very frequently accessed files, like my dotfiles, I do the following:

(defmacro radian-register-dotfile (filename &optional keybinding)
  "Tell Radian about a dotfile.

This is best demonstrated by example. If NAME is
\".emacs.d/init.el\" then `radian-register-dotfile' will create
the interactive function `radian-find-init-el'. Calling that
function will invoke `find-file' on ~/.emacs.d/init.el.

If additionally KEYBINDING is \"e i\" then
`radian-register-dotfile' will use `global-set-key' to bind
`radian-find-init-el' to (kbd \"M-RET e i\")."
  (let* ((bare-filename (replace-regexp-in-string ".*/" "" filename))
         (defun-name (make-symbol
                       (replace-regexp-in-string "[^a-z0-9]" "-" bare-filename))))
         (full-filename (concat "~/" filename))
         (docstring (format "Open %s in the current buffer."
         (defun-form `(defun ,defun-name ()
                        (find-file ,full-filename))))
    (if keybinding
        (let* ((full-keybinding (concat "M-RET " keybinding))
               (set-key-form `(global-set-key (kbd ,full-keybinding)

;; Emacs
(radian-register-dotfile ".emacs.d/init.el" "e i")
(radian-register-dotfile ".emacs.d/init.before.local.el" "e b")
(radian-register-dotfile ".emacs.d/init.local.el" "e l")

;; Git
(radian-register-dotfile ".gitconfig" "g c")
(radian-register-dotfile ".gitexclude" "g e")
(radian-register-dotfile ".gitconfig.local" "g l")

;; Et cetera

My init.el is here.

I hear that Emacs also has file registers, which are used for the same purpose as my custom macro above.

  1. If this is about having a preferred directory be the default (default-directory) when you start an Emacs session, then just start Emacs in that directory. For example, in MS Windows you would put that directory in the Start in field of a shortcut that you use to start Emacs.

    No need to use desktop-save-mode, if you always want to have that directory be the current one at Emacs startup.

    And you can show Dired for that directory when you start Emacs: just pass the directory as the file to edit on the command line.

  2. If you want a persistent, quick way to get to a particular directory, making it the default, and showing Dired for it, then just create a Dired bookmark. That is, create a bookmark when you are in a Dired buffer. You will want library Bookmark+ for bookmarking Dired buffers.

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.