all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* emacsclient: controlling from an application?
@ 2003-10-15 17:41 DrMemory
  2003-10-15 18:24 ` Stefan Monnier
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: DrMemory @ 2003-10-15 17:41 UTC (permalink / raw)


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.

I know I can set the auto-save-visited-file-name variable so that
auto-saves write to the original file; but unless I could do this on a
per-buffer basis I surely wouldn't want this as global behaviour.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: emacsclient: controlling from an application?
  2003-10-15 17:41 emacsclient: controlling from an application? DrMemory
@ 2003-10-15 18:24 ` Stefan Monnier
  2003-10-15 18:44   ` Stefan Monnier
  2003-10-15 21:58   ` DrMemory
  2003-10-15 18:25 ` Kevin Rodgers
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 16+ messages in thread
From: Stefan Monnier @ 2003-10-15 18:24 UTC (permalink / raw)


> 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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: emacsclient: controlling from an application?
  2003-10-15 17:41 emacsclient: controlling from an application? DrMemory
  2003-10-15 18:24 ` Stefan Monnier
@ 2003-10-15 18:25 ` Kevin Rodgers
  2003-10-15 20:36   ` DrMemory
  2003-10-15 20:46 ` DrMemory
  2003-12-01 21:40 ` Kai Grossjohann
  3 siblings, 1 reply; 16+ messages in thread
From: Kevin Rodgers @ 2003-10-15 18:25 UTC (permalink / raw)


DrMemory wrote:

> 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.
> 
> I know I can set the auto-save-visited-file-name variable so that
> auto-saves write to the original file; but unless I could do this on a
> per-buffer basis I surely wouldn't want this as global behaviour.

You can set any variable on a per-buffer basis:


(set (make-local-variable 'auto-save-visited-file-name) t)


Try putting that in the file itself, either as the first line

# -*- eval: (set ...) -*-

or at the end

### Local Variables:
### eval: (set ...)
### End:

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: emacsclient: controlling from an application?
  2003-10-15 18:24 ` Stefan Monnier
@ 2003-10-15 18:44   ` Stefan Monnier
  2003-10-15 19:03     ` Stefan Monnier
  2003-10-15 21:58   ` DrMemory
  1 sibling, 1 reply; 16+ messages in thread
From: Stefan Monnier @ 2003-10-15 18:44 UTC (permalink / raw)


>> 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.

Oops.  I don't know the idiot who write the above 4 lines ;-)
but I do know he's wrong.  He must have confused the variable
with another one.
But then again, maybe he has a point and a bug-report is in order.


        Stefan

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: emacsclient: controlling from an application?
  2003-10-15 18:44   ` Stefan Monnier
@ 2003-10-15 19:03     ` Stefan Monnier
  0 siblings, 0 replies; 16+ messages in thread
From: Stefan Monnier @ 2003-10-15 19:03 UTC (permalink / raw)


> Oops.  I don't know the idiot who write the above 4 lines ;-)
> but I do know he's wrong.

Look airhead, you can't even spell `wrote' correctly, so you'd
better shut up.

> He must have confused the variable with another one.

So what, I'm right anyway.

> But then again, maybe he has a point and a bug-report is in order.

Sure is,


        Stefan

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: emacsclient: controlling from an application?
  2003-10-15 18:25 ` Kevin Rodgers
@ 2003-10-15 20:36   ` DrMemory
  2003-10-15 21:04     ` Stefan Monnier
  0 siblings, 1 reply; 16+ messages in thread
From: DrMemory @ 2003-10-15 20:36 UTC (permalink / raw)


>
>You can set any variable on a per-buffer basis:
>
>
>(set (make-local-variable 'auto-save-visited-file-name) t)
>
>
>Try putting that in the file itself, either as the first line
>
># -*- eval: (set ...) -*-
>

Thanks. I tried it though, with results as follows, which baffle me:

It appears that the eval worked:

	auto-save-visited-file-name's value is 
	t
	Local in buffer 2do.txt; global value is 
	nil

However, the auto-save is still behaving as if the global value were in force:

  -rw-r--r--    1 swani    swani         819 Oct 15 14:18 #2do.txt#
  -rw-r--r--    1 swani    swani         819 Oct 15 14:15 2do.txt

I'll have a tilt at the other 2 ideas. Both emacs and the
knowledgeable folks in this forum never cease to amaze me. Thanks for
the suggestions!

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: emacsclient: controlling from an application?
  2003-10-15 17:41 emacsclient: controlling from an application? DrMemory
  2003-10-15 18:24 ` Stefan Monnier
  2003-10-15 18:25 ` Kevin Rodgers
@ 2003-10-15 20:46 ` DrMemory
  2003-10-15 20:57   ` DrMemory
  2003-12-01 21:40 ` Kai Grossjohann
  3 siblings, 1 reply; 16+ messages in thread
From: DrMemory @ 2003-10-15 20:46 UTC (permalink / raw)


Help! There was a post between Stefan's and Kevin's which dealt with
setting up an automated save-some-buffers call. Somehow, I clumsily
managed to delete it and don't know enough about slrn to retrieve it
(Yeah, I know I should be using the gnusreader in emacs.....).

Could someone be kind enough to send it to me? Thanks! 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: emacsclient: controlling from an application?
  2003-10-15 20:46 ` DrMemory
@ 2003-10-15 20:57   ` DrMemory
  0 siblings, 0 replies; 16+ messages in thread
From: DrMemory @ 2003-10-15 20:57 UTC (permalink / raw)


On Wed, 15 Oct 2003 20:46:20 GMT, DrMemory <drmemory@starband.net> wrote:
>Help! There was a post between Stefan's and Kevin's which dealt with
>setting up an automated save-some-buffers call. Somehow, I clumsily
>managed to delete it and don't know enough about slrn to retrieve it
>(Yeah, I know I should be using the gnusreader in emacs.....).

I don't know the idiot who wrote _those_ 4 lines! Of course the timer
idea was a 2nd idea of Stefan's. I'm off to try the USR1 idea, which
is quite intriguing.

Thanks again!

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: emacsclient: controlling from an application?
  2003-10-15 20:36   ` DrMemory
@ 2003-10-15 21:04     ` Stefan Monnier
  2003-10-17 22:45       ` DrMemory
  0 siblings, 1 reply; 16+ messages in thread
From: Stefan Monnier @ 2003-10-15 21:04 UTC (permalink / raw)


> Thanks. I tried it though, with results as follows, which baffle me:

> It appears that the eval worked:

> 	auto-save-visited-file-name's value is 
> 	t
> 	Local in buffer 2do.txt; global value is 
> 	nil

> However, the auto-save is still behaving as if the global value were in force:

>   -rw-r--r--    1 swani    swani         819 Oct 15 14:18 #2do.txt#
>   -rw-r--r--    1 swani    swani         819 Oct 15 14:15 2do.txt

> I'll have a tilt at the other 2 ideas. Both emacs and the
> knowledgeable folks in this forum never cease to amaze me. Thanks for
> the suggestions!

The variable is consulted when visiting a file to setup some other
auto-save-related variables.  What is probably occuring is that the
variable is consulted before it is changed by the "eval: (set ...)"
cookie.


        Stefan

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: emacsclient: controlling from an application?
  2003-10-15 18:24 ` Stefan Monnier
  2003-10-15 18:44   ` Stefan Monnier
@ 2003-10-15 21:58   ` DrMemory
  2003-10-16 15:17     ` Kevin Rodgers
  1 sibling, 1 reply; 16+ messages in thread
From: DrMemory @ 2003-10-15 21:58 UTC (permalink / raw)


On Wed, 15 Oct 2003 18:24:25 GMT, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:

>
>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.
>

I can't get this to work. I'm a babe-in-the-woods when it comes to
elisp, but doesn't the save-some-buffers need a non-nil argument to
make it save all? Otherwise, it will try to prompt the (non-existent)
user for each buffer.

Would it be
   (add-hook 'signal-USR1-hook '(save-some-buffers t)) ?

That didn't seem to work either. I also tried just putting a function
which doesn't take any arguments (delete-other-windows). No effect
there either.

Sorry to be such a dunce. I'll maybe try your timer idea, but I really
ought to be getting at some of those lines in '2do.txt', the file in
question!

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: emacsclient: controlling from an application?
  2003-10-15 21:58   ` DrMemory
@ 2003-10-16 15:17     ` Kevin Rodgers
  2003-10-16 16:48       ` DrMemory
  0 siblings, 1 reply; 16+ messages in thread
From: Kevin Rodgers @ 2003-10-16 15:17 UTC (permalink / raw)


DrMemory wrote:

> On Wed, 15 Oct 2003 18:24:25 GMT, Stefan Monnier
> <monnier@iro.umontreal.ca> wrote:
>>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.
> 
> I can't get this to work. I'm a babe-in-the-woods when it comes to
> elisp, but doesn't the save-some-buffers need a non-nil argument to
> make it save all? Otherwise, it will try to prompt the (non-existent)
> user for each buffer.


Yes.


> Would it be
>    (add-hook 'signal-USR1-hook '(save-some-buffers t)) ?


(add-hook 'signal-USR1-hook (lambda () (save-some-buffers t)))

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: emacsclient: controlling from an application?
  2003-10-16 15:17     ` Kevin Rodgers
@ 2003-10-16 16:48       ` DrMemory
  2003-10-16 19:00         ` Stefan Monnier
  0 siblings, 1 reply; 16+ messages in thread
From: DrMemory @ 2003-10-16 16:48 UTC (permalink / raw)


On Thu, 16 Oct 2003 09:17:33 -0600, Kevin Rodgers <ihs_4664@yahoo.com>
wrote:

>
>
>(add-hook 'signal-USR1-hook (lambda () (save-some-buffers t)))
>

Okay, makes sense. But it doesn't seem to work either! This is
frustrating.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: emacsclient: controlling from an application?
  2003-10-16 16:48       ` DrMemory
@ 2003-10-16 19:00         ` Stefan Monnier
  0 siblings, 0 replies; 16+ messages in thread
From: Stefan Monnier @ 2003-10-16 19:00 UTC (permalink / raw)


>> (add-hook 'signal-USR1-hook (lambda () (save-some-buffers t)))

> Okay, makes sense. But it doesn't seem to work either! This is
> frustrating.

You might want to file a bug report with M-x report-emacs-bug.


        Stefan

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: emacsclient: controlling from an application?
  2003-10-15 21:04     ` Stefan Monnier
@ 2003-10-17 22:45       ` DrMemory
  2003-10-20 16:58         ` Kevin Rodgers
  0 siblings, 1 reply; 16+ messages in thread
From: DrMemory @ 2003-10-17 22:45 UTC (permalink / raw)


It was suggested that I set the auto-save-visited-file-name var:

>>You can set any variable on a per-buffer basis:
>>
>>(set (make-local-variable 'auto-save-visited-file-name) t)
>>
>>Try putting that in the file itself, either as the first line
>>
>># -*- eval: (set ...) -*-
>>

Which didn't work:

>> It appears that the eval worked:
>> However, the auto-save is still behaving as if the global value were in force:

And you suggested:

>
>The variable is consulted when visiting a file to setup some other
>auto-save-related variables.  What is probably occuring is that the
>variable is consulted before it is changed by the "eval: (set ...)"
>cookie.
>

Nosing around, I find a variable called buffer-auto-save-file-name.
Setting that in an eval statement does work, if anyone is
interested....

-*- eval: (setq buffer-auto-save-file-name "Whatever") -*-

Also, the run-with-idle-timer idea worked just fine. Thanks! Now I
just wish I could make the USR1 signal work. I'm running version
20.6.1 here at work, so I will try with my newer version at home
before submitting any bug reports...

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: emacsclient: controlling from an application?
  2003-10-17 22:45       ` DrMemory
@ 2003-10-20 16:58         ` Kevin Rodgers
  0 siblings, 0 replies; 16+ messages in thread
From: Kevin Rodgers @ 2003-10-20 16:58 UTC (permalink / raw)


DrMemory wrote:

> It was suggested that I set the auto-save-visited-file-name var:
> 
>>>You can set any variable on a per-buffer basis:
>>>
>>>(set (make-local-variable 'auto-save-visited-file-name) t)
>>>
>>>Try putting that in the file itself, either as the first line
>>>
>>># -*- eval: (set ...) -*-
> 
> Which didn't work:
> 
>>>It appears that the eval worked:
>>>However, the auto-save is still behaving as if the global value were in force:
> 
> And you suggested:
> 
>>The variable is consulted when visiting a file to setup some other
>>auto-save-related variables.  What is probably occuring is that the
>>variable is consulted before it is changed by the "eval: (set ...)"
>>cookie.
> 
> Nosing around, I find a variable called buffer-auto-save-file-name.
> Setting that in an eval statement does work, if anyone is
> interested....
> 
> -*- eval: (setq buffer-auto-save-file-name "Whatever") -*-


To get the effect of setting auto-save-visited-file-name, change "Whatever"
to buffer-file-name.


-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: emacsclient: controlling from an application?
  2003-10-15 17:41 emacsclient: controlling from an application? DrMemory
                   ` (2 preceding siblings ...)
  2003-10-15 20:46 ` DrMemory
@ 2003-12-01 21:40 ` Kai Grossjohann
  3 siblings, 0 replies; 16+ messages in thread
From: Kai Grossjohann @ 2003-12-01 21:40 UTC (permalink / raw)


drmemory@starband.net (DrMemory) writes:

> 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.

Does the end of the day mean midnight?  In that case, you could cause
the processing from Emacs, using midnight.el.

Or does it mean when you hit C-x C-c?  In that case,
kill-emacs-query-functions or kill-emacs-hook might be for you.

Isn't it nasty of Emacs that it also wants to take over the job of
cron?

Kai

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2003-12-01 21:40 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-15 17:41 emacsclient: controlling from an application? DrMemory
2003-10-15 18:24 ` Stefan Monnier
2003-10-15 18:44   ` Stefan Monnier
2003-10-15 19:03     ` Stefan Monnier
2003-10-15 21:58   ` DrMemory
2003-10-16 15:17     ` Kevin Rodgers
2003-10-16 16:48       ` DrMemory
2003-10-16 19:00         ` Stefan Monnier
2003-10-15 18:25 ` Kevin Rodgers
2003-10-15 20:36   ` DrMemory
2003-10-15 21:04     ` Stefan Monnier
2003-10-17 22:45       ` DrMemory
2003-10-20 16:58         ` Kevin Rodgers
2003-10-15 20:46 ` DrMemory
2003-10-15 20:57   ` DrMemory
2003-12-01 21:40 ` Kai Grossjohann

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.