Function: comint-write-input-ring
comint-write-input-ring is a byte-compiled function defined in
comint.el.gz.
Signature
(comint-write-input-ring)
Documentation
Writes the buffer's comint-input-ring to a history file.
The name of the file is given by the variable comint-input-ring-file-name.
The original contents of the file are lost if comint-input-ring is not empty.
If comint-input-ring-file-name is nil this function does nothing.
Useful within process sentinels.
See also comint-read-input-ring.
Source Code
;; Defined in /usr/src/emacs/lisp/comint.el.gz
(defun comint-write-input-ring ()
"Writes the buffer's `comint-input-ring' to a history file.
The name of the file is given by the variable `comint-input-ring-file-name'.
The original contents of the file are lost if `comint-input-ring' is not empty.
If `comint-input-ring-file-name' is nil this function does nothing.
Useful within process sentinels.
See also `comint-read-input-ring'."
(cond ((or (null comint-input-ring-file-name)
(equal comint-input-ring-file-name "")
(null comint-input-ring) (ring-empty-p comint-input-ring))
nil)
((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)
(file comint-input-ring-file-name)
(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)
(while (> index 0)
(setq index (1- index))
(insert (ring-ref ring index) comint-input-ring-separator))
(write-region (buffer-string) nil file nil 'no-message)
(kill-buffer nil))))))