comparison lisp/comint.el @ 37386:b5ddd589d143

(comint-cr-magic): New function. (toplevel): Add it to comint-preoutput-filter-functions.
author Gerd Moellmann <gerd@gnu.org>
date Wed, 18 Apr 2001 14:18:44 +0000
parents 76fed386fc02
children 321506783c09
comparison
equal deleted inserted replaced
37385:f6daa641d91f 37386:b5ddd589d143
1494 (defun comint-snapshot-last-prompt () 1494 (defun comint-snapshot-last-prompt ()
1495 (when comint-last-prompt-overlay 1495 (when comint-last-prompt-overlay
1496 (overlay-put comint-last-prompt-overlay 'evaporate t) 1496 (overlay-put comint-last-prompt-overlay 'evaporate t)
1497 (setq comint-last-prompt-overlay nil))) 1497 (setq comint-last-prompt-overlay nil)))
1498 1498
1499 (defun comint-cr-magic (string)
1500 "Handle carriage returns in comint output.
1501 Translate carraige return/linefeed sequences to linefeeds.
1502 Let single carriage returns delete to the beginning of the line."
1503 (save-match-data
1504 ;; CR LF -> LF
1505 (while (string-match "\r\n" string)
1506 (setq string (replace-match "\n" nil t string)))
1507 ;; Let a single CR act like a carriage return on a real terminal.
1508 ;; Delete everything from the beginning of the line to the
1509 ;; insertion point.
1510 (when (string-match ".*\r" string)
1511 (setq string (replace-match "" nil t string))
1512 (save-excursion
1513 (save-restriction
1514 (widen)
1515 (let ((inhibit-field-text-motion t)
1516 (buffer-read-only nil))
1517 (goto-char (process-mark (get-buffer-process (current-buffer))))
1518 (delete-region (line-beginning-position) (point))))))
1519 string))
1520
1521 (add-hook 'comint-preoutput-filter-functions 'comint-cr-magic)
1522
1499 ;; The purpose of using this filter for comint processes 1523 ;; The purpose of using this filter for comint processes
1500 ;; is to keep comint-last-input-end from moving forward 1524 ;; is to keep comint-last-input-end from moving forward
1501 ;; when output is inserted. 1525 ;; when output is inserted.
1502 (defun comint-output-filter (process string) 1526 (defun comint-output-filter (process string)
1503 (let ((oprocbuf (process-buffer process))) 1527 (let ((oprocbuf (process-buffer process)))