all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Function needed to save a certain buffer every x seconds automatically
@ 2013-09-26 15:38 AW
  2013-09-26 17:01 ` Michael Heerdegen
  2013-09-26 17:14 ` Andreas Röhler
  0 siblings, 2 replies; 7+ messages in thread
From: AW @ 2013-09-26 15:38 UTC (permalink / raw)
  To: help-gnu-emacs

Hello!

To get a fast refreshing PDF of my LaTeX file, I use latexmk, which renders a 
PDF every time the LaTeX file changed on the hard disk.

I'd like to have a mechanism to save the LaTeX file every x seconds.

I found this solution:

(require 'auto-save-buffers)
(run-with-idle-timer 1 t 'auto-save-buffers)

If I put that into my .emacs, Emacs saves every buffer immediately after a 
change of the buffer. 

But it is cumbersome to switch that off in the .emacs file, if not needed, and 
on, if needed. Could someone write a function to switch this  line

(run-with-idle-timer 1 t 'auto-save-buffers)

on and off? 

Thank you!

Regards,

Alexander



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

* Re: Function needed to save a certain buffer every x seconds automatically
  2013-09-26 15:38 Function needed to save a certain buffer every x seconds automatically AW
@ 2013-09-26 17:01 ` Michael Heerdegen
  2013-09-26 17:14 ` Andreas Röhler
  1 sibling, 0 replies; 7+ messages in thread
From: Michael Heerdegen @ 2013-09-26 17:01 UTC (permalink / raw)
  To: help-gnu-emacs

Hi AW,

> Hello!
>
> To get a fast refreshing PDF of my LaTeX file, I use latexmk, which
> renders a PDF every time the LaTeX file changed on the hard disk.
>
> I'd like to have a mechanism to save the LaTeX file every x seconds.
>
> I found this solution:
>
> (require 'auto-save-buffers)
> (run-with-idle-timer 1 t 'auto-save-buffers)
>
> If I put that into my .emacs, Emacs saves every buffer immediately after a 
> change of the buffer. 
>
> But it is cumbersome to switch that off in the .emacs file, if not
> needed, and
> on, if needed. Could someone write a function to switch this  line
>
> (run-with-idle-timer 1 t 'auto-save-buffers)
>
> on and off? 

For the short I only found "auto-save-buffers-enhanced.el", which seems
to solve your problem - there is a function
`auto-save-buffers-enhanced-toggle-activity' which seems to do exactly
what you want.

Mmh, wait, the original package also has a toggle function,
`auto-save-buffers-toggle'.  Isn't that what you want?

In both cases, you must have started the timer before toggling does
anything.


Regards,

Michael.




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

* Re: Function needed to save a certain buffer every x seconds automatically
  2013-09-26 15:38 Function needed to save a certain buffer every x seconds automatically AW
  2013-09-26 17:01 ` Michael Heerdegen
@ 2013-09-26 17:14 ` Andreas Röhler
  2013-09-26 18:14   ` AW
  1 sibling, 1 reply; 7+ messages in thread
From: Andreas Röhler @ 2013-09-26 17:14 UTC (permalink / raw)
  To: help-gnu-emacs

Am 26.09.2013 17:38, schrieb AW:
> Hello!
>
> To get a fast refreshing PDF of my LaTeX file, I use latexmk, which renders a
> PDF every time the LaTeX file changed on the hard disk.
>
> I'd like to have a mechanism to save the LaTeX file every x seconds.
>

So you want to save a single buffer, not all, as auto-save-buffers does?

In this case here a little step forward

(run-with-idle-timer 1 nil (lambda () (set-buffer "MY-TEX")(write-file (expand-file-name "~/my.tex"))(message (format-time-string "%Y-%m-%d %a %H:%M" (current-time)))))

It runs just once, as timers not to switch off might turn nasty.
Gives some messages when saving.

Edit the my-tex parts.

Andreas



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

* Re: Function needed to save a certain buffer every x seconds automatically
@ 2013-09-26 17:30 AW
  0 siblings, 0 replies; 7+ messages in thread
From: AW @ 2013-09-26 17:30 UTC (permalink / raw)
  To: help-gnu-emacs


> Hi AW,
> 
... 
> Mmh, wait, the original package also has a toggle function,
> `auto-save-buffers-toggle'.  Isn't that what you want?
> 
> In both cases, you must have started the timer before toggling does
> anything.
> 
> 
> Regards,
> 
> Michael.

Dear Michael,

you are right, I did not occur to me to read the auto-save-buffers function.

Thank you!

Regards,

Alexander



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

* Re: Function needed to save a certain buffer every x seconds automatically
  2013-09-26 17:14 ` Andreas Röhler
@ 2013-09-26 18:14   ` AW
  2013-09-26 18:39     ` Andreas Röhler
  2013-10-02  3:18     ` Kevin Rodgers
  0 siblings, 2 replies; 7+ messages in thread
From: AW @ 2013-09-26 18:14 UTC (permalink / raw)
  To: help-gnu-emacs

Am Donnerstag, 26. September 2013, 19:14:06 schrieb Andreas Röhler:
> Am 26.09.2013 17:38, schrieb AW:
> > Hello!
> > 
> > To get a fast refreshing PDF of my LaTeX file, I use latexmk, which
> > renders a PDF every time the LaTeX file changed on the hard disk.
> > 
> > I'd like to have a mechanism to save the LaTeX file every x seconds.
> 
> So you want to save a single buffer, not all, as auto-save-buffers does?
> 
> In this case here a little step forward
> 
> (run-with-idle-timer 1 nil (lambda () (set-buffer "MY-TEX")(write-file
> (expand-file-name "~/my.tex"))(message (format-time-string "%Y-%m-%d %a
> %H:%M" (current-time)))))
> 
> It runs just once, as timers not to switch off might turn nasty.
> Gives some messages when saving.
> 
> Edit the my-tex parts.
> 
> Andreas

Would it be possible to take the current buffer instead of manually inserting 
the file name?

And besides that: thank you for your help!

Regards, 
Alexander



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

* Re: Function needed to save a certain buffer every x seconds automatically
  2013-09-26 18:14   ` AW
@ 2013-09-26 18:39     ` Andreas Röhler
  2013-10-02  3:18     ` Kevin Rodgers
  1 sibling, 0 replies; 7+ messages in thread
From: Andreas Röhler @ 2013-09-26 18:39 UTC (permalink / raw)
  To: AW; +Cc: help-gnu-emacs

Am 26.09.2013 20:14, schrieb AW:
> Am Donnerstag, 26. September 2013, 19:14:06 schrieb Andreas Röhler:
>> Am 26.09.2013 17:38, schrieb AW:
>>> Hello!
>>>
>>> To get a fast refreshing PDF of my LaTeX file, I use latexmk, which
>>> renders a PDF every time the LaTeX file changed on the hard disk.
>>>
>>> I'd like to have a mechanism to save the LaTeX file every x seconds.
>>
>> So you want to save a single buffer, not all, as auto-save-buffers does?
>>
>> In this case here a little step forward
>>
>> (run-with-idle-timer 1 nil (lambda () (set-buffer "MY-TEX")(write-file
>> (expand-file-name "~/my.tex"))(message (format-time-string "%Y-%m-%d %a
>> %H:%M" (current-time)))))
>>
>> It runs just once, as timers not to switch off might turn nasty.
>> Gives some messages when saving.
>>
>> Edit the my-tex parts.
>>
>> Andreas
>
> Would it be possible to take the current buffer instead of manually inserting
> the file name?
>

Yes. Didn't write it as the current-buffer changes quit often, than it writes whatever-what-buffer into the file-name specified, etc.
Would expect trouble from that.

BTW reflecting your task, what about an after-change, resp. after-save hook, producing the pdf after every save?

It's up to you.

Cheers,

> And besides that: thank you for your help!
>
> Regards,
> Alexander
>




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

* Re: Function needed to save a certain buffer every x seconds automatically
  2013-09-26 18:14   ` AW
  2013-09-26 18:39     ` Andreas Röhler
@ 2013-10-02  3:18     ` Kevin Rodgers
  1 sibling, 0 replies; 7+ messages in thread
From: Kevin Rodgers @ 2013-10-02  3:18 UTC (permalink / raw)
  To: help-gnu-emacs

On 9/26/13 12:14 PM, AW wrote:
> Am Donnerstag, 26. September 2013, 19:14:06 schrieb Andreas Röhler:
>> Am 26.09.2013 17:38, schrieb AW:
>>> Hello!
>>>
>>> To get a fast refreshing PDF of my LaTeX file, I use latexmk, which
>>> renders a PDF every time the LaTeX file changed on the hard disk.
>>>
>>> I'd like to have a mechanism to save the LaTeX file every x seconds.
>>
>> So you want to save a single buffer, not all, as auto-save-buffers does?
>>
>> In this case here a little step forward
>>
>> (run-with-idle-timer 1 nil (lambda () (set-buffer "MY-TEX")(write-file
>> (expand-file-name "~/my.tex"))(message (format-time-string "%Y-%m-%d %a
>> %H:%M" (current-time)))))
>>
>> It runs just once, as timers not to switch off might turn nasty.
>> Gives some messages when saving.
>>
>> Edit the my-tex parts.
>>
>> Andreas
>
> Would it be possible to take the current buffer instead of manually inserting
> the file name?

Instead: Map over all buffers, and save the LaTex buffers.

-- 
Kevin Rodgers
Denver, Colorado, USA




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

end of thread, other threads:[~2013-10-02  3:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-26 15:38 Function needed to save a certain buffer every x seconds automatically AW
2013-09-26 17:01 ` Michael Heerdegen
2013-09-26 17:14 ` Andreas Röhler
2013-09-26 18:14   ` AW
2013-09-26 18:39     ` Andreas Röhler
2013-10-02  3:18     ` Kevin Rodgers
  -- strict thread matches above, loose matches on Subject: below --
2013-09-26 17:30 AW

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.