diff options
| author | Gerd Moellmann | 2001-04-18 14:18:44 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-04-18 14:18:44 +0000 |
| commit | 80c40c6fbc6dd223134f647e7d7237de92e64541 (patch) | |
| tree | 1a20eefcd86a959c64fd6dba6d6c759e25f3fb25 | |
| parent | 90200fccb14964c16f140e28d8b99a26266de30c (diff) | |
| download | emacs-80c40c6fbc6dd223134f647e7d7237de92e64541.tar.gz emacs-80c40c6fbc6dd223134f647e7d7237de92e64541.zip | |
(comint-cr-magic): New function.
(toplevel): Add it to comint-preoutput-filter-functions.
| -rw-r--r-- | lisp/comint.el | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lisp/comint.el b/lisp/comint.el index aadf85f7261..7a5e7ad8928 100644 --- a/lisp/comint.el +++ b/lisp/comint.el | |||
| @@ -1496,6 +1496,30 @@ This variable is permanent-local.") | |||
| 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. |