aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/comint.el30
1 files changed, 20 insertions, 10 deletions
diff --git a/lisp/comint.el b/lisp/comint.el
index fda580feb99..1e7c0ee3c27 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -268,6 +268,9 @@ the function `comint-truncate-buffer' is on `comint-output-filter-functions'."
268(defvar comint-input-ring-size 32 268(defvar comint-input-ring-size 32
269 "Size of input history ring.") 269 "Size of input history ring.")
270 270
271(defvar comint-input-ring-separator "\n"
272 "Separator between commands in the history file.")
273
271(defcustom comint-process-echoes nil 274(defcustom comint-process-echoes nil
272 "*If non-nil, assume that the subprocess echoes any input. 275 "*If non-nil, assume that the subprocess echoes any input.
273If so, delete one copy of the input so that only one copy eventually 276If so, delete one copy of the input so that only one copy eventually
@@ -744,8 +747,9 @@ failure to read the history file.
744 747
745This function is useful for major mode commands and mode hooks. 748This function is useful for major mode commands and mode hooks.
746 749
747The structure of the history file should be one input command per line, 750The commands stored in the history file are separated by the
748with the most recent command last. 751`comint-input-ring-separator'. The most recent command comes last.
752
749See also `comint-input-ignoredups' and `comint-write-input-ring'." 753See also `comint-input-ignoredups' and `comint-write-input-ring'."
750 (cond ((or (null comint-input-ring-file-name) 754 (cond ((or (null comint-input-ring-file-name)
751 (equal comint-input-ring-file-name "")) 755 (equal comint-input-ring-file-name ""))
@@ -771,13 +775,19 @@ See also `comint-input-ignoredups' and `comint-write-input-ring'."
771 (while (and (< count comint-input-ring-size) 775 (while (and (< count comint-input-ring-size)
772 (re-search-backward "^[ \t]*\\([^#\n].*\\)[ \t]*$" 776 (re-search-backward "^[ \t]*\\([^#\n].*\\)[ \t]*$"
773 nil t)) 777 nil t))
774 (let ((history (buffer-substring (match-beginning 1) 778 (let (start end history)
775 (match-end 1)))) 779 (while (and (< count comint-input-ring-size)
776 (if (or (null comint-input-ignoredups) 780 (re-search-backward comint-input-ring-separator nil t)
777 (ring-empty-p ring) 781 (setq end (match-beginning 0))
778 (not (string-equal (ring-ref ring 0) history))) 782 (re-search-backward comint-input-ring-separator nil t)
779 (ring-insert-at-beginning ring history))) 783 (setq start (match-end 0))
780 (setq count (1+ count)))) 784 (setq history (buffer-substring start end))
785 (goto-char start))
786 (if (or (null comint-input-ignoredups)
787 (ring-empty-p ring)
788 (not (string-equal (ring-ref ring 0) history)))
789 (ring-insert-at-beginning ring history)))
790 (setq count (1+ count)))))
781 (kill-buffer history-buf)) 791 (kill-buffer history-buf))
782 (setq comint-input-ring ring 792 (setq comint-input-ring ring
783 comint-input-ring-index nil))))) 793 comint-input-ring-index nil)))))
@@ -809,7 +819,7 @@ See also `comint-read-input-ring'."
809 (erase-buffer) 819 (erase-buffer)
810 (while (> index 0) 820 (while (> index 0)
811 (setq index (1- index)) 821 (setq index (1- index))
812 (insert (ring-ref ring index) ?\n)) 822 (insert (ring-ref ring index) comint-input-ring-separator))
813 (write-region (buffer-string) nil file nil 'no-message) 823 (write-region (buffer-string) nil file nil 'no-message)
814 (kill-buffer nil)))))) 824 (kill-buffer nil))))))
815 825