]> git.eshelyaron.com Git - emacs.git/commitdiff
Use buffer-local value of 'comint-input-ring-size'
authorLiu Hui <liuhui1610@gmail.com>
Tue, 16 Jul 2024 10:05:46 +0000 (18:05 +0800)
committerEshel Yaron <me@eshelyaron.com>
Sat, 27 Jul 2024 12:03:11 +0000 (14:03 +0200)
When 'comint-read-input-ring' was reading history to the ring,
the global value of 'comint-input-ring-size' was used regardless
of the local value, due to the use of a temporary buffer.
This change fixes the problem.
* lisp/comint.el (comint-read-input-ring): Use buffer-local
value of the ring size.  (Bug#72138)

(cherry picked from commit c1436ac64dc3b30af1ee3994ca346b9bb6984228)

lisp/comint.el

index 2b54f6865055117233a5fad01e71031f078ce91d..8eba5d5c3b940c37f35b20f7ea4e45ca8364ed60 100644 (file)
@@ -1056,6 +1056,7 @@ See also `comint-input-ignoredups' and `comint-write-input-ring'."
                (ring-size (min 1500 comint-input-ring-size))
                (ring (make-ring ring-size))
                 ;; Use possibly buffer-local values of these variables.
+                (ring-max-size comint-input-ring-size)
                 (ring-separator comint-input-ring-separator)
                 (ring-file-prefix comint-input-ring-file-prefix)
                 (history-ignore comint-input-history-ignore)
@@ -1066,7 +1067,7 @@ See also `comint-input-ignoredups' and `comint-write-input-ring'."
              ;; Watch for those date stamps in history files!
              (goto-char (point-max))
              (let (start end history)
-               (while (and (< count comint-input-ring-size)
+               (while (and (< count ring-max-size)
                            (re-search-backward ring-separator nil t)
                            (setq end (match-beginning 0)))
                  (goto-char (if (re-search-backward ring-separator nil t)
@@ -1084,7 +1085,7 @@ See also `comint-input-ignoredups' and `comint-write-input-ring'."
                                (not (string-equal (ring-ref ring 0)
                                                   history))))
                   (when (= count ring-size)
-                    (ring-extend ring (min (- comint-input-ring-size ring-size)
+                    (ring-extend ring (min (- ring-max-size ring-size)
                                            ring-size))
                     (setq ring-size (ring-size ring)))
                   (ring-insert-at-beginning ring history)