unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: pjb@informatimago.com (Pascal J. Bourguignon)
To: help-gnu-emacs@gnu.org
Subject: Re: Executing External Programs from Emacs
Date: Sat, 14 Feb 2009 11:00:06 +0100	[thread overview]
Message-ID: <87zlgp8hjt.fsf@galatea.local> (raw)
In-Reply-To: 1a12217a-86cb-4088-8fd1-731ce415e68a@z28g2000prd.googlegroups.com

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	other threads:[~2009-02-14 10:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-14  6:48 Executing External Programs from Emacs dstein64
2009-02-14 10:00 ` Pascal J. Bourguignon [this message]
2009-02-14 10:30 ` Nurullah Akkaya
2009-02-14 10:53 ` Lennart Borgman
2009-02-14 13:08 ` Michael Albinus
2009-02-14 14:47 ` Xah Lee
2009-02-14 20:30 ` tyler
2009-02-16 11:52 ` Josef G. Bauer
  -- strict thread matches above, loose matches on Subject: below --
2009-02-14 21:25 Xavier Maillard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zlgp8hjt.fsf@galatea.local \
    --to=pjb@informatimago.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).