This page is about Emacs functions that execute Microsoft Windows shell commands.
On Microsoft Windows, files are typically associated with applications according to their file extension. Library w32-browser.el defines command
‘w32-browser’, which calls a Windows application, passing it a string argument such as a file name. This lets you open
*.doc files in Word, open URLs in a Web browser, and so on.
w32-browser.el also defines command
‘w32explore’, which opens Windows Explorer to a file or folder; it selects the file in Explorer.
Library Dired+ uses
w32-browser.el and defines similar commands that are bound to keys and menu items in Dired. They act on either the current file or folder or the one under the mouse. See Dired+: w32-browser.
Library Bookmark+ lets you open bookmarks using their Windows file associations. It does this by calling
‘w32-browser’. And library Dired+ lets you create bookmarks for each of the marked files in a Dired buffer, without your needing to visit them in Emacs. Combined with the ability to tag bookmarks a la del.icio.us, these features let you easily organize and open non-text files such as music and images.
‘mswindows-shell-execute’, which is similar to
‘w32-browser’. I wrote this little function, which I generally bind to
(defun gse-shellex-file (file) "My interface to shellex. In dired, filename under point is the default." (interactive (list (read-file-name (concat ;; Include default if we're in dired-mode and point is over a file. "shellex file" (if (and (string-equal major-mode "dired-mode") (dired-get-filename nil t)) (concat " [" (dired-get-filename 'no-dir t) "]")) ": ") ;; prmopt nil ;; dir (if (string-equal major-mode "dired-mode") (dired-get-filename nil t)) ;; default t ;; must-match ))) (setq file (expand-file-name file)) (mswindows-shell-execute nil file))
Comments are welcome. – ScottEvans
I suspect something like
‘w32-browser’ was named
‘mswindows-shell-execute’ on FSFmacs, until RMS decided to rename all symbols pertaining to windows, changing everything to “w32”. There’s some speculation he didn’t like the word “win” in “win32”, but I think (for once regarding RMS) that unlike the linux → gnulinux thing, this was for reasons of consistency. There’s still some political problems I have with FSFmacs, but that’s a whole other story. – ChuckAdams
EmacsMacro has file
e-w32.el where functionality similar to
‘w32-browser’ is implemented like this:
(defun dired-custom-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-custom-dired-mode-hook () (define-key dired-mode-map "X" 'dired-custom-execute-file)) (add-hook 'dired-mode-hook 'dired-custom-dired-mode-hook))