From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#44639: [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@catern.com> References: <20201114165459.9518-1-sbaugh@catern.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15781"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Spencer Baugh To: 44639@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 14 17:56:26 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kdyqf-0003zi-6J for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 14 Nov 2020 17:56:25 +0100 Original-Received: from localhost ([::1]:35814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kdyqe-000436-89 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 14 Nov 2020 11:56:24 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kdyqK-00042N-L4 for bug-gnu-emacs@gnu.org; Sat, 14 Nov 2020 11:56:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40298) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kdyqJ-0001tD-6H for bug-gnu-emacs@gnu.org; Sat, 14 Nov 2020 11:56:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kdyqJ-0001ph-5h for bug-gnu-emacs@gnu.org; Sat, 14 Nov 2020 11:56:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 14 Nov 2020 16:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 44639 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16053729417001 (code B ref -1); Sat, 14 Nov 2020 16:56:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 14 Nov 2020 16:55:41 +0000 Original-Received: from localhost ([127.0.0.1]:51842 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdypx-0001oq-7s for submit@debbugs.gnu.org; Sat, 14 Nov 2020 11:55:41 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:52392) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdypl-0001oW-CY for submit@debbugs.gnu.org; Sat, 14 Nov 2020 11:55:39 -0500 Original-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 ) id 1kdypk-0003nt-6j for bug-gnu-emacs@gnu.org; Sat, 14 Nov 2020 11:55:28 -0500 Original-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 ) id 1kdyph-0001Zu-BD for bug-gnu-emacs@gnu.org; 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@catern.com; receiver= 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= Original-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) X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201114165459.9518-1-sbaugh@catern.com> Received-SPF: pass client-ip=68.183.49.163; envelope-from=sbaugh@catern.com; 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:193308 Archived-At: 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