help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Browsing dirs from Dired with graphical explorer


From: Rupert Swarbrick
Subject: Re: Browsing dirs from Dired with graphical explorer
Date: Mon, 22 Sep 2008 13:55:59 +0100
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/22.2 (gnu/linux)

Tassilo Horn <tassilo@member.fsf.org> writes:

>
> If you're inside dired, you can use `dired-current-directory'.  So maybe
> this (untested) version does what you want:
>
> (defun my-browse-dir ()
>   "Open the current directory in your OS's file manager."
>   (interactive)
>   (let ((dir-as-string (dired-current-directory))
>         (file-manager
>          (cond (running-ms-windows "explorer")
>                (t "/usr/lib/kde4/bin/dolphin"))))
>     (start-process "browse" nil file-manager dir-as-string)))
>
> In should open the directory point is on.  If it's on a file, it depends
> on what the file manager does when it gets a file argument.  Most will
> open it with an appropriate application.
>
> You might want to bind the function so some key in dired.
>
>   (define-key dired-mode-map (kbd "e") 'my-browse-dir)

Another way, that doesn't need dired to be running is to use emacs'
directory expansion. That is,

(expand-file-name ".")

gives the full pathname of the current directory. This is a bit hacky,
to be honest, but I don't know a neater solution. Tassilo's solution now
becomes:

Attachment: binFMnhVukGk1.bin
Description: application/emacs-lisp

Personally though, I wouldn't use the let form at all, and would just
write the following:

Attachment: binxSH5d50p4k.bin
Description: application/emacs-lisp

Finally, since this now works outside of dired, you can use a global
keybinding if you want - how about:

(global-set-key (kbd "C-<f12>") 'my-browse-dir)

(of course, C-<f12> isn't necessarily what you want to use).


Rupert

Attachment: pgpya0Kwf2c_V.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]