all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Executing External Programs from Emacs
@ 2009-02-14  6:48 dstein64
  2009-02-14 10:00 ` Pascal J. Bourguignon
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: dstein64 @ 2009-02-14  6:48 UTC (permalink / raw
  To: help-gnu-emacs

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. 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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Executing External Programs from Emacs
  2009-02-14  6:48 dstein64
@ 2009-02-14 10:00 ` Pascal J. Bourguignon
  2009-02-14 10:30 ` Nurullah Akkaya
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Pascal J. Bourguignon @ 2009-02-14 10:00 UTC (permalink / raw
  To: help-gnu-emacs

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__


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Executing External Programs from Emacs
  2009-02-14  6:48 dstein64
  2009-02-14 10:00 ` Pascal J. Bourguignon
@ 2009-02-14 10:30 ` Nurullah Akkaya
  2009-02-14 10:53 ` Lennart Borgman
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Nurullah Akkaya @ 2009-02-14 10:30 UTC (permalink / raw
  Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 750 bytes --]

On Sat, Feb 14, 2009 at 8:48 AM, dstein64 <DStein64@gmail.com> wrote:

> 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. 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.
>

try using M-x term it does not block your session while running.

if you want to roll your own have a look at start-process function.

[-- Attachment #2: Type: text/html, Size: 1042 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Executing External Programs from Emacs
  2009-02-14  6:48 dstein64
  2009-02-14 10:00 ` Pascal J. Bourguignon
  2009-02-14 10:30 ` Nurullah Akkaya
@ 2009-02-14 10:53 ` Lennart Borgman
  2009-02-14 13:08 ` Michael Albinus
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Lennart Borgman @ 2009-02-14 10:53 UTC (permalink / raw
  To: dstein64; +Cc: help-gnu-emacs

On Sat, Feb 14, 2009 at 7:48 AM, dstein64 <DStein64@gmail.com> wrote:
> 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. 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.

This is OS dependent. There are some examples on EmacsWiki for MS Windows.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Executing External Programs from Emacs
  2009-02-14  6:48 dstein64
                   ` (2 preceding siblings ...)
  2009-02-14 10:53 ` Lennart Borgman
@ 2009-02-14 13:08 ` Michael Albinus
  2009-02-14 14:47 ` Xah Lee
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Michael Albinus @ 2009-02-14 13:08 UTC (permalink / raw
  To: dstein64; +Cc: help-gnu-emacs

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. 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.

Tramp does it. Tested with Emacs 23.0.90:

(with-temp-buffer
  (cd "/ssh:remotehost:")
  (add-to-list 'tramp-remote-process-environment
	       (concat "DISPLAY=" (getenv "DISPLAY"))
  (start-file-process "xterm" nil "xterm"))

Best regards, Michael.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Executing External Programs from Emacs
  2009-02-14  6:48 dstein64
                   ` (3 preceding siblings ...)
  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
  6 siblings, 0 replies; 9+ messages in thread
From: Xah Lee @ 2009-02-14 14:47 UTC (permalink / raw
  To: help-gnu-emacs

On Feb 13, 10:48 pm, dstein64 <DStei...@gmail.com> wrote:
> 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. 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.

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 "<f2>") '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

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Executing External Programs from Emacs
  2009-02-14  6:48 dstein64
                   ` (4 preceding siblings ...)
  2009-02-14 14:47 ` Xah Lee
@ 2009-02-14 20:30 ` tyler
  2009-02-16 11:52 ` Josef G. Bauer
  6 siblings, 0 replies; 9+ messages in thread
From: tyler @ 2009-02-14 20:30 UTC (permalink / raw
  To: help-gnu-emacs

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?

From a shell within Emacs, call the command followed by '&'. You can
also do this from with the 'shell-command' function, which is invoked
with M-!. So, to call a pdf viewer, for example, you could do:

M-! xpdf & <return>

Cheers,

Tyler



> 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. 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.

-- 
Philosophy of science is about as useful to scientists as ornithology is
to birds.                              --Richard Feynman


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Executing External Programs from Emacs
@ 2009-02-14 21:25 Xavier Maillard
  0 siblings, 0 replies; 9+ messages in thread
From: Xavier Maillard @ 2009-02-14 21:25 UTC (permalink / raw
  To: dstein64; +Cc: help-gnu-emacs


   Are there any functions that can launch external programs (not just
   command line programs, but also GUI programs) from Emacs?

You could try eev-mode [1].

[1] http://www.emacswiki.org/emacs/EevMode

	Xavier
-- 
http://www.gnu.org
http://www.april.org
http://www.lolica.org




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Executing External Programs from Emacs
  2009-02-14  6:48 dstein64
                   ` (5 preceding siblings ...)
  2009-02-14 20:30 ` tyler
@ 2009-02-16 11:52 ` Josef G. Bauer
  6 siblings, 0 replies; 9+ messages in thread
From: Josef G. Bauer @ 2009-02-16 11:52 UTC (permalink / raw
  To: help-gnu-emacs

Hi,

isn't 'call-process' what you are looking for?

Maybe search Google Groups for 'dired-do-shell-command-in-background'.

Greetings

Josef


>>>>> "dstein64" == dstein64  <DStein64@gmail.com> writes:

    dstein64> Are there any functions that can launch external
    dstein64> programs (not just command line programs, but also GUI
    dstein64> programs) from Emacs? I know that I can access a shell,
    dstein64> and call a program from there, but then emacs is not
    dstein64> operable until I close the program. Prepending the
    dstein64> command with `nohup' is useful, but for some reason it
    dstein64> does not work as expected with all programs, including
    dstein64> emacs. I would prefer another way of doing this - using
    dstein64> a specific built-in of emacs lisp if one exists.  Any
    dstein64> help would be greatly appreciated. Thanks.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-02-16 11:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-14 21:25 Executing External Programs from Emacs Xavier Maillard
  -- strict thread matches above, loose matches on Subject: below --
2009-02-14  6:48 dstein64
2009-02-14 10:00 ` Pascal J. Bourguignon
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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.