Some programs like firefox have buttons that when clicked open a file manager for browsing files. How do I make it to open in emacs with dired mode on Debian Linux?

  • 9
    What's your operating system?
    – Drew
    Jul 12, 2015 at 21:33
  • 1
    I am using debian jessie.
    – godblessfq
    Jul 13, 2015 at 22:46

4 Answers 4


Dependent on your desktop environment the method to set a default application may differ. That said, many desktop environments respect the associations in ~/.local/share/applications/mimeapps.list, where you can set up an association for the application/x-directory and/or inode/directory types.

My mimeapps.list looks like this now:

[Default Applications]

In the same directory I have a file called emacs-dired.desktop with the following contents:

[Desktop Entry]
Exec=emacsclient --eval '(dired "%f")'
Comment=Emacs Dired

When my long-lived instance of Emacs runs a server (M-x server-start) and I click on, say, the folder icon in the list of Downloads in Icecat a new dired buffer is opened.

This actually works for me now. Thanks for asking the question --- otherwise I would not have set this up.


This is how to make emacs as default file manager in ubuntu.

First we have to write a script which will act as our file manager.

#!/usr/bin/env python
import os
import sys

def main():
    if len(sys.argv) > 1:
        dirname =  sys.argv[1]
        dirname = '~'
    os.system('emacs --eval \'(dired "{}")\'%'.format(dirname))
    # you can use emacsclient if you are running emacs server

if __name__ == "__main__":

Save this as emacsfm in /usr/bin/. Now in terminal instead of using nautilus or nautilus /foo/bar, we can use emacsfm or emacsfm /foo/bar.

Now we need to set this as default file manager. Install exo-utils using

sudo apt-get install exo-utils

and run it


It opens a new window. Go to Utilities -> File manager -> Other and enter /usr/bin/emacsfm "%s" in it.

You can goto chrome downloads and if click show in folder it will open emacs dired :-)


enter image description here Reference: https://help.ubuntu.com/community/DefaultFileManager

  • Anand, it works.. but it opens a new emacs window everytime.. it is good to use emacsclient that will open a new buffer in an already open emacs session....
    – Madhavan
    Sep 16, 2015 at 10:01
  • i think, the previous answer addresses this point...
    – Madhavan
    Sep 16, 2015 at 10:04

Although the question is specifically for Linux I went and figured it out for Windows (since this prompted me to find how to do it for myself).

Interestingly enough, you don't have to invoke Dired, simply pass a folder as the file. This saves a lot of hassle on Windows since %1 will pass c:\Users (for example) and break on \U if included in the eval statement, while passing it as a file will properly parse it.

Windows Registry Editor Version 5.00


@="Open in Dired"

@="\"%path/to/emacsclientw%\" %1"


@="Open in XYplorer"

@="\"%path/to/emacsclientw%\" %1"

Reference: Seven Forums - How to change the default File Manager


You can use Ranger. However you can configure xmonad for use emacs a windows default when you start session

  • 7
    Please expand on your answer to make it self-contained.
    – Dan
    Jul 14, 2015 at 9:25

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.