Allow global-auto-revert-ignore-buffer to be a predicate function

* lisp/autorevert.el (global-auto-revert-ignore-buffer): Allow
this to be a predicate function (bug#25277).
(auto-revert--global-add-current-buffer): Use it.
This commit is contained in:
Lars Ingebrigtsen 2019-07-27 13:04:33 +02:00
parent e310843d9d
commit b41a763d9a
2 changed files with 14 additions and 2 deletions

View file

@ -1691,6 +1691,11 @@ the new variable 'buffer-auto-revert-by-notification' to a non-nil
value. Auto Revert mode can use this information to avoid polling the
buffer periodically when 'auto-revert-avoid-polling' is non-nil.
---
*** `global-auto-revert-ignore-buffer' can now also be a predicate
function that can be used for more fine-grained control of which
buffers to auto-revert.
** auth-source-pass
+++

View file

@ -266,7 +266,10 @@ buffers. CPU usage depends on the version control system."
(defvar-local global-auto-revert-ignore-buffer nil
"When non-nil, Global Auto-Revert Mode will not revert this buffer.
This variable becomes buffer local when set in any fashion.")
This variable can also be a predicate function, in which case
it'll be called with one parameter (the buffer in question), and
it should return non-nil to make Global Auto-Revert Mode not
revert this buffer.")
(defcustom auto-revert-remote-files nil
"If non-nil remote files are also reverted."
@ -541,7 +544,11 @@ specifies in the mode line."
(not (eq buffer-stale-function
#'buffer-stale--default-function))))
(not (memq 'major-mode global-auto-revert-ignore-modes))
(not global-auto-revert-ignore-buffer))
(or (null global-auto-revert-ignore-buffer)
(if (functionp global-auto-revert-ignore-buffer)
(not (funcall global-auto-revert-ignore-buffer
(current-buffer)))
nil)))
(setq auto-revert--global-mode t)))
(defun auto-revert--global-adopt-current-buffer ()