Function: comint-write-output

comint-write-output is an interactive and byte-compiled function defined in comint.el.gz.

Signature

(comint-write-output FILENAME &optional APPEND MUSTBENEW)

Documentation

Write output from interpreter since last input to FILENAME.

Any prompt at the end of the output is not written.

If the optional argument APPEND (the prefix argument when interactive) is non-nil, the output is appended to the file instead.

If the optional argument MUSTBENEW is non-nil, check for an existing file with the same name. If MUSTBENEW is excl, that means to get an error if the file already exists; never overwrite. If MUSTBENEW is neither nil nor excl, that means ask for confirmation before overwriting, but do go ahead and overwrite the file if the user confirms. When interactive, MUSTBENEW is nil when appending, and t otherwise.

View in manual

Probably introduced at or before Emacs version 21.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/comint.el.gz
(defun comint-write-output (filename &optional append mustbenew)
  "Write output from interpreter since last input to FILENAME.
Any prompt at the end of the output is not written.

If the optional argument APPEND (the prefix argument when interactive)
is non-nil, the output is appended to the file instead.

If the optional argument MUSTBENEW is non-nil, check for an existing
file with the same name.  If MUSTBENEW is `excl', that means to get an
error if the file already exists; never overwrite.  If MUSTBENEW is
neither nil nor `excl', that means ask for confirmation before
overwriting, but do go ahead and overwrite the file if the user
confirms.  When interactive, MUSTBENEW is nil when appending, and t
otherwise."
  (interactive
   (list (read-file-name
	  (if current-prefix-arg
	      "Append output to file: "
	    "Write output to file: "))
	 current-prefix-arg
	 (not current-prefix-arg)))
  (save-excursion
    (goto-char (process-mark (get-buffer-process (current-buffer))))
    (forward-line 0)
    (write-region comint-last-input-end (point) filename
		  append nil nil mustbenew)))