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

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

dired-execute-file [was Re: [h-e-w] Help with defadvice]


From: Michael R . Wolf
Subject: dired-execute-file [was Re: [h-e-w] Help with defadvice]
Date: Wed, 18 Jun 2003 13:46:37 -0700
User-agent: Gnus/5.1001 (Gnus v5.10.1) Emacs/21.2 (windows-nt)

"Richard M. Heiberger" <address@hidden> writes:

> It looks like w32-shell-execute might do what you want.
> It uses the file extension associations that windows uses, and you
> can add your extensions in by clicking thorugh windoes explorer.
>
> I use C-c C-f in the dired to get the windows standard behavior.
> I also have some specific extensions that I use, for example
> .  myfile.eps.gz  goes to ghostview, not wherever windows would send .gz 
> files.
> I constructed this based on discussion on this list:
>
> -------------- exec.el
[...]
> (defun execute-dired-find-file ()
[...]
> (define-key dired-mode-map "\C-c\C-f" 'execute-dired-find-file)
[...]
> (defun word-dired-find-file ()
[...]
> (define-key dired-mode-map "\C-c\C-w" 'word-dired-find-file)
[...]
> (defun excel-dired-find-file ()
[...]
> (define-key dired-mode-map "\C-cx" 'excel-dired-find-file)
[...]
> (defun wordpad-dired-find-file ()
[...]
> (define-key dired-mode-map "\C-c\C-p" 'wordpad-dired-find-file)
[...]
> (defun explorer-dired-find-file ()
[...]
> (define-key dired-mode-map "\C-c\C-e" 'explorer-dired-find-file)
[...]
> (defun dos-canonical-name (filename)
[...]
> (defun gsview-dired-find-file ()
[...]
> (define-key dired-mode-map "\C-c\C-g" 'gsview-dired-find-file)

Here's a bit of code I grabbed last year. It relies on the fact that
double-click in a windows environment calls "open" which does the
correct associations between file type and file reader. Since "open"
can be called from w32-shell-execute, it's not not necessary to
(redundantly) imbed any map between file type and its "starter", nor
is it necessary to use a different key binding for Word, Excel, ... --
it's all bound to 'X'.

It *is* necessary for me to hit 'e' or 'v' or 'X' as appropriate, but
that's fine for me. In an ideal word, there's be some kind of hook
intercepting 'e' and 'v' for me in a *smart* way (where *smart* means
to send *.doc and *.xls to Word apps, but *.txt back to emacs).

Enjoy,
Michael Wolf

================================================================

;;; From: David Vanderschel <address@hidden>
;;; Subject: Re: [h-e-w] mailcap file and filename/type associations for 
Windows 95
;;; To: address@hidden
;;; Date: 05 Jan 2002 17:47:47 -0600
;;; dired stuff to open files a la Windows from Howard Melman
(defun dired-execute-file (&optional arg)
  (interactive "P")
  (mapcar #'(lambda (file)
              (w32-shell-execute "open" (convert-standard-filename file)))
          (dired-get-marked-files nil arg)))

(defun dired-mouse-execute-file (event)
  "In dired, execute the file or goto directory name you click on."
  (interactive "e")
  (set-buffer (window-buffer (posn-window (event-end event))))
  (goto-char (posn-point (event-end event)))
  (if (file-directory-p (dired-get-filename))
      (dired-find-file)
    (dired-execute-file)))

(defun hrm-dired-mode-hook ()
  "Hook run when entering dired-mode."
    (define-key dired-mode-map "X" 'dired-execute-file)
    (define-key dired-mode-map [M-down-mouse-1] 'dired-mouse-mark-file))

(global-set-key [?\C-x mouse-2] 'dired-mouse-execute-file)
(add-hook 'dired-mode-hook 'hrm-dired-mode-hook)


-- 
Michael R. Wolf
    All mammals learn by playing!
        address@hidden





reply via email to

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