unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* why 4 inotfy events when saving a file?
@ 2013-03-10 21:44 Gregor Zattler
  2013-03-10 22:09 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Gregor Zattler @ 2013-03-10 21:44 UTC (permalink / raw)
  To: help-gnu-emacs

Dear Emacs users and developers,

saving a file from Emacs gives 4 inotify events:

how to reproduce:

   on first terminal do:
      emacs-snapshot -nw -Q /tmp/inotify.test
      modify file
   
   
   on second terminal do
      inotifywait -m  -q --format '%e %w%f' /tmp/inotify.test
   
   
   on first terminal do 
      ^x^s (safe buffer)
   
   result on second terminal is:
      MODIFY /tmp/inotify.test
      OPEN /tmp/inotify.test
      MODIFY /tmp/inotify.test
      CLOSE_WRITE,CLOSE /tmp/inotify.test


why are there so many events?



This is with 
GNU Emacs 24.3.50.1 (i486-pc-linux-gnu, GTK+ Version 3.4.2) of
2013-03-04 on dex, modified by Debian



Thanx for your attention, Gregor
-- 
 -... --- .-. . -.. ..--.. ...-.-



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

* Re: why 4 inotfy events when saving a file?
  2013-03-10 21:44 why 4 inotfy events when saving a file? Gregor Zattler
@ 2013-03-10 22:09 ` Eli Zaretskii
  2013-03-11 23:14   ` Gregor Zattler
       [not found]   ` <mailman.21890.1363043748.855.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 6+ messages in thread
From: Eli Zaretskii @ 2013-03-10 22:09 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Sun, 10 Mar 2013 22:44:42 +0100
> From: Gregor Zattler <telegraph@gmx.net>
> 
> saving a file from Emacs gives 4 inotify events:
> 
> how to reproduce:
> 
>    on first terminal do:
>       emacs-snapshot -nw -Q /tmp/inotify.test
>       modify file
>    
>    
>    on second terminal do
>       inotifywait -m  -q --format '%e %w%f' /tmp/inotify.test
>    
>    
>    on first terminal do 
>       ^x^s (safe buffer)
>    
>    result on second terminal is:
>       MODIFY /tmp/inotify.test
>       OPEN /tmp/inotify.test
>       MODIFY /tmp/inotify.test
>       CLOSE_WRITE,CLOSE /tmp/inotify.test
> 
> 
> why are there so many events?

Because that's what Emacs does when it saves the file, first to the
old version, then to the new.  Take a look at the implementation of
write-region, which is the primitive used by save-buffer to write the
buffer to its file, you will see all those operations there.



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

* Re: why 4 inotfy events when saving a file?
       [not found] <mailman.21821.1362951956.855.help-gnu-emacs@gnu.org>
@ 2013-03-11  0:59 ` Barry Margolin
  0 siblings, 0 replies; 6+ messages in thread
From: Barry Margolin @ 2013-03-11  0:59 UTC (permalink / raw)
  To: help-gnu-emacs

In article <mailman.21821.1362951956.855.help-gnu-emacs@gnu.org>,
 Gregor Zattler <telegraph@gmx.net> wrote:

> Dear Emacs users and developers,
> 
> saving a file from Emacs gives 4 inotify events:
> 
> how to reproduce:
> 
>    on first terminal do:
>       emacs-snapshot -nw -Q /tmp/inotify.test
>       modify file
>    
>    
>    on second terminal do
>       inotifywait -m  -q --format '%e %w%f' /tmp/inotify.test
>    
>    
>    on first terminal do 
>       ^x^s (safe buffer)
>    
>    result on second terminal is:
>       MODIFY /tmp/inotify.test
>       OPEN /tmp/inotify.test
>       MODIFY /tmp/inotify.test
>       CLOSE_WRITE,CLOSE /tmp/inotify.test
> 
> 
> why are there so many events?

To save the backup file. First it renames inotify.test to 
inotify.test.~<version>~, then it writes the buffer to a new 
inotify.test file.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


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

* Re: why 4 inotfy events when saving a file?
  2013-03-10 22:09 ` Eli Zaretskii
@ 2013-03-11 23:14   ` Gregor Zattler
  2013-03-12  3:07     ` William Gardella
       [not found]   ` <mailman.21890.1363043748.855.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 6+ messages in thread
From: Gregor Zattler @ 2013-03-11 23:14 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Eli, Emacs users and developers,
* Eli Zaretskii <eliz@gnu.org> [11. Mar. 2013]:
>> Date: Sun, 10 Mar 2013 22:44:42 +0100
>> From: Gregor Zattler <telegraph@gmx.net>
>> 
>> saving a file from Emacs gives 4 inotify events:
[...]
>> why are there so many events?
> 
> Because that's what Emacs does when it saves the file, first to the
> old version, then to the new.  Take a look at the implementation of
> write-region, which is the primitive used by save-buffer to write the
> buffer to its file, you will see all those operations there.

Thanks (also to Barry Margolin) for the explanation.  I now
search for a after-file-save-hook.  But I didn't find it.  Is
there some such thing?


Ciao, Gregor
-- 
 -... --- .-. . -.. ..--.. ...-.-



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

* Re: why 4 inotfy events when saving a file?
       [not found]   ` <mailman.21890.1363043748.855.help-gnu-emacs@gnu.org>
@ 2013-03-12  2:21     ` B. T. Raven
  0 siblings, 0 replies; 6+ messages in thread
From: B. T. Raven @ 2013-03-12  2:21 UTC (permalink / raw)
  To: help-gnu-emacs



> Hi Eli, Emacs users and developers,
> * Eli Zaretskii <eliz@gnu.org> [11. Mar. 2013]:
>>> Date: Sun, 10 Mar 2013 22:44:42 +0100
>>> From: Gregor Zattler <telegraph@gmx.net>
>>>
>>> saving a file from Emacs gives 4 inotify events:
> [...]
>>> why are there so many events?
>>
>> Because that's what Emacs does when it saves the file, first to the
>> old version, then to the new.  Take a look at the implementation of
>> write-region, which is the primitive used by save-buffer to write the
>> buffer to its file, you will see all those operations there.
> 
> Thanks (also to Barry Margolin) for the explanation.  I now
> search for a after-file-save-hook.  But I didn't find it.  Is
> there some such thing?

C-h v after TAB shows:

after-save-hook is a variable defined in `files.el'.
Its value is nil

  This variable is potentially risky when used as a file local variable.

Documentation:
Normal hook that is run after a buffer is saved to its file.

You can customize this variable.

Ed

> 
> 
> Ciao, Gregor
> 



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

* Re: why 4 inotfy events when saving a file?
  2013-03-11 23:14   ` Gregor Zattler
@ 2013-03-12  3:07     ` William Gardella
  0 siblings, 0 replies; 6+ messages in thread
From: William Gardella @ 2013-03-12  3:07 UTC (permalink / raw)
  To: help-gnu-emacs-mXXj517/zsQ

Hi Gregor,

Gregor Zattler <telegraph-hi6Y0CQ0nG0@public.gmane.org> writes:

> Thanks (also to Barry Margolin) for the explanation.  I now
> search for a after-file-save-hook.  But I didn't find it.  Is
> there some such thing?
>
>
> Ciao, Gregor

There is, in, fact, an `after-save-hook'.  :) Please see also (info
"(elisp) Saving Buffers").

-- 
Regards,
WGG




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

end of thread, other threads:[~2013-03-12  3:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-10 21:44 why 4 inotfy events when saving a file? Gregor Zattler
2013-03-10 22:09 ` Eli Zaretskii
2013-03-11 23:14   ` Gregor Zattler
2013-03-12  3:07     ` William Gardella
     [not found]   ` <mailman.21890.1363043748.855.help-gnu-emacs@gnu.org>
2013-03-12  2:21     ` B. T. Raven
     [not found] <mailman.21821.1362951956.855.help-gnu-emacs@gnu.org>
2013-03-11  0:59 ` Barry Margolin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).