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* ((ring comint-input-ring)
		(file comint-input-ring-file-name)
                (separator comint-input-ring-separator)
		(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-temp-buffer
	     (while (> index 0)
	       (insert (ring-ref ring (decf index)) separator))
	     (write-region nil nil file nil 'no-message))))))