diff options
| author | Miles Bader | 2000-08-10 13:07:25 +0000 |
|---|---|---|
| committer | Miles Bader | 2000-08-10 13:07:25 +0000 |
| commit | 867102f2b8b360d7ddf745e994f6b17e6b833833 (patch) | |
| tree | 5fd949c92b60747babcf5024ef5e3bc5a7352d2d | |
| parent | af71853819d9f8a7d059fb34ed754754eba1d313 (diff) | |
| download | emacs-867102f2b8b360d7ddf745e994f6b17e6b833833.tar.gz emacs-867102f2b8b360d7ddf745e994f6b17e6b833833.zip | |
(comint-output-filter): Doc fixes & misc code cleanup.
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/comint.el | 146 |
2 files changed, 80 insertions, 70 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a1a1b7b1a08..8cb6d664b06 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2000-08-10 Miles Bader <miles@gnu.org> | ||
| 2 | |||
| 3 | * comint.el (comint-output-filter): Doc fixes & misc code cleanup. | ||
| 4 | |||
| 1 | 2000-08-10 Eli Zaretskii <eliz@is.elta.co.il> | 5 | 2000-08-10 Eli Zaretskii <eliz@is.elta.co.il> |
| 2 | 6 | ||
| 3 | * info.el (Info-file-list-for-emacs): More elements for the | 7 | * info.el (Info-file-list-for-emacs): More elements for the |
diff --git a/lisp/comint.el b/lisp/comint.el index 21e318e2112..f890090c29a 100644 --- a/lisp/comint.el +++ b/lisp/comint.el | |||
| @@ -1487,83 +1487,89 @@ This variable is permanent-local.") | |||
| 1487 | ;; First check for killed buffer or no input. | 1487 | ;; First check for killed buffer or no input. |
| 1488 | (when (and string oprocbuf (buffer-name oprocbuf)) | 1488 | (when (and string oprocbuf (buffer-name oprocbuf)) |
| 1489 | (with-current-buffer oprocbuf | 1489 | (with-current-buffer oprocbuf |
| 1490 | ;; Run preoutput filters | ||
| 1490 | (let ((functions comint-preoutput-filter-functions)) | 1491 | (let ((functions comint-preoutput-filter-functions)) |
| 1491 | (while (and functions string) | 1492 | (while (and functions string) |
| 1492 | (setq string (funcall (car functions) string)) | 1493 | (setq string (funcall (car functions) string)) |
| 1493 | (setq functions (cdr functions)))) | 1494 | (setq functions (cdr functions)))) |
| 1494 | (let (opoint obeg oend) | ||
| 1495 | (setq opoint (point)) | ||
| 1496 | (setq obeg (point-min)) | ||
| 1497 | (setq oend (point-max)) | ||
| 1498 | (let ((buffer-read-only nil) | ||
| 1499 | (nchars (length string)) | ||
| 1500 | (ostart nil)) | ||
| 1501 | (widen) | ||
| 1502 | (goto-char (process-mark process)) | ||
| 1503 | (setq ostart (point)) | ||
| 1504 | (if (<= (point) opoint) | ||
| 1505 | (setq opoint (+ opoint nchars))) | ||
| 1506 | ;; Insert after old_begv, but before old_zv. | ||
| 1507 | (if (< (point) obeg) | ||
| 1508 | (setq obeg (+ obeg nchars))) | ||
| 1509 | (if (<= (point) oend) | ||
| 1510 | (setq oend (+ oend nchars))) | ||
| 1511 | |||
| 1512 | (insert string) | ||
| 1513 | |||
| 1514 | (unless comint-use-prompt-regexp-instead-of-fields | ||
| 1515 | ;; We check to see if the last overlay used for output has | ||
| 1516 | ;; already been extended to include STRING (because it was | ||
| 1517 | ;; inserted with insert-before-markers?), and only make | ||
| 1518 | ;; a new overlay if it hasn't. | ||
| 1519 | (if (and comint-last-output-overlay | ||
| 1520 | (equal (overlay-end comint-last-output-overlay) ostart)) | ||
| 1521 | ;; Extend comint-last-output-overlay to include the | ||
| 1522 | ;; most recent output | ||
| 1523 | (move-overlay comint-last-output-overlay | ||
| 1524 | (overlay-start comint-last-output-overlay) | ||
| 1525 | (point)) | ||
| 1526 | ;; Create a new overlay | ||
| 1527 | (let ((over (make-overlay ostart (point)))) | ||
| 1528 | (overlay-put over 'field 'output) | ||
| 1529 | (overlay-put over 'rear-nonsticky t) | ||
| 1530 | (overlay-put over 'inhibit-line-move-field-capture t) | ||
| 1531 | (overlay-put over 'evaporate t) | ||
| 1532 | (setq comint-last-output-overlay over)))) | ||
| 1533 | |||
| 1534 | (when comint-highlight-prompt | ||
| 1535 | ;; Highlight the prompt, where we define `prompt' to mean | ||
| 1536 | ;; the most recent output that doesn't end with a newline. | ||
| 1537 | (unless (and (bolp) (null comint-last-prompt-overlay)) | ||
| 1538 | ;; Need to create or move the prompt overlay (in the | ||
| 1539 | ;; case where's no prompt ((bolp) == t), we still do | ||
| 1540 | ;; this if there's already an existing overlay. | ||
| 1541 | (let ((prompt-start (save-excursion (forward-line 0) (point)))) | ||
| 1542 | (if comint-last-prompt-overlay | ||
| 1543 | ;; Just move an existing overlay | ||
| 1544 | (move-overlay comint-last-prompt-overlay | ||
| 1545 | prompt-start (point)) | ||
| 1546 | ;; Need to create the overlay | ||
| 1547 | (setq comint-last-prompt-overlay | ||
| 1548 | (make-overlay prompt-start (point))) | ||
| 1549 | (overlay-put comint-last-prompt-overlay | ||
| 1550 | 'rear-nonsticky t) | ||
| 1551 | (overlay-put comint-last-prompt-overlay | ||
| 1552 | 'face 'comint-highlight-prompt-face))))) | ||
| 1553 | |||
| 1554 | ;; Don't insert initial prompt outside the top of the window. | ||
| 1555 | (if (= (window-start (selected-window)) (point)) | ||
| 1556 | (set-window-start (selected-window) (- (point) (length string)))) | ||
| 1557 | (if (and comint-last-input-end | ||
| 1558 | (marker-buffer comint-last-input-end) | ||
| 1559 | (= (point) comint-last-input-end)) | ||
| 1560 | (set-marker comint-last-input-end (- comint-last-input-end nchars))) | ||
| 1561 | (set-marker comint-last-output-start ostart) | ||
| 1562 | (set-marker (process-mark process) (point)) | ||
| 1563 | (force-mode-line-update)) | ||
| 1564 | 1495 | ||
| 1496 | ;; Do insertion. We don't use save-restriction because it has a | ||
| 1497 | ;; bug, so we fake it by saving any current restriction, and | ||
| 1498 | ;; then later restoring it. | ||
| 1499 | (let ((opoint (point)) | ||
| 1500 | (obeg (point-min)) | ||
| 1501 | (oend (point-max)) | ||
| 1502 | (buffer-read-only nil) | ||
| 1503 | (nchars (length string)) | ||
| 1504 | (ostart (process-mark process))) | ||
| 1505 | (widen) | ||
| 1506 | (goto-char ostart) | ||
| 1507 | |||
| 1508 | ;; Adjust buffer positions to account for about-to-be-inserted text | ||
| 1509 | (if (<= (point) opoint) | ||
| 1510 | (setq opoint (+ opoint nchars))) | ||
| 1511 | ;; Insert after old_begv, but before old_zv. | ||
| 1512 | (if (< (point) obeg) | ||
| 1513 | (setq obeg (+ obeg nchars))) | ||
| 1514 | (if (<= (point) oend) | ||
| 1515 | (setq oend (+ oend nchars))) | ||
| 1516 | |||
| 1517 | (insert string) | ||
| 1518 | |||
| 1519 | (unless comint-use-prompt-regexp-instead-of-fields | ||
| 1520 | ;; We check to see if the last overlay used for output is | ||
| 1521 | ;; adjacent to the new input, and if so, just extend it. | ||
| 1522 | (if (and comint-last-output-overlay | ||
| 1523 | (equal (overlay-end comint-last-output-overlay) ostart)) | ||
| 1524 | ;; Extend comint-last-output-overlay to include the | ||
| 1525 | ;; most recent output | ||
| 1526 | (move-overlay comint-last-output-overlay | ||
| 1527 | (overlay-start comint-last-output-overlay) | ||
| 1528 | (point)) | ||
| 1529 | ;; Create a new overlay | ||
| 1530 | (let ((over (make-overlay ostart (point)))) | ||
| 1531 | (overlay-put over 'field 'output) | ||
| 1532 | (overlay-put over 'rear-nonsticky t) | ||
| 1533 | (overlay-put over 'inhibit-line-move-field-capture t) | ||
| 1534 | (overlay-put over 'evaporate t) | ||
| 1535 | (setq comint-last-output-overlay over)))) | ||
| 1536 | |||
| 1537 | (when comint-highlight-prompt | ||
| 1538 | ;; Highlight the prompt, where we define `prompt' to mean | ||
| 1539 | ;; the most recent output that doesn't end with a newline. | ||
| 1540 | (unless (and (bolp) (null comint-last-prompt-overlay)) | ||
| 1541 | ;; Need to create or move the prompt overlay (in the | ||
| 1542 | ;; case where's no prompt ((bolp) == t), we still do | ||
| 1543 | ;; this if there's already an existing overlay. | ||
| 1544 | (let ((prompt-start (save-excursion (forward-line 0) (point)))) | ||
| 1545 | (if comint-last-prompt-overlay | ||
| 1546 | ;; Just move an existing overlay | ||
| 1547 | (move-overlay comint-last-prompt-overlay | ||
| 1548 | prompt-start (point)) | ||
| 1549 | ;; Need to create the overlay | ||
| 1550 | (setq comint-last-prompt-overlay | ||
| 1551 | (make-overlay prompt-start (point))) | ||
| 1552 | (overlay-put comint-last-prompt-overlay | ||
| 1553 | 'rear-nonsticky t) | ||
| 1554 | (overlay-put comint-last-prompt-overlay | ||
| 1555 | 'face 'comint-highlight-prompt-face))))) | ||
| 1556 | |||
| 1557 | ;; Don't insert initial prompt outside the top of the window. | ||
| 1558 | (if (= (window-start (selected-window)) (point)) | ||
| 1559 | (set-window-start (selected-window) (- (point) (length string)))) | ||
| 1560 | (if (and comint-last-input-end | ||
| 1561 | (marker-buffer comint-last-input-end) | ||
| 1562 | (= (point) comint-last-input-end)) | ||
| 1563 | (set-marker comint-last-input-end | ||
| 1564 | (- comint-last-input-end nchars))) | ||
| 1565 | (set-marker comint-last-output-start ostart) | ||
| 1566 | (set-marker (process-mark process) (point)) | ||
| 1567 | (force-mode-line-update) | ||
| 1568 | |||
| 1569 | ;; Restore our saved restriction, and the point | ||
| 1565 | (narrow-to-region obeg oend) | 1570 | (narrow-to-region obeg oend) |
| 1566 | (goto-char opoint) | 1571 | (goto-char opoint) |
| 1572 | |||
| 1567 | (run-hook-with-args 'comint-output-filter-functions string)))))) | 1573 | (run-hook-with-args 'comint-output-filter-functions string)))))) |
| 1568 | 1574 | ||
| 1569 | (defun comint-preinput-scroll-to-bottom () | 1575 | (defun comint-preinput-scroll-to-bottom () |