]> git.eshelyaron.com Git - emacs.git/commitdiff
(comint-write-output, comint-append-output-to-file): New functions.
authorMiles Bader <miles@gnu.org>
Thu, 19 Oct 2000 02:12:30 +0000 (02:12 +0000)
committerMiles Bader <miles@gnu.org>
Thu, 19 Oct 2000 02:12:30 +0000 (02:12 +0000)
(comint-mode-map): Add them to the menu.

lisp/ChangeLog
lisp/comint.el

index f4f51ec5e90b93b0cc60d044fdd6ee976ca0da72..a2638f6a728ff266d101f6782dff7aa6c45cac45 100644 (file)
@@ -1,3 +1,9 @@
+2000-10-19  Miles Bader  <miles@lsi.nec.co.jp>
+
+       * comint.el (comint-write-output, comint-append-output-to-file):
+       New functions.
+       (comint-mode-map): Add them to the menu.
+
 2000-10-18  Gerd Moellmann  <gerd@gnu.org>
 
        * startup.el (fancy-splash-screens): Set buffer-undo-list to t.
index 318e1566b0d8cf0b2b5b34461e6a5c917f8c613c..2569ce434d935b94cb40749460a89c31a1dd923e 100644 (file)
@@ -574,6 +574,10 @@ Entry to this mode runs the hooks on `comint-mode-hook'."
     (cons "In/Out" (make-sparse-keymap "In/Out")))
   (define-key comint-mode-map [menu-bar inout delete-output]
     '("Delete Current Output Group" . comint-delete-output))
+  (define-key comint-mode-map [menu-bar inout write-output]
+    '("Write Current Output Group to File" . comint-write-output))
+  (define-key comint-mode-map [menu-bar inout append-output-to-file]
+    '("Append Current Output Group to File" . comint-append-output-to-file))
   (define-key comint-mode-map [menu-bar inout next-prompt]
     '("Forward Output Group" . comint-next-prompt))
   (define-key comint-mode-map [menu-bar inout previous-prompt]
@@ -1870,7 +1874,7 @@ This function could be in the list `comint-output-filter-functions'."
 ;; Random input hackage
 
 (defun comint-delete-output ()
-  "Kill all output from interpreter since last input.
+  "Delete all output from interpreter since last input.
 Does not delete the prompt."
   (interactive)
   (let ((proc (get-buffer-process (current-buffer)))
@@ -1889,6 +1893,33 @@ Does not delete the prompt."
 (defalias 'comint-kill-output 'comint-delete-output)
 (make-obsolete 'comint-kill-output 'comint-delete-output "21.1")
 
+(defun comint-write-output (filename &optional 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 MUSTBENEW (the prefix argument when interactive),
+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."
+  (interactive "FWrite output to file: \np")
+  (save-excursion
+    (goto-char (process-mark (get-buffer-process (current-buffer))))
+    (forward-line 0)
+    (write-region comint-last-input-end (point)
+                 filename nil nil nil mustbenew)))
+
+(defun comint-append-output-to-file (filename)
+  "Append output from interpreter since last input to FILENAME.
+Any prompt at the end of the output is not written."
+  (interactive "FAppend output to file: ")
+  (save-excursion
+    (goto-char (process-mark (get-buffer-process (current-buffer))))
+    (forward-line 0)
+    (write-region comint-last-input-end (point) filename t)))
+
+
 (defun comint-show-output ()
   "Display start of this batch of interpreter output at top of window.
 Sets mark to the value of point when this command is run."