1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Don't create directory in erc-truncate compat check

* lisp/erc/erc-log.el (erc-log--check-writable-nocreate-p): New variable.
(erc-logging-enabled): Use `erc-log--save-in-progress-p' flag to
conditionally avoid creating a directory when checking if the location
is writable.
(erc-log--call-when-logging-enabled-sans-module)
(erc-log--check-legacy-implicit-enabling-by-truncate): Rename former to
latter, and guard against creating a ~/log directory just to see if it's
writable when calling `erc-logging-enabled'.
(erc-truncate-mode): Explain legacy "implicit logging" behavior in doc
string.
* lisp/erc/erc-truncate.el (erc-truncate--warn-about-logging): Make more
concise, and defer to `erc-truncate-mode' doc string for particulars.
* lisp/erc/erc.el (erc-directory-writable-p): Add comment to rename on
next non-patch release.
This commit is contained in:
F. Jason Park 2024-09-30 02:10:02 -07:00
parent 3f1ce47fe7
commit 1de2c86317
3 changed files with 36 additions and 25 deletions

View file

@ -52,7 +52,18 @@ plus `erc-max-buffer-size'."
"Truncate a query buffer if it gets too large.
This prevents the query buffer from getting too large, which can
bring any grown Emacs to its knees after a few days worth of
tracking heavy-traffic channels."
tracking heavy-traffic channels.
Before ERC 5.6, this module performed logging whenever the \\+`log'
module's library, \\+`erc-log', happened to be loaded, regardless of
whether the \\+`log' module itself was enabled. (Loading can of course
happen in any number of ways, such as when browsing options via
\\[customize-group] or completing autoloaded symbol names at the
\\[describe-variable] prompt.) Users of \\+`truncate' who prefer the
old behavior can add \\+`log' to `erc-modules' to get the same effect.
Those who don't want logging but need to load the \\+`erc-log' library
for other purposes should customize either `erc-enable-logging' or
`erc-log-channels-directory' to avoid the annoying warning."
;;enable
((add-hook 'erc-insert-done-hook #'erc-truncate-buffer)
(add-hook 'erc-connect-pre-hook #'erc-truncate--warn-about-logging)
@ -83,21 +94,13 @@ tracking heavy-traffic channels."
(defun erc-truncate--warn-about-logging (&rest _)
(when (and (not erc--target)
(fboundp 'erc-log--call-when-logging-enabled-sans-module))
;; We could also enable `erc-log-mode' here, but the risk of
;; lasting damage is nonzero.
(erc-log--call-when-logging-enabled-sans-module
(lambda (dirfile)
;; Emit a real Emacs warning because the message may be
;; truncated away before it can be read if merely inserted.
(erc-button--display-error-notice-with-keys-and-warn
"The `truncate' module no longer enables logging implicitly."
" If you want ERC to write logs before truncating, add `log' to"
" `erc-modules' using something like \\[customize-option]."
" To silence this message, don't `require' `erc-log'."
(and dirfile " Alternatively, change the value of")
(and dirfile " `erc-log-channels-directory', or move ")
dirfile (and dirfile " elsewhere."))))))
(fboundp 'erc-log--check-legacy-implicit-enabling-by-truncate)
(erc-log--check-legacy-implicit-enabling-by-truncate))
;; Emit a real Emacs warning because the message may be
;; truncated away before it can be read if merely inserted.
(erc-button--display-error-notice-with-keys-and-warn
"The `truncate' module no longer enables logging implicitly."
" See the doc string for `erc-truncate-mode' for details.")))
;;;###autoload
(defun erc-truncate-buffer-to-size (size &optional buffer)