Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to make a lisp function use an outside executable such as a compiled C program?

7 views
Skip to first unread message

gnui...@hotmail.com

unread,
Oct 24, 2012, 2:02:55 PM10/24/12
to

I asked this question in a 2002 post in the thread describing it and
previous response.

https://groups.google.com/group/gnu.emacs.help/browse_thread/thread/a556b6d959c4a84d/

Has there been any improvements in the last 10 years?

Gnuist

Drew Adams

unread,
Oct 24, 2012, 2:13:49 PM10/24/12
to gnui...@hotmail.com, help-gn...@gnu.org
Barry Margolin already gave you the answer, at the URL you cite.
Did you try it in the last 10 years? ;-)

For more info, see the Elisp manual, nodes `Synchronous Processes' and
`Asynchronous Processes'.


Raymond Wiker

unread,
Oct 24, 2012, 4:02:30 PM10/24/12
to
Apparently not... your question is still as ill-specified as it was 10
years ago.

Aurélien Aptel

unread,
Oct 24, 2012, 4:29:49 PM10/24/12
to gnui...@hotmail.com, help-gn...@gnu.org
On Wed, Oct 24, 2012 at 8:02 PM, <gnui...@hotmail.com> wrote:
>
> I asked this question in a 2002 post in the thread describing it and
> previous response.

You have to write some emacs lisp.
As someone already said, use call-process.

This calls synchronously ls with the -l and -a options:

(call-process "ls" nil nil nil "-l" "-a")

If you want the return value to be the program output you can use
shell-command-to-string.

You can wrap this line in a function and put it in your .emacs like this:

(defun my-function ()
(interactive)
(call-process "ls" nil nil nil "-l" "-a"))

You can then bind it to a key like this (still in .emacs):

(global-set-key (kbd "<f9>") 'my-function)

>
> https://groups.google.com/group/gnu.emacs.help/browse_thread/thread/a556b6d959c4a84d/
>
> Has there been any improvements in the last 10 years?

It's really not difficult, you should read what people say in this thread.
If you have a previous experience in programming and want a short
introduction to emacs lisp I recommend you Xah Lee's tutorials :

http://ergoemacs.org/emacs/elisp.html

gnui...@hotmail.com

unread,
Oct 24, 2012, 10:53:06 PM10/24/12
to
On Oct 24, 1:29 pm, Aurélien Aptel <aurelien.aptel+em...@gmail.com>
wrote:
> On Wed, Oct 24, 2012 at 8:02 PM,  <gnuist...@hotmail.com> wrote:
>
> > I asked this question in a 2002 post in the thread describing it and
> > previous response.
>
> You have to write some emacs lisp.
> As someone already said, use call-process.
>
> This calls synchronously ls with the -l and -a options:
>
> (call-process "ls" nil nil nil "-l" "-a")
>
> If you want the return value to be the program output you can use
> shell-command-to-string.
>
> You can wrap this line in a function and put it in your .emacs like this:
>
> (defun my-function ()
>   (interactive)
>   (call-process "ls" nil nil nil "-l" "-a"))
>
> You can then bind it to a key like this (still in .emacs):
>
> (global-set-key (kbd "<f9>")   'my-function)
>
>
>
> >https://groups.google.com/group/gnu.emacs.help/browse_thread/thread/a...
>
> > Has there been any improvements in the last 10 years?
>
> It's really not difficult, you should read what people say in this thread.
> If you have a previous experience in programming and want a short
> introduction to emacs lisp I recommend you Xah Lee's tutorials :
>
> http://ergoemacs.org/emacs/elisp.html

Thanks for the great reply. Your illustrative example was the thing in
need.

0 new messages