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

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

Re: [h-e-w] Customizing run-shell-command


From: Richard M. Heiberger
Subject: Re: [h-e-w] Customizing run-shell-command
Date: Thu, 16 Dec 2004 10:25:05 -0500

I use the file exec.el, which I wrote based on discussion on
this list about three years ago.  It gives keystrokes for specific
programs and a generic keystroke C-c C-f to do what doubleclicking
in Windows Explorer would do.  I keep this file in site-lisp
and load it from site-start.el with the lines

;;; allows files to be executed directly from the dired window
(load-library "exec.el")

To change the default behavior in Windows Explorer,
it is necessary to use the Windows Explorer menu item
   Tools/Folder Options/File Types


;; 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 nil t))))
(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 nil t)))))))
(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)
;; -----------------------------------------------------------------




reply via email to

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