2009-02-14

launch external programs in emacs

On Feb 13, 10:48 pm, dstein64 wrote:
> Are there any functions that can launch external programs (not just
> command line programs, but also GUI programs) from Emacs?

if you OS support command line to open the gui app, then you can just use emacs's shell-command. e.g. in mac os x, to open TextEdit, do

(shell-command "open -a TextEdit")

Q: How to open the current directory in Desktop?

You can define a function and assign it a keyboard shortcut, so that by pressing a button, emacs will switch you to your operating systems's file manager (aka Desktop) with the current directory open.

On the Mac OS X, this is done with the “/usr/bin/open” command. So, press “Alt+! open .” to have Finder open the current directory. You can define the function this way:

(defun open-with-finder ()
"Open the current file in Mac's Finder."
(interactive)
(shell-command "open ."))

(global-set-key (kbd "") 'open-with-finder)

For a documentation of OS X's “open” command, see “man open”.

On Microsoft Windows, you can use “explorer.exe” instead of the “open” command.

the above is from

• Emacs and HTML Tips
http://xahlee.org/emacs/emacs_html.html

see also:

• Elisp Lesson: Execute/Compile Current File
http://xahlee.org/emacs/elisp_run_current_file.html

http://groups.google.com/group/gnu.emacs.help/browse_frm/thread/85d9f21aeff5f036

No comments:

Post a Comment