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

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

Re: Executing External Programs from Emacs


From: Pascal J. Bourguignon
Subject: Re: Executing External Programs from Emacs
Date: Sat, 14 Feb 2009 11:00:06 +0100
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin)

dstein64 <DStein64@gmail.com> writes:

> Are there any functions that can launch external programs (not just
> command line programs, but also GUI programs) from Emacs? I know that
> I can access a shell, and call a program from there, but then emacs is
> not operable until I close the program. Prepending the command with
> `nohup' is useful, but for some reason it does not work as expected
> with all programs, including emacs. 

You should read: http://catb.org/esr/writings/taoup/html/
Pay particular attention to the chapter 11.

> I would prefer another way of
> doing this - using a specific built-in of emacs lisp if one exists.
> Any help would be greatly appreciated. Thanks.


(defun run-any-program (program &rest arguments)
  (let ((output (get-buffer-create (format "*%s output*" (gensym program)))))
    (shell-command (format "xterm -T \"Controlling terminal for %s\" -e %s %s 
&" 
                           (shell-quote-argument program)
                           (shell-quote-argument program)
                           (with-output-to-string
                               (dolist (arg arguments)
                                 (princ (shell-quote-argument arg))
                                 (princ " "))))
                   output output)))

(run-any-program "xclock")
(run-any-program "vim")
(run-any-program "emacs" "-q" "-nw")
(run-any-program "emacs" "-q")

-- 
__Pascal Bourguignon__


reply via email to

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