branch: externals/autorevert-tail-truncate commit 1d8ac4467164bee3330bc8b32685f58c3c190043 Author: shipmints <shipmi...@gmail.com> Commit: shipmints <shipmi...@gmail.com>
Incorporate suggestions from Philip Kaludercic --- autorevert-tail-truncate.el | 51 +++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/autorevert-tail-truncate.el b/autorevert-tail-truncate.el index ec6cc2cb02..33d83e81ae 100644 --- a/autorevert-tail-truncate.el +++ b/autorevert-tail-truncate.el @@ -1,4 +1,4 @@ -;;; autorevert-tail-truncate.el -- Summary;: -*- mode: emacs-lisp; lexical-binding: t; -*- +;;; autorevert-tail-truncate.el --- auto-revert-tail your files with RAM control -*- lexical-binding: t; -*- ;; Copyright (C) 2025 Free Software Foundation, Inc. @@ -56,54 +56,72 @@ If nil, truncation is disabled. Bind this as a buffer-local variable to control the maximum number lines to retain for specific buffers." :group 'auto-revert - :type 'natnum) + :type '(choice (const :tag "Disabled" nil) natnum) + :version "29.1" + :package-version "1.0") (defcustom auto-revert-tail-truncate-file-size-hint 64 "Bytes per line hint to `auto-revert-tail-truncate-file'. This is multiplied by `auto-revert-tail-truncate-max-lines' to compute the initial bytes to load." :group 'auto-revert - :type 'natnum) + :type 'natnum + :version "29.1" + :package-version "1.0") (defcustom auto-revert-tail-truncate-revert-interval auto-revert-interval "Number of seconds between Auto-Revert Tail Truncate Mode file checks. The default value is `auto-revert-interval', which see." :group 'auto-revert - :type 'natnum) + :type 'natnum + :version "29.1" + :package-version "1.0") (defcustom auto-revert-tail-truncate-verbose auto-revert-verbose "When nil, `auto-revert-tail-truncate-mode' does not generate messages. When non-nil, a message is generated whenever a buffer is reverted. The default value is `auto-revert-verbose', which see." :group 'auto-revert - :type 'boolean) + :type 'boolean + :version "29.1" + :package-version "1.0") (defcustom auto-revert-tail-truncate-immediately t "If non-nil, buffer is truncated when this mode is enabled. Set the maximum number of lines to retain in the buffer using the option `auto-revert-tail-truncate-max-lines', which see." :group 'auto-revert - :type 'boolean) + :type 'boolean + :version "29.1" + :package-version "1.0") (defcustom auto-revert-tail-truncate-read-only t "If non-nil, the tailed buffer is set to be read only." :group 'auto-revert - :type 'boolean) + :type 'boolean + :version "29.1" + :package-version "1.0") (defcustom auto-revert-tail-truncate-disable-undo t "If non-nil, the buffer's undo log is disabled to save memory." :group 'auto-revert - :type 'boolean) + :type 'boolean + :version "29.1" + :package-version "1.0") (defcustom auto-revert-tail-truncate-disable-font-lock t "If non-nil, font-lock is disabled on the tailed buffer." :group 'auto-revert - :type 'boolean) + :type 'boolean + :version "29.1" + :package-version "1.0") (defcustom auto-revert-tail-truncate-mode-text " TailTrunc" "Mode line string when `auto-revert-tail-truncate-mode' is active." :group 'auto-revert - :type 'string) + :type 'string + :version "29.1" + :package-version "1.0") (defvar-local auto-revert-tail-truncate-mode nil "Non-nil when `auto-revert-tail-truncate-mode' is active. @@ -119,15 +137,17 @@ buffer in which it is displayed. Customize `auto-revert-tail-mode-hook' to control features such as `truncate-lines' for the tailed buffer." - :group 'find-file + :group 'auto-revert :lighter auto-revert-tail-truncate-mode-text (if auto-revert-tail-truncate-mode (progn (setq-local auto-revert-tail-mode-text nil) ; this mode's lighter has priority (auto-revert-tail-mode) - (make-local-variable 'auto-revert-interval) - (make-local-variable 'auto-revert-timer) - (setopt auto-revert-interval auto-revert-tail-truncate-revert-interval) + (progn + (make-local-variable 'auto-revert-interval) + (make-local-variable 'auto-revert-timer) + (setq auto-revert-interval auto-revert-tail-truncate-revert-interval) + (auto-revert-set-timer)) (setq-local auto-revert-verbose auto-revert-tail-truncate-verbose) (when auto-revert-tail-truncate-read-only (read-only-mode)) @@ -136,8 +156,7 @@ Customize `auto-revert-tail-mode-hook' to control features such as (when auto-revert-tail-truncate-disable-font-lock (font-lock-mode -1)) (when (version< emacs-version "31") - (make-local-variable 'auto-revert-check-vc-info) - (setq auto-revert-check-vc-info nil)) + (setq-local auto-revert-check-vc-info nil)) (goto-char (point-max)) (when auto-revert-tail-truncate-immediately (auto-revert--tail-truncate))