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

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

Re: emacsclient: controlling from an application?


From: Stefan Monnier
Subject: Re: emacsclient: controlling from an application?
Date: Wed, 15 Oct 2003 18:24:25 GMT
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

> I would like to have a cron task signal emacsclient to save a certain
> buffer which I keep open throughout the workday, so that a perl script
> can do some processing on the contents at the end of the day.
> Signalling to save _all_ buffers would be okay too.

You can use `kill -USR1 <emacs process>' in your cron job
and something akin to (add-hook 'signal-USR1-hook 'save-some-buffers).
Same thing with USR2 of course.  I've never tried it, tho.

If you use Emacs-CVS you can also use
something like `emacsclient --eval "(save-some-buffers)"' and if your
Emacs is older, you can do the same with gnuserv/gnuclient.

> I know I can set the auto-save-visited-file-name variable so that
> auto-saves write to the original file;

I recommend you don't do that.  The auto-save file is written using
Emacs's internal encoding of characters, so unless you stick to pure ASCII,
you will get incorrect results.  And Emacs will be all confused, thinking
that some external process is modifying the file.

But you could use a timer to save this specific buffer every once in
a while.  Something like

   (run-with-idle-timer 60 'repeat
     (lambda ()
       (let ((buf (get-buffer "the bufferIwanttosave")))
         (if buf
             (with-current-buffer buf
               (save-buffer))))))


-- Stefan


reply via email to

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