Fix bug in 'sieve-manage--append-to-log'

* lisp/net/sieve-manage.el (sieve-manage--append-to-log): Fix
log buffer creation.  (Bug#54154)  Do not merge to master.
This commit is contained in:
Kai Tetzlaff 2023-01-19 03:16:14 +01:00 committed by Eli Zaretskii
parent 21be03cccb
commit 12d7670b90

View file

@ -168,19 +168,25 @@ Valid states are `closed', `initial', `nonauth', and `auth'.")
;; Internal utility functions
(defun sieve-manage--append-to-log (&rest args)
"Append ARGS to sieve-manage log buffer.
"Append ARGS to `sieve-manage-log' buffer.
ARGS can be a string or a list of strings.
The buffer to use for logging is specifified via
`sieve-manage-log'. If it is nil, logging is disabled."
The buffer to use for logging is specifified via `sieve-manage-log'.
If it is nil, logging is disabled.
When the `sieve-manage-log' buffer doesn't exist, it gets created (and
configured with some initial settings)."
(when sieve-manage-log
(with-current-buffer (or (get-buffer sieve-manage-log)
(with-current-buffer
(get-buffer-create sieve-manage-log)
(set-buffer-multibyte nil)
(buffer-disable-undo)))
(goto-char (point-max))
(apply #'insert args))))
(let* ((existing-log-buffer (get-buffer sieve-manage-log))
(log-buffer (or existing-log-buffer
(get-buffer-create sieve-manage-log))))
(with-current-buffer log-buffer
(unless existing-log-buffer
;; Do this only once, when creating the log buffer.
(set-buffer-multibyte nil)
(buffer-disable-undo))
(goto-char (point-max))
(apply #'insert args)))))
(defun sieve-manage--message (format-string &rest args)
"Wrapper around `message' which also logs to sieve manage log.