GNU bug report logs - #44639
[PATCH 2/2] autorevert: map each watch descriptor to a single buffer

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Spencer Baugh <sbaugh@HIDDEN>; Keywords: patch; dated Sat, 14 Nov 2020 16:56:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 14 Nov 2020 16:55:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 14 11:55:41 2020
Received: from localhost ([127.0.0.1]:51842 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kdypx-0001oq-7s
	for submit <at> debbugs.gnu.org; Sat, 14 Nov 2020 11:55:41 -0500
Received: from lists.gnu.org ([209.51.188.17]:52392)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1kdypl-0001oW-CY
 for submit <at> debbugs.gnu.org; Sat, 14 Nov 2020 11:55:39 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:48816)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <sbaugh@HIDDEN>) id 1kdypk-0003nt-6j
 for bug-gnu-emacs@HIDDEN; Sat, 14 Nov 2020 11:55:28 -0500
Received: from venus.catern.com ([68.183.49.163]:44372)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <sbaugh@HIDDEN>) id 1kdyph-0001Zu-BD
 for bug-gnu-emacs@HIDDEN; Sat, 14 Nov 2020 11:55:27 -0500
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1605372918; bh=uc60j/s7nzm2q8+5zf1SEzHxnCsp1ja+IArHdRoMNCk=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=Lz/tkhA5R/3WmSFB1YGtH13O/Da1sy5jW6pYEzsbqQn6OQP1jCKgSr04hHn3C8Hn2
 KRQBq/dojpEJIDy9tiLhxORwG4CsBncPvqvlDwENais8cIit+hzfV9+xrwet8VN4xo
 7hGsoKILAprC/HlMFemcSoF/Nb7nG92mehKfjsMw=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 7A00E2DD4A0;
 Sat, 14 Nov 2020 16:55:18 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH 2/2] autorevert: map each watch descriptor to a single buffer
Date: Sat, 14 Nov 2020 11:54:59 -0500
Message-Id: <20201114165459.9518-2-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.28.0
In-Reply-To: <20201114165459.9518-1-sbaugh@HIDDEN>
References: <20201114165459.9518-1-sbaugh@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=68.183.49.163; envelope-from=sbaugh@HIDDEN;
 helo=venus.catern.com
X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/14 11:55:18
X-ACL-Warn: Detected OS   = Linux 3.11 and newer
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: submit
Cc: Spencer Baugh <sbaugh@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Now that we don't share watch descriptors between buffers, we don't
need to store a list of buffers for each watch descriptor - there
would only be a single buffer in each list. This should have no
functional change.
---
 lisp/autorevert.el | 30 +++++++++++-------------------
 1 file changed, 11 insertions(+), 19 deletions(-)

diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index d5bb75c2f1..ad39884ab0 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -355,10 +355,10 @@ the list of old buffers.")
 (add-hook 'after-set-visited-file-name-hook
           #'auto-revert-set-visited-file-name)
 
-(defvar auto-revert--buffers-by-watch-descriptor
+(defvar auto-revert--buffer-by-watch-descriptor
   (make-hash-table :test 'equal)
-  "A hash table mapping notification descriptors to lists of buffers.
-The buffers use that descriptor for auto-revert notifications.
+  "A hash table mapping notification descriptors to buffers.
+The buffer uses that descriptor for auto-revert notifications.
 The key is equal to `auto-revert-notify-watch-descriptor' in each
 buffer.")
 
@@ -631,12 +631,9 @@ will use an up-to-date value of `auto-revert-interval'."
 (defun auto-revert-notify-rm-watch ()
   "Disable file notification for current buffer's associated file."
   (let ((desc auto-revert-notify-watch-descriptor)
-        (table auto-revert--buffers-by-watch-descriptor))
+        (table auto-revert--buffer-by-watch-descriptor))
     (when desc
-      (let ((buffers (delq (current-buffer) (gethash desc table))))
-        (if buffers
-            (puthash desc buffers table)
-          (remhash desc table)))
+      (remhash desc table)
       (ignore-errors
 	(file-notify-rm-watch desc))
       (remove-hook 'kill-buffer-hook #'auto-revert-notify-rm-watch t)))
@@ -663,10 +660,8 @@ will use an up-to-date value of `auto-revert-interval'."
         (setq auto-revert-notify-modified-p t)
         (puthash
          auto-revert-notify-watch-descriptor
-         (cons (current-buffer)
-	       (gethash auto-revert-notify-watch-descriptor
-		        auto-revert--buffers-by-watch-descriptor))
-         auto-revert--buffers-by-watch-descriptor)
+         (current-buffer)
+         auto-revert--buffer-by-watch-descriptor)
         (add-hook 'kill-buffer-hook #'auto-revert-notify-rm-watch nil t))))
 
 ;; If we have file notifications, we want to update the auto-revert buffers
@@ -696,8 +691,8 @@ system.")
 	   (action (nth 1 event))
 	   (file (nth 2 event))
 	   (file1 (nth 3 event)) ;; Target of `renamed'.
-	   (buffers (gethash descriptor
-			     auto-revert--buffers-by-watch-descriptor)))
+	   (buffer (gethash descriptor
+			    auto-revert--buffer-by-watch-descriptor)))
       ;; Check, that event is meant for us.
       (cl-assert descriptor)
       ;; Since we watch a directory, a file name must be returned.
@@ -708,7 +703,6 @@ system.")
 
       (if (eq action 'stopped)
           ;; File notification has stopped.  Continue with polling.
-          (cl-dolist (buffer buffers)
             (with-current-buffer buffer
               (when (or
                      ;; A buffer associated with a file.
@@ -721,10 +715,8 @@ system.")
                 (auto-revert-notify-rm-watch)
                 ;; Restart the timer if it wasn't running.
                 (unless auto-revert-timer
-                  (auto-revert-set-timer)))))
+                  (auto-revert-set-timer))))
 
-        ;; Loop over all buffers, in order to find the intended one.
-        (cl-dolist (buffer buffers)
           (when (buffer-live-p buffer)
             (with-current-buffer buffer
               (when (or
@@ -752,7 +744,7 @@ system.")
                   (setq auto-revert--lockout-timer
                         (run-with-timer
                          auto-revert--lockout-interval nil
-                         #'auto-revert--end-lockout buffer)))))))))))
+                         #'auto-revert--end-lockout buffer))))))))))
 
 (defun auto-revert--end-lockout (buffer)
   "End the lockout period after a notification.
-- 
2.28.0





Acknowledgement sent to Spencer Baugh <sbaugh@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#44639; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 14 Nov 2020 17:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.