Function: logview--do-append-log-file-tail
logview--do-append-log-file-tail is a natively compiled function
defined in logview.el.
Signature
(logview--do-append-log-file-tail &optional NO-ERRORS)
Documentation
Perform the work of logview-append-log-file-tail.
If NO-ERRORS is non-nil and the file has changed in a non-growing way, returns nil rather than barking. In case of success, always returns non-nil.
Source Code
;; Defined in /nix/store/3zkn9hgpv447zb8nrg55d9x2ynmmrk40-emacs-packages-deps/share/emacs/site-lisp/elpa/logview-20260218.2013/logview.el
(defun logview--do-append-log-file-tail (&optional no-errors)
"Perform the work of `logview-append-log-file-tail'.
If NO-ERRORS is non-nil and the file has changed in a non-growing
way, returns nil rather than barking. In case of success, always
returns non-nil."
(logview--std-temporarily-widening ;FIXME: `logview--temporarily-widening'?
(let* ((buffer (current-buffer))
(file buffer-file-name)
(reassurance-chars (min (max logview-reassurance-chars 0)
(buffer-size)))
(compare-from (- (point-max) reassurance-chars))
(current-text (buffer-substring-no-properties
compare-from (point-max)))
(compare-from-bytes (bufferpos-to-filepos compare-from)))
(with-temp-buffer
;; As of Emacs 30 this fails when trying to read past the end of the
;; file (in earlier Emacs versions it works, but doesn't insert
;; anything). Don't care to report anything to Emacs-devel (maybe it's
;; even intentional in this case, don't know), just work with either
;; behavior by suppressing all errors.
(ignore-errors (insert-file-contents file nil compare-from-bytes nil))
(let ((temporary (current-buffer))
(temporary-boundary (+ reassurance-chars (point-min)))
(temporary-size (buffer-size)))
(if (and (>= temporary-size reassurance-chars)
(string= (buffer-substring-no-properties
(point-min) temporary-boundary)
current-text))
(if (= temporary-size reassurance-chars)
(message "Backing file %s hasn't grown" file)
(with-current-buffer buffer
(let ((was-modified (buffer-modified-p))
(inhibit-read-only t)
;; This is to avoid unnecessary confirmation about
;; modifying a buffer with externally changed file.
(buffer-file-name nil))
(save-excursion
(goto-char (point-max))
;; FIXME: Why `-no-properties'?
(insert-buffer-substring-no-properties
temporary temporary-boundary nil))
(restore-buffer-modified-p was-modified))
(message "Appended the tail of file %s" file)))
(unless no-errors
(user-error "Buffer contents doesn't match the head of %s anymore" file))))))))