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

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

Re: double-click or return in dired to launch application


From: Enila Nero
Subject: Re: double-click or return in dired to launch application
Date: Fri, 05 Mar 2004 16:38:22 GMT
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (windows-nt)

Joel Smith <joelvsmith@earthlink.net> writes:

> Benjamin Rutt <brutt+news@bloomington.in.us> writes:
>
>> Joel Smith <joelvsmith@earthlink.net> writes:
>> 
>> > is it possible to double-click on a file in dired and have it launch
>> > an application, i.e. click on a .doc document and word opens with
>> > the document.  i'm using emacsnt, but it would be interesting to set
>> > this up at home on my linux box as well.  thanks.
>> 
>> I have the following set up to do file associations and actions:
>> 
>> (setq dired-guess-shell-alist-user
>>       '(("\\.jpe?g\\'" "xli")
>>      ("\\.gif\\'" "xli")
>>      ("\\.pdf\\'" "acroread")
>>      ("\\.pdf.gz\\'" "gv")
>>      ("\\.ps.gz\\'" "gv")
>>      ("\\.ps\\'" "gv")))
>> 
>> which allows me to specify what happens when I apply the ! key in
>> dired to a specific file.  I suppose you could add something like
>> 
>>     ("\\.doc\\'" "start")
>> 
>> to that list in windows and it should work (use "ooffice" instead of
>> "start" in linux).  Then, you could press ! RET on one of those files.
>> I'm not sure if that's what you want.
>> 
>> As to how to get it to work from a double-click, I'm not sure if it's
>> possible or not to intercept double-clicks, anyone?
>> -- 
>> Benjamin
>
> I put in dired-x and added dired-guess-shell-alist-user to my .emacs like
>
>  (add-hook 'dired-load-hook
>            (function (lambda ()
>                        (load "dired-x")
>                        ;; Set global variables here.  For example:
>                        ;; (setq dired-guess-shell-gnutar "gtar")
>                      (setq dired-guess-shell-alist-user
>                            '(("\\.jpe?g\\'" "xli")
>                              ("\\.pdf\\'" "Acrobat")
>                              ("\\.pdf.gz\\'" "gsview32")
>                              ("\\.ps.gz\\'" "gsview32")
>                              ("\\.doc\\'" "start")
>                              ("\\.ps\\'" "gsview32")))
>                        )))
>
> I type ! RET and a word document appeared on the screen.  wow!  but the only 
> problem is that when the word document is open, emacs freezes until the 
> process is closed.  How do I run these things in the background?  
>
> I'm not sure how to use the double-click response, i.e. how to use 
> dired-do-shell-command with the list provided by dired-guess-shell-alist-user.
> i'll stick with the first method provided i can run things in the background.
> Thanks for the help.

For windows try this:

(defun w32-browser (doc)
  "Browse to a particular file/URL using default application"
  (w32-shell-execute 1 doc))

(eval-after-load "dired"
  '(progn
     (define-key dired-mode-map [f3] (lambda () 
                                       (interactive)
                                       (w32-browser
                                        (dired-replace-in-string 
                                         "/" "\\" 
                                         (dired-get-filename)))))
     (define-key dired-mode-map [(double-down-mouse-1)] (lambda () 
                                                     (interactive)
                                                     (w32-browser
                                                      (dired-replace-in-string 
                                                       "/" "\\" 
                                                       (dired-get-filename)))))
))

Best of luck.


reply via email to

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