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

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

Re: How to make a lisp function use an outside executable such as a comp


From: Aurélien Aptel
Subject: Re: How to make a lisp function use an outside executable such as a compiled C program?
Date: Wed, 24 Oct 2012 22:29:49 +0200

On Wed, Oct 24, 2012 at 8:02 PM,  <address@hidden> 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



reply via email to

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