Mailing List Archive

Support open source code!


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

Re: Craig's "Rainikkusu" site



>>>>> "Stephen" == Stephen J Turnbull <turnbull@example.com> writes:


>>>>> "Shige" == Shige Abe <sabe@example.com> writes:
    Shige> We have DnD for our Wharf (Dock), I heard that you can drag
    Shige> filenames into the icon, and the application corresponding
    Shige> to the icon will fire up using data from the file.

    Stephen> Yes, I can see how you'd do that; you give the file
    Stephen> manager (or the window manager) the ability to interpret
    Stephen> calls like "exec mule %s", where %s gets the filename
    Stephen> substituted in.  However, I don't want to fire up a new
    Stephen> mule every time I edit a new file.

You don't have to fire up a new copy every time. You can use the
EDITOR environment variable to send a document to an resident copy of
emacs ( mule ):


Using Emacs as a Server
=======================

   Various programs such as `mail' can invoke your choice of editor to
edit a particular piece of text, such as a message that you are
sending.  By convention, these programs use the environment variable
`EDITOR' to specify which editor to run.  If you set `EDITOR' to
`emacs', they invoke Emacs--but in an inconvenient fashion, by starting
a new, separate Emacs process.  This is inconvenient because it takes
time and because the new Emacs process doesn't share the buffers in the
existing Emacs process.

   You can arrange to use your existing Emacs process as the editor for
programs like `mail' by using the Emacs client and Emacs server
programs.  Here is how.

   First, the preparation.  Within Emacs, call the function
`server-start'.  (Your `.emacs' file can do this automatically if you
add the expression `(server-start)' to it.)  Then, outside Emacs, set
the `EDITOR' environment variable to `emacsclient'.

   Then, whenever any program invokes your specified `EDITOR' program,
the effect is to send a message to your principal Emacs telling it to
visit a file.  (That's what the program `emacsclient' does.) Emacs
obeys silently; it does not immediately switch to the new file's
buffer.  When you want to do that, type `C-x #' (`server-edit').

   When you've finished editing that buffer, type `C-x #' again.  This
saves the file and sends a message back to the `emacsclient' program
telling it to exit.  The programs that use `EDITOR' wait for the
"editor" (actually, `emacsclient') to exit.  `C-x #' also checks to see
if any other files are pending for you to edit, and selects the next
one.

   You can switch to a server buffer manually if you wish; you don't
have to arrive at it with `C-x #'.  But `C-x #' is the only way to say
that you are "finished" with one.

   If you set the variable `server-window' to a window or a frame, `C-x
#' displays the server buffer in that window or in that frame.

   While `mail' or another application is waiting for `emacsclient' to
finish, `emacsclient' does not read terminal input.  So the terminal
that `mail' was using is effectively blocked for the duration.  In
order to edit with your principal Emacs, you need to be able to use it
without using that terminal.  There are two ways to do this:

   * Using a window system, run `mail' and the principal Emacs in two
     separate windows.  While `mail' is waiting for `emacsclient', the
     window where it was running is blocked, but you can use Emacs by
     switching windows.

   * Use Shell mode in Emacs to run the other program such as `mail';
     then, `emacsclient' blocks only the subshell under Emacs; you can
     still use Emacs to edit the file.

   Some programs write temporary files for you to edit.  After you edit
the temporary file, the program reads it back and deletes it.  If the
Emacs server is later asked to edit the same file name, it should assume
this has nothing to do with the previous occasion for that file name.
The server accomplishes this by killing the temporary file's buffer when
you finish with the file.  Use the variable `server-temp-file-regexp'
to specify which files are temporary in this sense; its value should be
a regular expression that matches file names that are temporary.


Regards,

	Andy
-----------------------------------------------------------------
a word from the sponsor will appear below
-----------------------------------------------------------------
The TLUG mailing list is proudly sponsored by TWICS - Japan's First
Public-Access Internet System.  Now offering 20,000 yen/year flat
rate Internet access with no time charges.  Full line of corporate
Internet and intranet products are available.   info@example.com
Tel: 03-3351-5977   Fax: 03-3353-6096


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links