diff options
| author | Richard M. Stallman | 1993-05-06 19:51:08 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-05-06 19:51:08 +0000 |
| commit | 5511e41124338ebd78d652e2756e21576062fe2c (patch) | |
| tree | 615a616b7acce9db81bdf77c5db87a0b8aafa1c9 | |
| parent | c3bd85dd5f7a723f4ad937d3fc33be8d62ad2d36 (diff) | |
| download | emacs-5511e41124338ebd78d652e2756e21576062fe2c.tar.gz emacs-5511e41124338ebd78d652e2756e21576062fe2c.zip | |
(comint-filter): New function.
(comint-exec): Install the filter.
| -rw-r--r-- | lisp/comint.el | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/lisp/comint.el b/lisp/comint.el index 5f6d8301c01..5c0d27ccb89 100644 --- a/lisp/comint.el +++ b/lisp/comint.el | |||
| @@ -330,6 +330,7 @@ buffer. The hook comint-exec-hook is run after each exec." | |||
| 330 | (if proc (delete-process proc))) | 330 | (if proc (delete-process proc))) |
| 331 | ;; Crank up a new process | 331 | ;; Crank up a new process |
| 332 | (let ((proc (comint-exec-1 name buffer command switches))) | 332 | (let ((proc (comint-exec-1 name buffer command switches))) |
| 333 | (set-process-filter proc 'comint-filter) | ||
| 333 | (make-local-variable 'comint-ptyp) | 334 | (make-local-variable 'comint-ptyp) |
| 334 | (setq comint-ptyp process-connection-type) ; T if pty, NIL if pipe. | 335 | (setq comint-ptyp process-connection-type) ; T if pty, NIL if pipe. |
| 335 | ;; Jump to the end, and set the process mark. | 336 | ;; Jump to the end, and set the process mark. |
| @@ -594,7 +595,7 @@ point as input to the process. Before the process output mark, calls value | |||
| 594 | of variable `comint-get-old-input' to retrieve old input, copies it to the | 595 | of variable `comint-get-old-input' to retrieve old input, copies it to the |
| 595 | process mark, and sends it. If variable `comint-process-echoes' is `nil', | 596 | process mark, and sends it. If variable `comint-process-echoes' is `nil', |
| 596 | a terminal newline is also inserted into the buffer and sent to the process | 597 | a terminal newline is also inserted into the buffer and sent to the process |
| 597 | (if it is non-`nil', all text from the process mark to point is deleted, | 598 | \(if it is non-`nil', all text from the process mark to point is deleted, |
| 598 | since it is assumed the remote process will re-echo it). The value of | 599 | since it is assumed the remote process will re-echo it). The value of |
| 599 | variable `comint-input-sentinel' is called on the input before sending it. | 600 | variable `comint-input-sentinel' is called on the input before sending it. |
| 600 | The input is entered into the input history ring, if the value of variable | 601 | The input is entered into the input history ring, if the value of variable |
| @@ -645,6 +646,43 @@ Similarly for Soar, Scheme, etc." | |||
| 645 | (set-marker comint-last-input-end (point)) | 646 | (set-marker comint-last-input-end (point)) |
| 646 | (set-marker (process-mark proc) (point)))))) | 647 | (set-marker (process-mark proc) (point)))))) |
| 647 | 648 | ||
| 649 | ;; The sole purpose of using this filter for comint processes | ||
| 650 | ;; is to keep comint-last-input-end from moving forward | ||
| 651 | ;; when output is inserted. | ||
| 652 | (defun comint-filter (process string) | ||
| 653 | (let ((obuf (current-buffer)) | ||
| 654 | ordonly | ||
| 655 | opoint obeg oend) | ||
| 656 | (set-buffer (process-buffer process)) | ||
| 657 | (setq opoint (point)) | ||
| 658 | (setq obeg (point-min)) | ||
| 659 | (setq oend (point-max)) | ||
| 660 | (setq ordonly buffer-read-only) | ||
| 661 | (let ((buffer-read-only nil) | ||
| 662 | (nchars (length string))) | ||
| 663 | (widen) | ||
| 664 | (goto-char (process-mark process)) | ||
| 665 | (setq opoint (+ opoint nchars)) | ||
| 666 | ;; Insert after old_begv, but before old_zv. | ||
| 667 | (if (< (point) obeg) | ||
| 668 | (setq obeg (+ obeg nchars))) | ||
| 669 | (if (<= (point) oend) | ||
| 670 | (setq oend (+ oend nchars))) | ||
| 671 | |||
| 672 | (insert-before-markers string) | ||
| 673 | (and comint-last-input-end | ||
| 674 | (marker-buffer comint-last-input-end) | ||
| 675 | (= (point) comint-last-input-end) | ||
| 676 | (set-marker comint-last-input-end | ||
| 677 | (- comint-last-input-end nchars))) | ||
| 678 | (set-marker (process-mark process) (point) nil) | ||
| 679 | (force-mode-line-update) | ||
| 680 | |||
| 681 | (narrow-to-region obeg oend) | ||
| 682 | (setq buffer-read-only ordonly) | ||
| 683 | (goto-char opoint) | ||
| 684 | (set-buffer obuf)))) | ||
| 685 | |||
| 648 | (defun comint-get-old-input-default () | 686 | (defun comint-get-old-input-default () |
| 649 | "Default for comint-get-old-input. | 687 | "Default for comint-get-old-input. |
| 650 | Take the current line, and discard any initial text matching | 688 | Take the current line, and discard any initial text matching |