summaryrefslogtreecommitdiff
path: root/lisp/comint.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1999-08-29 20:55:30 +0000
committerRichard M. Stallman <rms@gnu.org>1999-08-29 20:55:30 +0000
commitbc29fd5ff8330481b3c739eeca4e3ae5dbc01c19 (patch)
treedb4dd48360352967b722d816153b736e90a06017 /lisp/comint.el
parent7e7ef77238fb0d4ebdeece535f40ae7957f8b7b4 (diff)
downloademacs-bc29fd5ff8330481b3c739eeca4e3ae5dbc01c19.tar.gz
(comint-input-ring-separator): New variable.
(comint-read-input-ring): Doc change; use comint-input-ring-separator when reading file. (comint-write-input-ring): Use comint-input-ring-separator when writing file.
Diffstat (limited to 'lisp/comint.el')
-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'."
(defvar comint-input-ring-size 32
"Size of input history ring.")
+(defvar comint-input-ring-separator "\n"
+ "Separator between commands in the history file.")
+
(defcustom comint-process-echoes nil
"*If non-nil, assume that the subprocess echoes any input.
If so, delete one copy of the input so that only one copy eventually
@@ -744,8 +747,9 @@ failure to read the history file.
This function is useful for major mode commands and mode hooks.
-The structure of the history file should be one input command per line,
-with the most recent command last.
+The commands stored in the history file are separated by the
+`comint-input-ring-separator'. The most recent command comes last.
+
See also `comint-input-ignoredups' and `comint-write-input-ring'."
(cond ((or (null comint-input-ring-file-name)
(equal comint-input-ring-file-name ""))
@@ -771,13 +775,19 @@ See also `comint-input-ignoredups' and `comint-write-input-ring'."
(while (and (< count comint-input-ring-size)
(re-search-backward "^[ \t]*\\([^#\n].*\\)[ \t]*$"
nil t))
- (let ((history (buffer-substring (match-beginning 1)
- (match-end 1))))
- (if (or (null comint-input-ignoredups)
- (ring-empty-p ring)
- (not (string-equal (ring-ref ring 0) history)))
- (ring-insert-at-beginning ring history)))
- (setq count (1+ count))))
+ (let (start end history)
+ (while (and (< count comint-input-ring-size)
+ (re-search-backward comint-input-ring-separator nil t)
+ (setq end (match-beginning 0))
+ (re-search-backward comint-input-ring-separator nil t)
+ (setq start (match-end 0))
+ (setq history (buffer-substring start end))
+ (goto-char start))
+ (if (or (null comint-input-ignoredups)
+ (ring-empty-p ring)
+ (not (string-equal (ring-ref ring 0) history)))
+ (ring-insert-at-beginning ring history)))
+ (setq count (1+ count)))))
(kill-buffer history-buf))
(setq comint-input-ring ring
comint-input-ring-index nil)))))
@@ -809,7 +819,7 @@ See also `comint-read-input-ring'."
(erase-buffer)
(while (> index 0)
(setq index (1- index))
- (insert (ring-ref ring index) ?\n))
+ (insert (ring-ref ring index) comint-input-ring-separator))
(write-region (buffer-string) nil file nil 'no-message)
(kill-buffer nil))))))