[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Browsing dirs from Dired with graphical explorer
From: |
Tassilo Horn |
Subject: |
Re: Browsing dirs from Dired with graphical explorer |
Date: |
Mon, 22 Sep 2008 12:04:00 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
Sébastien Vauban <zthjwsqqafhv@spammotel.com>
writes:
Hi Sébastien,
> I would like some help with a snippet of code I've merged from
> different sources:
>
> (defun my-browse-dir (dir-as-string)
> "Open the current directory in your OS's file manager."
> (interactive)
> (let ((file-manager
> (cond (running-ms-windows "explorer")
> (t "/usr/lib/kde4/bin/dolphin"))))
> ;; `nautilus --no-desktop' or `gnome-open'
> (start-process-shell-command "browse"
> "*scratch*"
> (concat file-manager " " dir-as-string))))
>
> I'd like to use that when in Dired mode: to be able to launch
> the graphical file browser from the underlying OS.
>
> My problem is: how to pass the current directory argument?
If you're inside dired, you can use `dired-current-directory'. So maybe
this (untested) version does what you want:
--8<---------------cut here---------------start------------->8---
(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)))
--8<---------------cut here---------------end--------------->8---
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)
> Next question: is there somehow a way not to be forced to explicitly
> give the path to all possible executables under Linux?
Normally something like (start-process "file-browser" nil "dolphin")
should work. If not, then the PATH emacs sees is not setup correctly.
> Some way to launch the file browser like with a `start' or `open'
> command?
There's `xdg-open' which given a directory or file argument should open
it with the system's default application.
Bye,
Tassilo
--
No fortunes found
- Browsing dirs from Dired with graphical explorer, Sébastien Vauban, 2008/09/22
- Re: Browsing dirs from Dired with graphical explorer,
Tassilo Horn <=
- Message not available
- Re: Browsing dirs from Dired with graphical explorer, Richard Riley, 2008/09/22
- Re: Browsing dirs from Dired with graphical explorer, Rupert Swarbrick, 2008/09/22
- Re: Browsing dirs from Dired with graphical explorer, Tassilo Horn, 2008/09/22
- Message not available
- Re: Browsing dirs from Dired with graphical explorer, Richard Riley, 2008/09/22
- Re: Browsing dirs from Dired with graphical explorer, Tassilo Horn, 2008/09/22
- Message not available
- Re: Browsing dirs from Dired with graphical explorer, Richard Riley, 2008/09/22
- Re: Browsing dirs from Dired with graphical explorer, Tassilo Horn, 2008/09/23
- Message not available
- Re: Browsing dirs from Dired with graphical explorer, Richard Riley, 2008/09/23