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

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

RE: [h-e-w] Help with defadvice


From: Richard M. Heiberger
Subject: RE: [h-e-w] Help with defadvice
Date: Wed, 18 Jun 2003 18:48:43 -0400 (EDT)

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
(require 'dired)

(defun execute-dired-find-file ()
  "In dired, run the w32-shell-execute on this file."
  (interactive)
  ;; dired-get-filename is defined in dired.el
  (w32-shell-execute nil (dos-canonical-name (dired-get-filename))))
(define-key dired-mode-map "\C-c\C-f" 'execute-dired-find-file)

(defun word-dired-find-file ()
  "In dired, run the MS Word on this file."
  (interactive)
  ;; dired-get-filename is defined in dired.el
  (w32-shell-execute nil "winword" (w32-short-file-name (dired-get-filename))))
(define-key dired-mode-map "\C-c\C-w" 'word-dired-find-file)

(defun excel-dired-find-file ()
  "In dired, run the MS Excel on this file."
  (interactive)
  ;; dired-get-filename is defined in dired.el
  (w32-shell-execute nil "c:/progra~1/micros~2/office10/excel.exe"
                     (w32-short-file-name (dired-get-filename))))
(define-key dired-mode-map "\C-cx" 'excel-dired-find-file)

(defun wordpad-dired-find-file ()
  "In dired, run the MS wordpad on this file."
  (interactive)
  ;; dired-get-filename is defined in dired.el
  (w32-shell-execute nil "wordpad" (w32-short-file-name (dired-get-filename))))
(define-key dired-mode-map "\C-c\C-p" 'wordpad-dired-find-file)

(defun explorer-dired-find-file ()
  "In dired, run the MS Windows Explorer on this file."
  (interactive)
  ;; dired-get-filename is defined in dired.el
  (w32-shell-execute nil "explorer" (concat "/e," (dos-canonical-name 
(file-name-directory (w32-short-file-name (dired-get-filename)))))))
(define-key dired-mode-map "\C-c\C-e" 'explorer-dired-find-file)

(defun dos-canonical-name (filename)
"Canonicalize filename forcing `\\' as directory-sep-char."
  (let ((directory-sep-char ?\ ))
    (expand-file-name filename)))

(defun gsview-dired-find-file ()
  "In dired, run Ghostview on this file."
  (interactive)
  ;; dired-get-filename is defined in dired.el
  (w32-shell-execute nil "gsview32" (dired-get-filename)))
(define-key dired-mode-map "\C-c\C-g" 'gsview-dired-find-file)


----------------------- end exec.el
Rich




reply via email to

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