in reply to Use perl to drive emacs

Yes, this this possible. To use emacs in batch mode, try this from the command line
% emacs -batch -l lisp_file -f function_to_execute text_file_to_proce +ss
function_to _execute should be the top level driver function in lisp_file. To execute this from perl, use system() or qx//.

-Mark

Replies are listed 'Best First'.
Re^2: Use perl to drive emacs
by johnnywang (Priest) on Feb 21, 2005 at 05:09 UTC
    Thanks, that's great. Is it possible to do this dynamically? i.e., I don't have the lisp_file before hand, and would like to decide what to do at runtime. For example, is it possible to run emacs as a server, listening on a port, and I can send it commands over the socket, and see its result on the file on the screen display? Thanks again.
      To use emacs as a server, look into gnuserv. From the manpage:
      gnuclient allows the user to request a running emacs pro- cess to edit the named files or directories and/or evalu- ate lisp forms. Depending on your environment, it can be an X frame or a TTY frame. One typical use for this is with a dialup connection to a machine on which an emacs process is currently running. gnuserv is the server program that is set running by emacs to handle all incoming and outgoing requests. It is not usually invoked directly, but is started from emacs by loading the gnuserv package and evaluating the Lisp form (gnuserv-start).
      Using gnuserv and gnuclient also addresses Aristotle's concern about the heavy startup costs of invoking emacs for each separate command.

      -Mark

Re^2: Use perl to drive emacs
by Aristotle (Chancellor) on Feb 21, 2005 at 05:25 UTC

    Of course launching an Emacs instance (even if not fullblown) for every single editing command could get a wee bit slow…

    Makeshifts last the longest.