Variable: auto-save-visited-predicate

auto-save-visited-predicate is a customizable variable defined in files.el.gz.

Value

nil

Documentation

Predicate function for auto-save-visited-mode(var)/auto-save-visited-mode(fun).

If non-nil, the value should be a function of no arguments; it will be called once in each file-visiting buffer when the time comes to auto-save. A buffer will be saved only if the predicate function returns a non-nil value.

For example, you could add this to your Init file to only save files that are both in Org mode and in a particular directory:

    (setq auto-save-visited-predicate
          (lambda () (and (eq major-mode 'org-mode)
                          (string-match "^/home/skangas/org/"
                                        buffer-file-name))))

If the value of this variable is not a function, it is ignored. This is the same as having a predicate that always returns non-nil.

This variable was added, or its default value changed, in Emacs 29.1.

Probably introduced at or before Emacs version 29.1.

Source Code

;; Defined in /usr/src/emacs/lisp/files.el.gz
(defcustom auto-save-visited-predicate nil
  "Predicate function for `auto-save-visited-mode'.

If non-nil, the value should be a function of no arguments; it
will be called once in each file-visiting buffer when the time
comes to auto-save.  A buffer will be saved only if the predicate
function returns a non-nil value.

For example, you could add this to your Init file to only save
files that are both in Org mode and in a particular directory:

    (setq auto-save-visited-predicate
          (lambda () (and (eq major-mode \\='org-mode)
                          (string-match \"^/home/skangas/org/\"
                                        buffer-file-name))))

If the value of this variable is not a function, it is ignored.
This is the same as having a predicate that always returns
non-nil."
  :group 'auto-save
  :type '(choice :tag "Function:"
                 (const :tag "No extra predicate" :value nil)
                 (function :tag "Predicate function" :value always))
  :risky t
  :version "29.1")