diff options
| author | Miles Bader | 2000-08-19 01:55:40 +0000 |
|---|---|---|
| committer | Miles Bader | 2000-08-19 01:55:40 +0000 |
| commit | d8d972bf49a45f00663c94b4457966cb3bf4501b (patch) | |
| tree | 20ea94310ec8f6995a1bdd8a932091ef881af9fe | |
| parent | 527083d575f13da741c07e6423fcdf9b69142fea (diff) | |
| download | emacs-d8d972bf49a45f00663c94b4457966cb3bf4501b.tar.gz emacs-d8d972bf49a45f00663c94b4457966cb3bf4501b.zip | |
(comint-output-filter): Remove ad-hoc saving of restriction, and just
use save-restriction, now that it works correctly. Don't adjust
comint-last-input-start to account for our insertion; it shouldn't have
moved because we don't use insert-before-markers anymore. Comment out
call to `force-mode-line-update'; why is it here?
| -rw-r--r-- | lisp/comint.el | 137 |
1 files changed, 62 insertions, 75 deletions
diff --git a/lisp/comint.el b/lisp/comint.el index da9e2797749..84e4f54949b 100644 --- a/lisp/comint.el +++ b/lisp/comint.el | |||
| @@ -1493,81 +1493,68 @@ This variable is permanent-local.") | |||
| 1493 | (setq string (funcall (car functions) string)) | 1493 | (setq string (funcall (car functions) string)) |
| 1494 | (setq functions (cdr functions)))) | 1494 | (setq functions (cdr functions)))) |
| 1495 | 1495 | ||
| 1496 | ;; Do insertion. We don't use save-restriction because it has a | 1496 | ;; Insert STRING |
| 1497 | ;; bug, so we fake it by saving any current restriction, and | 1497 | (let ((buffer-read-only nil) |
| 1498 | ;; then later restoring it. | 1498 | ;; Avoid the overhead of save-excursion, since we just |
| 1499 | (let ((opoint (point)) | 1499 | ;; fiddle with the point |
| 1500 | (obeg (point-min)) | 1500 | (saved-point (point))) |
| 1501 | (oend (point-max)) | 1501 | |
| 1502 | (buffer-read-only nil) | 1502 | ;; We temporarly remove any buffer narrowing, in case the |
| 1503 | (nchars (length string)) | 1503 | ;; process mark is outside of the restriction |
| 1504 | (ostart (process-mark process))) | 1504 | (save-restriction |
| 1505 | (widen) | 1505 | (widen) |
| 1506 | (goto-char ostart) | 1506 | |
| 1507 | 1507 | (goto-char (process-mark process)) | |
| 1508 | ;; Adjust buffer positions to account for about-to-be-inserted text | 1508 | (set-marker comint-last-output-start (point)) |
| 1509 | (if (<= (point) opoint) | 1509 | |
| 1510 | (setq opoint (+ opoint nchars))) | 1510 | (insert string) |
| 1511 | ;; Insert after old_begv, but before old_zv. | 1511 | |
| 1512 | (if (< (point) obeg) | 1512 | (set-marker (process-mark process) (point)) |
| 1513 | (setq obeg (+ obeg nchars))) | 1513 | |
| 1514 | (if (<= (point) oend) | 1514 | (unless comint-use-prompt-regexp-instead-of-fields |
| 1515 | (setq oend (+ oend nchars))) | 1515 | ;; We check to see if the last overlay used for output is |
| 1516 | 1516 | ;; adjacent to the new input, and if so, just extend it. | |
| 1517 | (insert string) | 1517 | (if (and comint-last-output-overlay |
| 1518 | 1518 | (equal (overlay-end comint-last-output-overlay) | |
| 1519 | (unless comint-use-prompt-regexp-instead-of-fields | 1519 | (point))) |
| 1520 | ;; We check to see if the last overlay used for output is | 1520 | ;; Extend comint-last-output-overlay to include the |
| 1521 | ;; adjacent to the new input, and if so, just extend it. | 1521 | ;; most recent output |
| 1522 | (if (and comint-last-output-overlay | 1522 | (move-overlay comint-last-output-overlay |
| 1523 | (equal (overlay-end comint-last-output-overlay) ostart)) | 1523 | (overlay-start comint-last-output-overlay) |
| 1524 | ;; Extend comint-last-output-overlay to include the | 1524 | (point)) |
| 1525 | ;; most recent output | 1525 | ;; Create a new overlay |
| 1526 | (move-overlay comint-last-output-overlay | 1526 | (let ((over (make-overlay comint-last-output-start (point)))) |
| 1527 | (overlay-start comint-last-output-overlay) | 1527 | (overlay-put over 'field 'output) |
| 1528 | (point)) | 1528 | (overlay-put over 'rear-nonsticky t) |
| 1529 | ;; Create a new overlay | 1529 | (overlay-put over 'inhibit-line-move-field-capture t) |
| 1530 | (let ((over (make-overlay ostart (point)))) | 1530 | (overlay-put over 'evaporate t) |
| 1531 | (overlay-put over 'field 'output) | 1531 | (setq comint-last-output-overlay over)))) |
| 1532 | (overlay-put over 'rear-nonsticky t) | 1532 | |
| 1533 | (overlay-put over 'inhibit-line-move-field-capture t) | 1533 | (when comint-highlight-prompt |
| 1534 | (overlay-put over 'evaporate t) | 1534 | ;; Highlight the prompt, where we define `prompt' to mean |
| 1535 | (setq comint-last-output-overlay over)))) | 1535 | ;; the most recent output that doesn't end with a newline. |
| 1536 | 1536 | (unless (and (bolp) (null comint-last-prompt-overlay)) | |
| 1537 | (when comint-highlight-prompt | 1537 | ;; Need to create or move the prompt overlay (in the case |
| 1538 | ;; Highlight the prompt, where we define `prompt' to mean | 1538 | ;; where there is no prompt ((bolp) == t), we still do |
| 1539 | ;; the most recent output that doesn't end with a newline. | 1539 | ;; this if there's already an existing overlay). |
| 1540 | (unless (and (bolp) (null comint-last-prompt-overlay)) | 1540 | (let ((prompt-start (save-excursion (forward-line 0) (point)))) |
| 1541 | ;; Need to create or move the prompt overlay (in the case | 1541 | (if comint-last-prompt-overlay |
| 1542 | ;; where there is no prompt ((bolp) == t), we still do | 1542 | ;; Just move an existing overlay |
| 1543 | ;; this if there's already an existing overlay). | 1543 | (move-overlay comint-last-prompt-overlay |
| 1544 | (let ((prompt-start (save-excursion (forward-line 0) (point)))) | 1544 | prompt-start (point)) |
| 1545 | (if comint-last-prompt-overlay | 1545 | ;; Need to create the overlay |
| 1546 | ;; Just move an existing overlay | 1546 | (setq comint-last-prompt-overlay |
| 1547 | (move-overlay comint-last-prompt-overlay | 1547 | (make-overlay prompt-start (point))) |
| 1548 | prompt-start (point)) | 1548 | (overlay-put comint-last-prompt-overlay |
| 1549 | ;; Need to create the overlay | 1549 | 'rear-nonsticky t) |
| 1550 | (setq comint-last-prompt-overlay | 1550 | (overlay-put comint-last-prompt-overlay |
| 1551 | (make-overlay prompt-start (point))) | 1551 | 'face 'comint-highlight-prompt-face))))) |
| 1552 | (overlay-put comint-last-prompt-overlay | 1552 | |
| 1553 | 'rear-nonsticky t) | 1553 | ;;(force-mode-line-update) |
| 1554 | (overlay-put comint-last-prompt-overlay | 1554 | |
| 1555 | 'face 'comint-highlight-prompt-face))))) | 1555 | (goto-char saved-point) |
| 1556 | 1556 | ||
| 1557 | (if (and comint-last-input-end | 1557 | (run-hook-with-args 'comint-output-filter-functions string))))))) |
| 1558 | (marker-buffer comint-last-input-end) | ||
| 1559 | (= (point) comint-last-input-end)) | ||
| 1560 | (set-marker comint-last-input-end | ||
| 1561 | (- comint-last-input-end nchars))) | ||
| 1562 | (set-marker comint-last-output-start ostart) | ||
| 1563 | (set-marker (process-mark process) (point)) | ||
| 1564 | (force-mode-line-update) | ||
| 1565 | |||
| 1566 | ;; Restore our saved restriction, and the point | ||
| 1567 | (narrow-to-region obeg oend) | ||
| 1568 | (goto-char opoint) | ||
| 1569 | |||
| 1570 | (run-hook-with-args 'comint-output-filter-functions string)))))) | ||
| 1571 | 1558 | ||
| 1572 | (defun comint-preinput-scroll-to-bottom () | 1559 | (defun comint-preinput-scroll-to-bottom () |
| 1573 | "Go to the end of buffer in all windows showing it. | 1560 | "Go to the end of buffer in all windows showing it. |