From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Boruch Baum Newsgroups: gmane.emacs.bugs Subject: bug#43412: [FEATURE] autorevert-only-if-visible [PATCH] Date: Tue, 15 Sep 2020 00:07:28 -0400 Message-ID: <20200915040728.77ufv7g6bekvrzqa@E15-2016.optimum.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="c3dgevwv4k6pvmht" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14276"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: NeoMutt/20180716 To: 43412@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 15 06:08:28 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 1kI2GZ-0003dx-SC for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 15 Sep 2020 06:08:27 +0200 Original-Received: from localhost ([::1]:59668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI2GY-00044d-OQ for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 15 Sep 2020 00:08:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI2GA-00044W-CW for bug-gnu-emacs@gnu.org; Tue, 15 Sep 2020 00:08:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45297) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kI2GA-0005FX-43 for bug-gnu-emacs@gnu.org; Tue, 15 Sep 2020 00:08:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kI2G9-0003e2-W0 for bug-gnu-emacs@gnu.org; Tue, 15 Sep 2020 00:08:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Boruch Baum Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 15 Sep 2020 04:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 43412 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: Emacs Bug Reporting Original-Received: via spool by submit@debbugs.gnu.org id=B.160014286013979 (code B ref -1); Tue, 15 Sep 2020 04:08:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Sep 2020 04:07:40 +0000 Original-Received: from localhost ([127.0.0.1]:56843 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kI2Fo-0003dP-FB for submit@debbugs.gnu.org; Tue, 15 Sep 2020 00:07:40 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:54332) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kI2Fl-0003dG-MN for submit@debbugs.gnu.org; Tue, 15 Sep 2020 00:07:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI2Fl-000448-Ff for bug-gnu-emacs@gnu.org; Tue, 15 Sep 2020 00:07:37 -0400 Original-Received: from mout.gmx.net ([212.227.17.22]:47345) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI2Fj-0005Dv-8F for bug-gnu-emacs@gnu.org; Tue, 15 Sep 2020 00:07:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1600142852; bh=h7C1u/UJqrsh/YJgL2Ekk6h0NvqMGwscE6E0+0pNm/0=; h=X-UI-Sender-Class:Date:From:To:Subject; b=A3/QNmjvsLdqQYkq3eZD6dkOlgf8dSf2UlAUhj0/xBP1f/6CGL6yMoVC/usLHWG/L FuEfxkaNKT6q8ggw9n3H96XPX5imcJNOCO2uB4n9iNBZ7W9GGsXP4eyBwOfHwLi75T g6i5VM7jHXcxEDo2zqnSGj2zvVUdiCUrLmtwba2U= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from E15-2016.optimum.net ([72.89.170.172]) by mail.gmx.com (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MeCtj-1ktI4y2DI7-00bLKM for ; Tue, 15 Sep 2020 06:07:31 +0200 Content-Disposition: inline X-Provags-ID: V03:K1:RBLT1cKDuXMPg4V9lJ8da97wxws9aKjxLbe/PD0Gdh4C5GFvp1X gxpZp1SUCTpZqs1/pwhz5k1pSWPiX33T1sBUOB47EhIedA45o837LUnyAJbizGq90HZmAGm VlSa/2x2+Yawl4wu1Omm9T320DbFk5WfqUYyr5TXKIFT7SUionlhrrKM6miXfyvfHXHh7cO 3+nbCjqUbfabRr6gv2SPQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:/aeqbMjveZ8=:XdqreI/yFfZqghlfED0cJd TCAHY3Zn3fnwjmkFiWlZ7CBHNzxJq/89iJldXyr0QNgaOlQtcINT0Ju1DPEkemq7Msvd5x9rH XrCsDyV7ovY+cAjEM2A/PUCptZXJsikMsWBWeeerJ8Fy2XjvmBP/2yQiqF5Pkjokihd9iJwfh chHISfLfMOhyuPntCNljHEj4HG9XFvm1tPTDuiq8bePAAkOrcPo4veAvmzneOKi7qDOD8Np50 CYbKv7qM/dWVB+1CKyv+COWMpgQtCNKSnpYPjIycZrNbh/F7OqnbaAtlcCsx8zhFkbw8RY+sN c1z76BU/TxAfX97qnYvE8i40f3ZC2EQEFYPn3nbamUiZ096tDBSJhJpwAbFlwzko1LCPgYpmk KqvF7xghp5bU5gV5hYdJ+Uh6qOwc8Vt6yMZ2lOgfWvBUSUX7ilDo+4b2fxHHPAADBc5Qs+Ovf V9C2z5rl3FCQb+QHa7iB/Jw+Zrzfua28Rjf45w/ic2d/3MY4h1Id2qbigdtQe7HHbugvFNRM/ UoL7ja9hFWqVjS8rvK5Uin0mk01XJwtG3HFZrTBaRGAseFJEVO81FFoeocYzViowp0Anek0Uh 4kx37PZNsW7hlWCQe6qmj3/Ec07N808RBCMSkgyv7IlvcBOsR5fDfrFXiTHHKQURoQZyHu7AJ s/Lzgzfn61Dsqp+3DCwAjX3P7/2etkdAXSev5C/ayf3p76uiki/wIn+wdVPVhBSjwG4YGVTFi HSPMDrJGh4gJ0vRUy8xUP76Gi8lv3gtpJB1bH0ne2myO+O8s7NYA5N7fyEyjqJku8gWFyjpk Received-SPF: pass client-ip=212.227.17.22; envelope-from=boruch_baum@gmx.com; helo=mout.gmx.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 00:07:32 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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:188099 Archived-At: --c3dgevwv4k6pvmht Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable The attached proposed patch adds a defcustom and makes a change to two existing functions in order to allow a user the option to only have autorevert mode operate on visible buffers. The change to function 'after-find-files' may also fix a bug (or change behavior) in that sometimes when being prompted to manually revert a buffer that had been in auto-revert-mode, the auto-revert-mode status would be lost, ie. set to nil. Use of this feature: 1) Reduces CPU workload when using autorevert 2) Reduces messages when using `auto-revert-verbose' Possible disadvantage: 1) When making a buffer visible, it might take as long as 'auto-revert-interval' seconds for any accumulated changes to auto-revert. The default for that value is five seconds. =2D- hkp://keys.gnupg.net CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0 --c3dgevwv4k6pvmht Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="autorevert.patch" Content-Transfer-Encoding: quoted-printable diff --git a/autorevert.el b/autorevert.el index 7b83026..ace010e 100644 =2D-- a/autorevert.el +++ b/autorevert.el @@ -302,6 +302,12 @@ You should set this variable through Custom." :type 'regexp :version "24.4") +(defcustom auto-revert-only-if-visible nil + "If non-nil, suppress Auto-Revert Mode when a buffer isn't visible." + :group 'auto-revert + :type 'boolean + :version "28") + ;; Internal variables: (defvar auto-revert-buffer-list () @@ -686,8 +692,14 @@ This is an internal function used by Auto-Revert Mode= ." #'buffer-stale--default-function) t)))) eob eoblist) - (setq auto-revert-notify-modified-p nil) - (when revert + (when (and revert + (or (not auto-revert-only-if-visible) + (member buffer + (mapcar 'window-buffer + (get-buffer-window-list + nil nil + (if (display-graphic-p) 'visible (window-normali= ze-frame nil))))))) + (setq auto-revert-notify-modified-p nil) (when (and auto-revert-verbose (not (eq revert 'fast))) (message "Reverting buffer `%s'." (buffer-name))) --c3dgevwv4k6pvmht Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="files.patch" diff --git a/files.el b/files.el index e6629d2..2cdf451 100644 --- a/files.el +++ b/files.el @@ -2570,7 +2570,10 @@ unless NOMODES is non-nil." (unless nomodes (when (and view-read-only view-mode) (view-mode -1)) - (normal-mode t) + (let ((auto-revert auto-revert-mode)) + (normal-mode t) + (when auto-revert + (auto-revert-mode 1))) ;; If requested, add a newline at the end of the file. (and (memq require-final-newline '(visit visit-save)) (> (point-max) (point-min)) --c3dgevwv4k6pvmht Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="NEWS.patch" Content-Transfer-Encoding: quoted-printable diff --git a/NEWS b/NEWS index 4076630..579f1f9 100644 =2D-- a/NEWS +++ b/NEWS @@ -1157,6 +1157,12 @@ type symbols. messages, contain the error name of that message now. They can be made visible by setting user variable 'dbus-show-dbus-errors' to non-nil, even if protected by 'dbus-ignore-errors' otherwise. +** Autorevert + ++++ +*** autorevert can be restricted to act only when a buffer is visible + +Enable the feature using defcustom variable 'auto-revert-only-if-visible'= . =0C * New Modes and Packages in Emacs 28.1 --c3dgevwv4k6pvmht--