140 |
;; comint-scroll-to-bottom-on-output symbol ... |
;; comint-scroll-to-bottom-on-output symbol ... |
141 |
;; comint-scroll-show-maximum-output boolean ... |
;; comint-scroll-show-maximum-output boolean ... |
142 |
;; comint-accum-marker maker For comint-accumulate |
;; comint-accum-marker maker For comint-accumulate |
|
;; comint-last-output-overlay overlay |
|
143 |
;; |
;; |
144 |
;; Comint mode non-buffer local variables: |
;; Comint mode non-buffer local variables: |
145 |
;; comint-completion-addsuffix boolean/cons For file name |
;; comint-completion-addsuffix boolean/cons For file name |
476 |
(set (make-local-variable 'comint-last-input-start) (point-min-marker)) |
(set (make-local-variable 'comint-last-input-start) (point-min-marker)) |
477 |
(set (make-local-variable 'comint-last-input-end) (point-min-marker)) |
(set (make-local-variable 'comint-last-input-end) (point-min-marker)) |
478 |
(set (make-local-variable 'comint-last-output-start) (make-marker)) |
(set (make-local-variable 'comint-last-output-start) (make-marker)) |
|
(make-local-variable 'comint-last-output-overlay) |
|
479 |
(make-local-variable 'comint-last-prompt-overlay) |
(make-local-variable 'comint-last-prompt-overlay) |
480 |
(make-local-variable 'comint-prompt-regexp) ; Don't set; default |
(make-local-variable 'comint-prompt-regexp) ; Don't set; default |
481 |
(make-local-variable 'comint-input-ring-size) ; ...to global val. |
(make-local-variable 'comint-input-ring-size) ; ...to global val. |
766 |
(defun comint-insert-clicked-input (event) |
(defun comint-insert-clicked-input (event) |
767 |
"In a comint buffer, set the current input to the clicked-on previous input." |
"In a comint buffer, set the current input to the clicked-on previous input." |
768 |
(interactive "e") |
(interactive "e") |
769 |
(let ((over (catch 'found |
(let ((pos (posn-point (event-end event)))) |
770 |
;; Ignore non-input overlays |
(if (not (eq (get-char-property pos 'field) 'input)) |
771 |
(dolist (ov (overlays-at (posn-point (event-end event)))) |
;; No input at POS, fall back to the global definition. |
772 |
(when (eq (overlay-get ov 'field) 'input) |
(let* ((keys (this-command-keys)) |
773 |
(throw 'found ov)))))) |
(last-key (and (vectorp keys) (aref keys (1- (length keys))))) |
774 |
;; Do we have input in this area? |
(fun (and last-key (lookup-key global-map (vector last-key))))) |
775 |
(if over |
(and fun (call-interactively fun))) |
776 |
(let ((input-str (buffer-substring (overlay-start over) |
;; There's previous input at POS, insert it at the end of the buffer. |
777 |
(overlay-end over)))) |
(goto-char (point-max)) |
778 |
(goto-char (point-max)) |
;; First delete any old unsent input at the end |
779 |
(delete-region |
(delete-region |
780 |
;; Can't use kill-region as it sets this-command |
(or (marker-position comint-accum-marker) |
781 |
(or (marker-position comint-accum-marker) |
(process-mark (get-buffer-process (current-buffer)))) |
782 |
(process-mark (get-buffer-process (current-buffer)))) |
(point)) |
783 |
(point)) |
;; Insert the clicked-upon input |
784 |
(insert input-str)) |
(insert-buffer-substring |
785 |
;; Fall back to the global definition. |
(current-buffer) |
786 |
(let* ((keys (this-command-keys)) |
(previous-single-char-property-change (1+ pos) 'field) |
787 |
(last-key (and (vectorp keys) (aref keys (1- (length keys))))) |
(next-single-char-property-change pos 'field))))) |
788 |
(fun (and last-key (lookup-key global-map (vector last-key))))) |
|
|
(if fun (call-interactively fun)))))) |
|
789 |
|
|
790 |
|
|
791 |
;; Input history processing in a buffer |
;; Input history processing in a buffer |
1447 |
(let ((beg (marker-position pmark)) |
(let ((beg (marker-position pmark)) |
1448 |
(end (if no-newline (point) (1- (point))))) |
(end (if no-newline (point) (1- (point))))) |
1449 |
(when (not (> beg end)) ; handle a special case |
(when (not (> beg end)) ; handle a special case |
1450 |
;; Make an overlay for the input field |
;; Set text-properties for the input field |
1451 |
(let ((over (make-overlay beg end nil nil t))) |
(add-text-properties |
1452 |
(unless comint-use-prompt-regexp-instead-of-fields |
beg end |
1453 |
;; Give old user input a field property of `input', to |
'(front-sticky t |
1454 |
;; distinguish it from both process output and unsent |
font-lock-face comint-highlight-input |
1455 |
;; input. The terminating newline is put into a special |
mouse-face highlight |
1456 |
;; `boundary' field to make cursor movement between input |
help-echo "mouse-2: insert after prompt as new input")) |
1457 |
;; and output fields smoother. |
(unless comint-use-prompt-regexp-instead-of-fields |
1458 |
(overlay-put over 'field 'input)) |
;; Give old user input a field property of `input', to |
1459 |
(overlay-put over 'font-lock-face 'comint-highlight-input) |
;; distinguish it from both process output and unsent |
1460 |
(overlay-put over 'mouse-face 'highlight) |
;; input. The terminating newline is put into a special |
1461 |
(overlay-put over |
;; `boundary' field to make cursor movement between input |
1462 |
'help-echo |
;; and output fields smoother. |
1463 |
"mouse-2: insert after prompt as new input") |
(put-text-property beg end 'field 'input))) |
|
(overlay-put over 'evaporate t))) |
|
1464 |
(unless comint-use-prompt-regexp-instead-of-fields |
(unless comint-use-prompt-regexp-instead-of-fields |
1465 |
;; Make an overlay for the terminating newline |
;; Cover the terminating newline |
1466 |
(let ((over (make-overlay end (1+ end) nil t nil))) |
(add-text-properties end (1+ end) |
1467 |
(overlay-put over 'field 'boundary) |
'(rear-nonsticky t |
1468 |
(overlay-put over 'inhibit-line-move-field-capture t) |
field boundary |
1469 |
(overlay-put over 'evaporate t)))) |
inhibit-line-move-field-capture t)))) |
1470 |
|
|
1471 |
(comint-snapshot-last-prompt) |
(comint-snapshot-last-prompt) |
1472 |
|
|
1528 |
You can use `add-hook' to add functions to this list |
You can use `add-hook' to add functions to this list |
1529 |
either globally or locally.") |
either globally or locally.") |
1530 |
|
|
|
;; When non-nil, this is the last overlay used for output. |
|
|
;; It is kept around so that we can extend it instead of creating |
|
|
;; multiple contiguous overlays for multiple contiguous output chunks. |
|
|
(defvar comint-last-output-overlay nil) |
|
|
|
|
1531 |
;; When non-nil, this is an overlay over the last recognized prompt in |
;; When non-nil, this is an overlay over the last recognized prompt in |
1532 |
;; the buffer; it is used when highlighting the prompt. |
;; the buffer; it is used when highlighting the prompt. |
1533 |
(defvar comint-last-prompt-overlay nil) |
(defvar comint-last-prompt-overlay nil) |
1534 |
|
|
1535 |
;; `snapshot' any current comint-last-prompt-overlay, freezing it in place. |
;; `snapshot' any current comint-last-prompt-overlay, freezing its |
1536 |
;; Any further output will then create a new comint-last-prompt-overlay. |
;; attributes in place, even when more input comes a long and moves the |
1537 |
|
;; prompt overlay. |
1538 |
(defun comint-snapshot-last-prompt () |
(defun comint-snapshot-last-prompt () |
1539 |
(when comint-last-prompt-overlay |
(when comint-last-prompt-overlay |
1540 |
(overlay-put comint-last-prompt-overlay 'evaporate t) |
(add-text-properties (overlay-start comint-last-prompt-overlay) |
1541 |
(setq comint-last-prompt-overlay nil))) |
(overlay-end comint-last-prompt-overlay) |
1542 |
|
(overlay-properties comint-last-prompt-overlay)))) |
1543 |
|
|
1544 |
(defun comint-carriage-motion (string) |
(defun comint-carriage-motion (string) |
1545 |
"Handle carriage control characters in comint output. |
"Handle carriage control characters in comint output. |
1663 |
(set-marker (process-mark process) (point)) |
(set-marker (process-mark process) (point)) |
1664 |
|
|
1665 |
(unless comint-use-prompt-regexp-instead-of-fields |
(unless comint-use-prompt-regexp-instead-of-fields |
1666 |
;; We check to see if the last overlay used for output is |
(add-text-properties comint-last-output-start (point) |
1667 |
;; adjacent to the new input, and if so, just extend it. |
'(rear-nonsticky t |
1668 |
(if (and comint-last-output-overlay |
field output |
1669 |
(equal (overlay-end comint-last-output-overlay) |
inhibit-line-move-field-capture t))) |
|
(marker-position comint-last-output-start))) |
|
|
;; Extend comint-last-output-overlay to include the |
|
|
;; most recent output |
|
|
(move-overlay comint-last-output-overlay |
|
|
(overlay-start comint-last-output-overlay) |
|
|
(point)) |
|
|
;; Create a new overlay |
|
|
(let ((over (make-overlay comint-last-output-start (point)))) |
|
|
(overlay-put over 'field 'output) |
|
|
(overlay-put over 'inhibit-line-move-field-capture t) |
|
|
(overlay-put over 'evaporate t) |
|
|
(setq comint-last-output-overlay over)))) |
|
1670 |
|
|
1671 |
;; Highlight the prompt, where we define `prompt' to mean |
;; Highlight the prompt, where we define `prompt' to mean |
1672 |
;; the most recent output that doesn't end with a newline. |
;; the most recent output that doesn't end with a newline. |
1797 |
(if (eq (get-char-property bof 'field) 'input) |
(if (eq (get-char-property bof 'field) 'input) |
1798 |
(field-string bof) |
(field-string bof) |
1799 |
(comint-bol) |
(comint-bol) |
1800 |
(buffer-substring (point) (line-end-position))))) |
(buffer-substring-no-properties (point) (line-end-position))))) |
1801 |
|
|
1802 |
(defun comint-copy-old-input () |
(defun comint-copy-old-input () |
1803 |
"Insert after prompt old input at point as new input to be edited. |
"Insert after prompt old input at point as new input to be edited. |
2385 |
(and (search-forward "\"" eol t) |
(and (search-forward "\"" eol t) |
2386 |
(1- (point)))))) |
(1- (point)))))) |
2387 |
(and start end |
(and start end |
2388 |
(buffer-substring start end))))) |
(buffer-substring-no-properties start end))))) |
2389 |
|
|
2390 |
(defun comint-get-source (prompt prev-dir/file source-modes mustmatch-p) |
(defun comint-get-source (prompt prev-dir/file source-modes mustmatch-p) |
2391 |
(let* ((def (comint-source-default prev-dir/file source-modes)) |
(let* ((def (comint-source-default prev-dir/file source-modes)) |