From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: why 4 inotfy events when saving a file? Date: Mon, 11 Mar 2013 00:09:44 +0200 Message-ID: <83ehfmx5xz.fsf@gnu.org> References: <20130310214442.GA8538@boo.workgroup> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1362953408 6305 80.91.229.3 (10 Mar 2013 22:10:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 10 Mar 2013 22:10:08 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Mar 10 23:10:32 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UEoRp-0001OU-6d for geh-help-gnu-emacs@m.gmane.org; Sun, 10 Mar 2013 23:10:29 +0100 Original-Received: from localhost ([::1]:55830 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UEoRT-00055r-0T for geh-help-gnu-emacs@m.gmane.org; Sun, 10 Mar 2013 18:10:07 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:49054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UEoRI-00055j-Dk for help-gnu-emacs@gnu.org; Sun, 10 Mar 2013 18:09:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UEoRH-0005UG-HS for help-gnu-emacs@gnu.org; Sun, 10 Mar 2013 18:09:56 -0400 Original-Received: from mtaout23.012.net.il ([80.179.55.175]:34771) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UEoRH-0005U8-9L for help-gnu-emacs@gnu.org; Sun, 10 Mar 2013 18:09:55 -0400 Original-Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0MJG00900T9HY700@a-mtaout23.012.net.il> for help-gnu-emacs@gnu.org; Mon, 11 Mar 2013 00:09:53 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MJG009I8TKHXL50@a-mtaout23.012.net.il> for help-gnu-emacs@gnu.org; Mon, 11 Mar 2013 00:09:53 +0200 (IST) In-reply-to: <20130310214442.GA8538@boo.workgroup> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.175 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:89464 Archived-At: > Date: Sun, 10 Mar 2013 22:44:42 +0100 > From: Gregor Zattler > > 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.