Mercurial > hg > xemacs-beta
comparison lisp/comint/comint.el @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | 56c54cf7c5b6 |
children | 360340f9fd5f |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
352 (put 'comint-output-filter-functions 'permanent-local t) | 352 (put 'comint-output-filter-functions 'permanent-local t) |
353 (put 'comint-scroll-to-bottom-on-input 'permanent-local t) | 353 (put 'comint-scroll-to-bottom-on-input 'permanent-local t) |
354 (put 'comint-scroll-to-bottom-on-output 'permanent-local t) | 354 (put 'comint-scroll-to-bottom-on-output 'permanent-local t) |
355 (put 'comint-scroll-show-maximum-output 'permanent-local t) | 355 (put 'comint-scroll-show-maximum-output 'permanent-local t) |
356 (put 'comint-ptyp 'permanent-local t) | 356 (put 'comint-ptyp 'permanent-local t) |
357 | |
358 | |
359 | 357 |
360 (defun comint-mode () | 358 (defun comint-mode () |
361 "Major mode for interacting with an inferior interpreter. | 359 "Major mode for interacting with an inferior interpreter. |
362 Interpreter name is same as buffer name, sans the asterisks. | 360 Interpreter name is same as buffer name, sans the asterisks. |
363 Return at end of buffer sends line as input. | 361 Return at end of buffer sends line as input. |
536 ["Complete Env. Variable Name" shell-dynamic-complete-environment-variable | 534 ["Complete Env. Variable Name" shell-dynamic-complete-environment-variable |
537 :active t :included (eq 'shell-mode major-mode)] | 535 :active t :included (eq 'shell-mode major-mode)] |
538 ["Expand Directory Reference" shell-replace-by-expanded-directory | 536 ["Expand Directory Reference" shell-replace-by-expanded-directory |
539 :active t :included (eq 'shell-mode major-mode)] | 537 :active t :included (eq 'shell-mode major-mode)] |
540 "---" | 538 "---" |
541 ["Send INT" comint-interrupt-subjob t] | 539 ["Send INT" comint-interrupt-subjob t] |
542 ["Send STOP" comint-stop-subjob t] | 540 ["Send STOP" comint-stop-subjob t] |
543 ["Send CONT" comint-continue-subjob t] | 541 ["Send CONT" comint-continue-subjob t] |
544 ["Send QUIT" comint-quit-subjob t] | 542 ["Send QUIT" comint-quit-subjob t] |
545 ["Send KILL" comint-kill-subjob t] | 543 ["Send KILL" comint-kill-subjob t] |
546 ["Send EOF" comint-send-eof t] | 544 ["Send EOF" comint-send-eof t] |
567 ["Next Input" comint-next-matching-input-from-input t] | 565 ["Next Input" comint-next-matching-input-from-input t] |
568 ["Previous Input matching Regexp..." 'comint-previous-matching-input t] | 566 ["Previous Input matching Regexp..." 'comint-previous-matching-input t] |
569 ["Next Input matching Regexp..." 'comint-next-matching-input t] | 567 ["Next Input matching Regexp..." 'comint-next-matching-input t] |
570 ["List Command History" comint-dynamic-list-input-ring t] | 568 ["List Command History" comint-dynamic-list-input-ring t] |
571 "----" | 569 "----" |
572 ["Send INT" comint-interrupt-subjob t] | 570 ["Send INT" comint-interrupt-subjob t] |
573 ["Send STOP" comint-stop-subjob t] | 571 ["Send STOP" comint-stop-subjob t] |
574 ["Send CONT" comint-continue-subjob t] | 572 ["Send CONT" comint-continue-subjob t] |
575 ["Send QUIT" comint-quit-subjob t] | 573 ["Send QUIT" comint-quit-subjob t] |
576 ["Send KILL" comint-kill-subjob t] | 574 ["Send KILL" comint-kill-subjob t] |
577 ["Send EOF" comint-send-eof t] | 575 ["Send EOF" comint-send-eof t] |
588 | 586 |
589 (defvar comint-history-menu-max 40 | 587 (defvar comint-history-menu-max 40 |
590 "*Maximum number of entries to display on the Comint command-history menu.") | 588 "*Maximum number of entries to display on the Comint command-history menu.") |
591 | 589 |
592 (defun comint-history-menu-filter (menu) | 590 (defun comint-history-menu-filter (menu) |
593 (let ((histmenu (comint-make-history-menu))) | 591 (append menu (comint-make-history-menu))) |
594 (append menu histmenu))) | |
595 | 592 |
596 (defun comint-make-history-menu () | 593 (defun comint-make-history-menu () |
597 (if (or (not (ring-p comint-input-ring)) | 594 (if (or (not (ring-p comint-input-ring)) |
598 (ring-empty-p comint-input-ring)) | 595 (ring-empty-p comint-input-ring)) |
599 nil | 596 nil |
600 (let ((menu nil) | 597 (let ((menu nil) |
601 hist | 598 hist |
602 (index (1- (ring-length comint-input-ring))) | 599 (index (1- (ring-length comint-input-ring))) |
603 (count 0)) | 600 (count 0)) |
604 ;; We have to build up a list ourselves from the ring vector. | 601 ;; We have to build up a list ourselves from the ring vector. |
602 ;; We don't want the entries to get translated in a Mule | |
603 ;; environment, so we use the `suffix' field of the menu entries. | |
605 (while (and (>= index 0) | 604 (while (and (>= index 0) |
606 (and comint-history-menu-max | 605 (and comint-history-menu-max |
607 (< count comint-history-menu-max))) | 606 (< count comint-history-menu-max))) |
608 (setq hist (ring-ref comint-input-ring index) | 607 (setq hist (ring-ref comint-input-ring index) |
609 menu (cons (vector hist (list 'comint-menu-history hist) t) | 608 menu (cons (vector "" (list 'comint-menu-history hist) t hist) |
610 menu) | 609 menu) |
611 count (1+ count) | 610 count (1+ count) |
612 index (1- index))) | 611 index (1- index))) |
613 menu))) | 612 menu))) |
614 | 613 |
1032 See `comint-magic-space' and `comint-replace-by-expanded-history-before-point'. | 1031 See `comint-magic-space' and `comint-replace-by-expanded-history-before-point'. |
1033 | 1032 |
1034 Returns t if successful." | 1033 Returns t if successful." |
1035 (interactive) | 1034 (interactive) |
1036 (if (and comint-input-autoexpand | 1035 (if (and comint-input-autoexpand |
1037 (string-match "!\\|^\\^" (funcall comint-get-old-input)) | 1036 (string-match "[!^]" (funcall comint-get-old-input)) |
1038 (save-excursion (beginning-of-line) | 1037 (save-excursion (beginning-of-line) |
1039 (looking-at comint-prompt-regexp))) | 1038 (looking-at comint-prompt-regexp))) |
1040 ;; Looks like there might be history references in the command. | 1039 ;; Looks like there might be history references in the command. |
1041 (let ((previous-modified-tick (buffer-modified-tick))) | 1040 (let ((previous-modified-tick (buffer-modified-tick))) |
1042 (message "Expanding history references...") | 1041 (message "Expanding history references...") |
1346 ;; Update the markers before we send the input | 1345 ;; Update the markers before we send the input |
1347 ;; in case we get output amidst sending the input. | 1346 ;; in case we get output amidst sending the input. |
1348 (set-marker comint-last-input-start pmark) | 1347 (set-marker comint-last-input-start pmark) |
1349 (set-marker comint-last-input-end (point)) | 1348 (set-marker comint-last-input-end (point)) |
1350 (set-marker (process-mark proc) (point)) | 1349 (set-marker (process-mark proc) (point)) |
1351 (comint-input-done) | |
1352 (funcall comint-input-sender proc input) | 1350 (funcall comint-input-sender proc input) |
1353 (comint-input-setup) | |
1354 ;; XEmacs - A kludge to prevent the delay between insert and | 1351 ;; XEmacs - A kludge to prevent the delay between insert and |
1355 ;; process output affecting the display. A case for a | 1352 ;; process output affecting the display. A case for a |
1356 ;; comint-send-input-hook? | 1353 ;; comint-send-input-hook? |
1357 (run-hook-with-args 'comint-output-filter-functions | 1354 (run-hook-with-args 'comint-output-filter-functions |
1358 (concat input "\n")) | 1355 (concat input "\n")) |
1359 (comint-output-filter proc "") | 1356 (comint-output-filter proc "") |
1360 ))))) | 1357 ))))) |
1361 (defun comint-input-done () | |
1362 "Finalized comint-input-extent so nothing more is added." | |
1363 (if (not comint-input-extent) | |
1364 (comint-input-setup)) | |
1365 (set-extent-property comint-input-extent 'start-closed nil) | |
1366 (set-extent-property comint-input-extent 'end-closed nil) | |
1367 (set-extent-property comint-input-extent 'detachable t) | |
1368 ) | |
1369 | |
1370 (defun comint-input-setup () | |
1371 "Insure the comint-input-extent is ready." | |
1372 (require 'comint-xemacs) | |
1373 (setq comint-input-extent (make-extent (point) (point-max))) | |
1374 (set-extent-property comint-input-extent 'detachable nil) | |
1375 (set-extent-property comint-input-extent 'start-closed t) | |
1376 (set-extent-property comint-input-extent 'end-closed t) | |
1377 (set-extent-face comint-input-extent 'comint-input-face) | |
1378 ) | |
1379 | |
1380 (defvar comint-input-extent nil | |
1381 "Current extent used for displaying text in buffer."); | |
1382 (make-variable-buffer-local 'comint-input-extent) | |
1383 | 1358 |
1384 ;; The purpose of using this filter for comint processes | 1359 ;; The purpose of using this filter for comint processes |
1385 ;; is to keep comint-last-input-end from moving forward | 1360 ;; is to keep comint-last-input-end from moving forward |
1386 ;; when output is inserted. | 1361 ;; when output is inserted. |
1387 (defun comint-output-filter (process string) | 1362 (defun comint-output-filter (process string) |
1393 (set-buffer oprocbuf) | 1368 (set-buffer oprocbuf) |
1394 (setq string (replace-in-string string "\^M" "") | 1369 (setq string (replace-in-string string "\^M" "") |
1395 opoint (point) | 1370 opoint (point) |
1396 obeg (point-min) | 1371 obeg (point-min) |
1397 oend (point-max)) | 1372 oend (point-max)) |
1398 ;; Keep stuff being output (before input) from using input-extent | |
1399 (if comint-input-extent | |
1400 (set-extent-property comint-input-extent 'start-closed nil)) | |
1401 (let ((buffer-read-only nil) | 1373 (let ((buffer-read-only nil) |
1402 (nchars (length string)) | 1374 (nchars (length string)) |
1403 (ostart nil)) | 1375 (ostart nil)) |
1404 (widen) | 1376 (widen) |
1405 (goto-char (process-mark process)) | 1377 (goto-char (process-mark process)) |
1420 (= (point) comint-last-input-end)) | 1392 (= (point) comint-last-input-end)) |
1421 (set-marker comint-last-input-end (- comint-last-input-end nchars))) | 1393 (set-marker comint-last-input-end (- comint-last-input-end nchars))) |
1422 (set-marker comint-last-output-start ostart) | 1394 (set-marker comint-last-output-start ostart) |
1423 (set-marker (process-mark process) (point)) | 1395 (set-marker (process-mark process) (point)) |
1424 (redraw-modeline)) | 1396 (redraw-modeline)) |
1425 ;; Now insure everything inserted after (user input) is in extent | |
1426 (if (not comint-input-extent) | |
1427 (comint-input-setup)) | |
1428 (set-extent-endpoints comint-input-extent (point) (point-max)) | |
1429 (set-extent-property comint-input-extent 'start-closed t) | |
1430 | 1397 |
1431 (narrow-to-region obeg oend) | 1398 (narrow-to-region obeg oend) |
1432 (goto-char opoint) | 1399 (goto-char opoint) |
1433 (run-hook-with-args 'comint-output-filter-functions string) | 1400 (run-hook-with-args 'comint-output-filter-functions string) |
1434 (set-buffer obuf))))) | 1401 (set-buffer obuf))))) |
2029 ;;; | 1996 ;;; |
2030 ;;; Commands like this are fine things to put in load hooks if you | 1997 ;;; Commands like this are fine things to put in load hooks if you |
2031 ;;; want them present in specific modes. | 1998 ;;; want them present in specific modes. |
2032 | 1999 |
2033 (defvar comint-completion-autolist nil | 2000 (defvar comint-completion-autolist nil |
2034 "*If non-nil, automatically list possibilities on partial completion. | 2001 "*If non-nil, automatically list possiblities on partial completion. |
2035 This mirrors the optional behavior of tcsh.") | 2002 This mirrors the optional behavior of tcsh.") |
2036 | 2003 |
2037 (defvar comint-completion-addsuffix t | 2004 (defvar comint-completion-addsuffix t |
2038 "*If non-nil, add a `/' to completed directories, ` ' to file names. | 2005 "*If non-nil, add a `/' to completed directories, ` ' to file names. |
2039 If a cons pair, it should be of the form (DIRSUFFIX . FILESUFFIX) where | 2006 If a cons pair, it should be of the form (DIRSUFFIX . FILESUFFIX) where |