Function: term-read-input-ring
term-read-input-ring is a byte-compiled function defined in
term.el.gz.
Signature
(term-read-input-ring &optional SILENT)
Documentation
Set the buffer's term-input-ring from a history file.
The name of the file is given by the variable term-input-ring-file-name.
The history ring is of size term-input-ring-size, regardless of file size.
If term-input-ring-file-name is nil this function does nothing.
If the optional argument SILENT is non-nil, we say nothing about a 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.
See also term-input-ignoredups and term-write-input-ring.
Source Code
;; Defined in /usr/src/emacs/lisp/term.el.gz
;;; Input history processing in a buffer
;; ===========================================================================
;; Useful input history functions, courtesy of the Ergo group.
;; Eleven commands:
;; term-dynamic-list-input-ring List history in help buffer.
;; term-previous-input Previous input...
;; term-previous-matching-input ...matching a string.
;; term-previous-matching-input-from-input ... matching the current input.
;; term-next-input Next input...
;; term-next-matching-input ...matching a string.
;; term-next-matching-input-from-input ... matching the current input.
;; term-backward-matching-input Backwards input...
;; term-forward-matching-input ...matching a string.
;; term-replace-by-expanded-history Expand history at point;
;; replace with expanded history.
;; term-magic-space Expand history and insert space.
;;
;; Three functions:
;; term-read-input-ring Read into term-input-ring...
;; term-write-input-ring Write to term-input-ring-file-name.
;; term-replace-by-expanded-history-before-point Workhorse function.
(defun term-read-input-ring (&optional silent)
"Set the buffer's `term-input-ring' from a history file.
The name of the file is given by the variable `term-input-ring-file-name'.
The history ring is of size `term-input-ring-size', regardless of file size.
If `term-input-ring-file-name' is nil this function does nothing.
If the optional argument SILENT is non-nil, we say nothing about a
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.
See also `term-input-ignoredups' and `term-write-input-ring'."
(cond ((or (null term-input-ring-file-name)
(equal term-input-ring-file-name ""))
nil)
((not (file-readable-p term-input-ring-file-name))
(or silent
(message "Cannot read history file %s"
term-input-ring-file-name)))
(t
(let ((file term-input-ring-file-name)
(count 0)
(ring (make-ring term-input-ring-size)))
(with-temp-buffer
(insert-file-contents file)
;; Save restriction in case file is already visited...
;; Watch for those date stamps in history files!
(goto-char (point-max))
(while (and (< count term-input-ring-size)
(re-search-backward "^[ \t]*\\([^#\n].*\\)[ \t]*$"
nil t))
(let ((history (buffer-substring (match-beginning 1)
(match-end 1))))
(when (or (null term-input-ignoredups)
(ring-empty-p ring)
(not (string-equal (ring-ref ring 0) history)))
(ring-insert-at-beginning ring history)))
(setq count (1+ count))))
(setq term-input-ring ring
term-input-ring-index nil)))))