Function: fast-lock-save-cache

fast-lock-save-cache is an interactive and byte-compiled function defined in fast-lock.el.gz.

Signature

(fast-lock-save-cache &optional BUFFER)

Documentation

Save the Font Lock cache of BUFFER or the current buffer.

The following criteria must be met for a Font Lock cache file to be saved:
- Fast Lock mode must be turned on in the buffer.
- The event must be one of fast-lock-save-events.
- The buffer must be at least fast-lock-minimum-size bytes long.
- The buffer file must be owned by you, or fast-lock-save-others must be t.
- The buffer must contain at least one face text property.
- The buffer must not be modified.
- The buffer file's timestamp must be the same as the file's on disk.
- The on disk file's timestamp must be different than the buffer's cache.
- Criteria imposed by fast-lock-cache-directories.

See fast-lock-mode(var)/fast-lock-mode(fun).

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/obsolete/fast-lock.el.gz
(defun fast-lock-save-cache (&optional buffer)
  "Save the Font Lock cache of BUFFER or the current buffer.

The following criteria must be met for a Font Lock cache file to be saved:
- Fast Lock mode must be turned on in the buffer.
- The event must be one of `fast-lock-save-events'.
- The buffer must be at least `fast-lock-minimum-size' bytes long.
- The buffer file must be owned by you, or `fast-lock-save-others' must be t.
- The buffer must contain at least one `face' text property.
- The buffer must not be modified.
- The buffer file's timestamp must be the same as the file's on disk.
- The on disk file's timestamp must be different than the buffer's cache.
- Criteria imposed by `fast-lock-cache-directories'.

See `fast-lock-mode'."
  (interactive)
  (save-excursion
    (when buffer
      (set-buffer buffer))
    (let ((min-size (font-lock-value-in-major-mode fast-lock-minimum-size))
	  (file-timestamp (visited-file-modtime)) (saved nil))
      (when (and fast-lock-mode
	     ;;
	     ;; "Only save if the buffer matches the file, the file has
	     ;; changed, and it was changed by the current emacs session."
	     ;;
	     ;; Only save if the buffer is not modified,
	     ;; (i.e., so we don't save for something not on disk)
	     (not (buffer-modified-p))
	     ;; and the file's timestamp is the same as the buffer's,
	     ;; (i.e., someone else hasn't written the file in the meantime)
	     (verify-visited-file-modtime (current-buffer))
	     ;; and the file's timestamp is different from the cache's.
	     ;; (i.e., a save has occurred since the cache was read)
	     (not (equal fast-lock-cache-timestamp file-timestamp))
	     ;;
	     ;; Only save if user's restrictions are satisfied.
	     (and min-size (>= (buffer-size) min-size))
	     (or fast-lock-save-others
		 (eq (user-uid) (file-attribute-user-id
				 (file-attributes buffer-file-name))))
	     ;;
	     ;; Only save if there are `face' properties to save.
	     (text-property-not-all (point-min) (point-max) 'face nil))
	;;
	;; Try each directory until we manage to save or the user quits.
	(let ((directories fast-lock-cache-directories))
	  (while (and directories (memq saved '(nil error)))
	    (let* ((dir (fast-lock-cache-directory (car directories) t))
		   (file (and dir (fast-lock-cache-name dir))))
	      (when (and file (file-writable-p file))
		(setq saved (fast-lock-save-cache-1 file file-timestamp)))
	      (setq directories (cdr directories)))))))))