Mercurial > emacs
comparison lisp/comint.el @ 2683:21ab70613c42
(comint-filter): New function.
(comint-exec): Install the filter.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 06 May 1993 19:51:08 +0000 |
parents | ac4af95b962f |
children | 305044e75269 |
comparison
equal
deleted
inserted
replaced
2682:866fefc5d52b | 2683:21ab70613c42 |
---|---|
328 (set-buffer buffer) | 328 (set-buffer buffer) |
329 (let ((proc (get-buffer-process buffer))) ; Blast any old process. | 329 (let ((proc (get-buffer-process buffer))) ; Blast any old process. |
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. |
336 (goto-char (point-max)) | 337 (goto-char (point-max)) |
337 (set-marker (process-mark proc) (point)) | 338 (set-marker (process-mark proc) (point)) |
592 After the process output mark, sends all text from the process mark to | 593 After the process output mark, sends all text from the process mark to |
593 point as input to the process. Before the process output mark, calls value | 594 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 |
601 `comint-input-filter' returns non-`nil' when called on the input. | 602 `comint-input-filter' returns non-`nil' when called on the input. |
602 | 603 |
642 (funcall comint-input-sender proc input) | 643 (funcall comint-input-sender proc input) |
643 (setq comint-input-ring-index nil) | 644 (setq comint-input-ring-index nil) |
644 (set-marker comint-last-input-start pmark) | 645 (set-marker comint-last-input-start pmark) |
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)))))) |
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)))) | |
647 | 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 |
651 comint-prompt-regexp." | 689 comint-prompt-regexp." |