[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Browsing dirs from Dired with graphical explorer
From: |
Richard Riley |
Subject: |
Re: Browsing dirs from Dired with graphical explorer |
Date: |
Mon, 22 Sep 2008 14:05:29 +0200 |
User-agent: |
Emacs 22.2.1/No Gnus v0.11 |
Tassilo Horn <tassilo@member.fsf.org> writes:
> 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:
>
> (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)
>
>> 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.
Where is this defined? It does not exist on my debian system.
Also would you know how to make "e" open the directory/file under the
cursor? Your comments above indicate you thought this to be the case -
it actually opens the current dir.
e.g If I am in dired in ~, and the cursor is on .adobe (a dir) then
hitting e should open .adobe in nautilus in my case
,----
| (defun my-browse-dir ()
| "Open the current directory in your OS's file manager."
| (interactive)
| (let ((dir-as-string (dired-current-directory))
| (file-manager "nautilus"))
| (message "Dir is %s" dir-as-string)
| (start-process "browse" nil file-manager dir-as-string)
| )
| )
|
| (define-key dired-mode-map (kbd "e") 'my-browse-dir)
`----
>
> Bye,
> Tassilo
--
- Browsing dirs from Dired with graphical explorer, Sébastien Vauban, 2008/09/22
- Message not available
- Re: Browsing dirs from Dired with graphical explorer,
Richard Riley <=
- 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
- Re: Browsing dirs from Dired with graphical explorer, Richard Riley, 2008/09/23
- Re: Browsing dirs from Dired with graphical explorer, Richard Riley, 2008/09/24
Message not available