From a465c43b29fc7757d4beaefb9ac49dcfc6e7111e Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Sat, 6 Dec 2025 12:22:03 +0100 Subject: [PATCH] Simplify 'comint-write-input-ring' * lisp/comint.el (comint-write-input-ring): Use 'with-temp-buffer', 'decf' and write the buffer contents without 'buffer-string'. (bug#79954) --- lisp/comint.el | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lisp/comint.el b/lisp/comint.el index d94bc97ede3..be691363fe9 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -1120,21 +1120,16 @@ See also `comint-read-input-ring'." ((not (file-writable-p comint-input-ring-file-name)) (message "Cannot write history file %s" comint-input-ring-file-name)) (t - (let* ((history-buf (get-buffer-create " *Temp Input History*")) - (ring comint-input-ring) + (let* ((ring comint-input-ring) (file comint-input-ring-file-name) (separator comint-input-ring-separator) (index (ring-length ring))) ;; Write it all out into a buffer first. Much faster, but messier, ;; than writing it one line at a time. - (with-current-buffer history-buf - (erase-buffer) + (with-temp-buffer (while (> index 0) - (setq index (1- index)) - (insert (ring-ref ring index) separator)) - (write-region (buffer-string) nil file nil 'no-message) - (kill-buffer nil)))))) - + (insert (ring-ref ring (decf index)) separator)) + (write-region nil nil file nil 'no-message)))))) (defvar comint-dynamic-list-input-ring-window-conf)