/[emacs]/emacs/lisp/comint.el
ViewVC logotype

Diff of /emacs/lisp/comint.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.289.2.3 by miles, Tue Jun 29 16:44:52 2004 UTC revision 1.289.2.4 by miles, Thu Oct 14 08:50:01 2004 UTC
# Line 1  Line 1 
1  ;;; comint.el --- general command interpreter in a window stuff  ;;; comint.el --- general command interpreter in a window stuff
2    
3  ;; Copyright (C) 1988,90,92,93,94,95,96,97,98,99,2000,01,02,03,2004  ;; Copyright (C) 1988, 1990, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4  ;;      Free Software Foundation, Inc.  ;;   2000, 2001, 2002, 2003, 2004  Free Software Foundation, Inc.
5    
6  ;; Author: Olin Shivers <shivers@cs.cmu.edu>  ;; Author: Olin Shivers <shivers@cs.cmu.edu>
7  ;;      Simon Marshall <simon@gnu.org>  ;;      Simon Marshall <simon@gnu.org>
# Line 185  the remaining prompts will be accidental Line 185  the remaining prompts will be accidental
185  wish to put something like the following in your `.emacs' file:  wish to put something like the following in your `.emacs' file:
186    
187  \(add-hook 'comint-mode-hook  \(add-hook 'comint-mode-hook
188            '(lambda ()            (lambda ()
189               (define-key comint-mode-map \"\C-w\" 'comint-kill-region)              (define-key comint-mode-map \"\C-w\" 'comint-kill-region)
190               (define-key comint-mode-map [C-S-backspace]              (define-key comint-mode-map [C-S-backspace]
191                 'comint-kill-whole-line)))                'comint-kill-whole-line)))
192    
193  If you sometimes use comint-mode on text-only terminals or with `emacs-nw',  If you sometimes use comint-mode on text-only terminals or with `emacs-nw',
194  you might wish to use another binding for `comint-kill-whole-line'."  you might wish to use another binding for `comint-kill-whole-line'."
# Line 369  Takes one argument, the input.  If non-n Line 369  Takes one argument, the input.  If non-n
369  history list.  Default is to save anything that isn't all whitespace.")  history list.  Default is to save anything that isn't all whitespace.")
370    
371  (defvar comint-input-filter-functions '()  (defvar comint-input-filter-functions '()
372    "Functions to call before input is sent to the process.    "Special hook run before input is sent to the process.
373  These functions get one argument, a string containing the text to send.  These functions get one argument, a string containing the text to send.")
   
 You can use `add-hook' to add functions to this list  
 either globally or locally.")  
374    
375  (defvar comint-output-filter-functions '(comint-postoutput-scroll-to-bottom)  (defvar comint-output-filter-functions '(comint-postoutput-scroll-to-bottom)
376    "Functions to call after output is inserted into the buffer.    "Functions to call after output is inserted into the buffer.
# Line 411  See `comint-send-input'." Line 408  See `comint-send-input'."
408  (defcustom comint-use-prompt-regexp-instead-of-fields nil  (defcustom comint-use-prompt-regexp-instead-of-fields nil
409    "*If non-nil, use `comint-prompt-regexp' to distinguish prompts from user-input.    "*If non-nil, use `comint-prompt-regexp' to distinguish prompts from user-input.
410  If nil, then program output and user-input are given different `field'  If nil, then program output and user-input are given different `field'
411  properties, which emacs commands can use to distinguish them (in  properties, which Emacs commands can use to distinguish them (in
412  particular, common movement commands such as begining-of-line respect  particular, common movement commands such as begining-of-line respect
413  field boundaries in a natural way)."  field boundaries in a natural way)."
414    :type 'boolean    :type 'boolean
# Line 432  executed once when the buffer is created Line 429  executed once when the buffer is created
429    :type 'hook    :type 'hook
430    :group 'comint)    :group 'comint)
431    
432  (defvar comint-mode-map nil)  (defvar comint-mode-map
433      (let ((map (make-sparse-keymap)))
434        ;; Keys:
435        (define-key map "\ep"         'comint-previous-input)
436        (define-key map "\en"         'comint-next-input)
437        (define-key map [C-up]        'comint-previous-input)
438        (define-key map [C-down]      'comint-next-input)
439        (define-key map "\er"         'comint-previous-matching-input)
440        (define-key map "\es"         'comint-next-matching-input)
441        (define-key map [?\C-c ?\M-r] 'comint-previous-matching-input-from-input)
442        (define-key map [?\C-c ?\M-s] 'comint-next-matching-input-from-input)
443        (define-key map "\e\C-l"      'comint-show-output)
444        (define-key map "\C-m"        'comint-send-input)
445        (define-key map "\C-d"        'comint-delchar-or-maybe-eof)
446        (define-key map "\C-c "       'comint-accumulate)
447        (define-key map "\C-c\C-x"    'comint-get-next-from-history)
448        (define-key map "\C-c\C-a"    'comint-bol-or-process-mark)
449        (define-key map "\C-c\C-u"    'comint-kill-input)
450        (define-key map "\C-c\C-w"    'backward-kill-word)
451        (define-key map "\C-c\C-c"    'comint-interrupt-subjob)
452        (define-key map "\C-c\C-z"    'comint-stop-subjob)
453        (define-key map "\C-c\C-\\"   'comint-quit-subjob)
454        (define-key map "\C-c\C-m"    'comint-insert-input)
455        (define-key map "\C-c\C-o"    'comint-delete-output)
456        (define-key map "\C-c\C-r"    'comint-show-output)
457        (define-key map "\C-c\C-e"    'comint-show-maximum-output)
458        (define-key map "\C-c\C-l"    'comint-dynamic-list-input-ring)
459        (define-key map "\C-c\C-n"    'comint-next-prompt)
460        (define-key map "\C-c\C-p"    'comint-previous-prompt)
461        (define-key map "\C-c\C-d"    'comint-send-eof)
462        (define-key map "\C-c\C-s"    'comint-write-output)
463        (define-key map "\C-c."       'comint-insert-previous-argument)
464        ;; Mouse Buttons:
465        (define-key map [mouse-2]     'comint-insert-input)
466        ;; Menu bars:
467        ;; completion:
468        (define-key map [menu-bar completion]
469          (cons "Complete" (make-sparse-keymap "Complete")))
470        (define-key map [menu-bar completion complete-expand]
471          '("Expand File Name" . comint-replace-by-expanded-filename))
472        (define-key map [menu-bar completion complete-listing]
473          '("File Completion Listing" . comint-dynamic-list-filename-completions))
474        (define-key map [menu-bar completion complete-file]
475          '("Complete File Name" . comint-dynamic-complete-filename))
476        (define-key map [menu-bar completion complete]
477          '("Complete Before Point" . comint-dynamic-complete))
478        ;; Input history:
479        (define-key map [menu-bar inout]
480          (cons "In/Out" (make-sparse-keymap "In/Out")))
481        (define-key map [menu-bar inout delete-output]
482          '("Delete Current Output Group" . comint-delete-output))
483        (define-key map [menu-bar inout append-output-to-file]
484          '("Append Current Output Group to File" . comint-append-output-to-file))
485        (define-key map [menu-bar inout write-output]
486          '("Write Current Output Group to File" . comint-write-output))
487        (define-key map [menu-bar inout next-prompt]
488          '("Forward Output Group" . comint-next-prompt))
489        (define-key map [menu-bar inout previous-prompt]
490          '("Backward Output Group" . comint-previous-prompt))
491        (define-key map [menu-bar inout show-maximum-output]
492          '("Show Maximum Output" . comint-show-maximum-output))
493        (define-key map [menu-bar inout show-output]
494          '("Show Current Output Group" . comint-show-output))
495        (define-key map [menu-bar inout kill-input]
496          '("Kill Current Input" . comint-kill-input))
497        (define-key map [menu-bar inout copy-input]
498          '("Copy Old Input" . comint-insert-input))
499        (define-key map [menu-bar inout forward-matching-history]
500          '("Forward Matching Input..." . comint-forward-matching-input))
501        (define-key map [menu-bar inout backward-matching-history]
502          '("Backward Matching Input..." . comint-backward-matching-input))
503        (define-key map [menu-bar inout next-matching-history]
504          '("Next Matching Input..." . comint-next-matching-input))
505        (define-key map [menu-bar inout previous-matching-history]
506          '("Previous Matching Input..." . comint-previous-matching-input))
507        (define-key map [menu-bar inout next-matching-history-from-input]
508          '("Next Matching Current Input" . comint-next-matching-input-from-input))
509        (define-key map [menu-bar inout previous-matching-history-from-input]
510          '("Previous Matching Current Input" . comint-previous-matching-input-from-input))
511        (define-key map [menu-bar inout next-history]
512          '("Next Input" . comint-next-input))
513        (define-key map [menu-bar inout previous-history]
514          '("Previous Input" . comint-previous-input))
515        (define-key map [menu-bar inout list-history]
516          '("List Input History" . comint-dynamic-list-input-ring))
517        (define-key map [menu-bar inout expand-history]
518          '("Expand History Before Point" . comint-replace-by-expanded-history))
519        ;; Signals
520        (let ((signals-map (make-sparse-keymap "Signals")))
521          (define-key map [menu-bar signals] (cons "Signals" signals-map))
522          (define-key signals-map [eof]   '("EOF"   . comint-send-eof))
523          (define-key signals-map [kill]  '("KILL"  . comint-kill-subjob))
524          (define-key signals-map [quit]  '("QUIT"  . comint-quit-subjob))
525          (define-key signals-map [cont]  '("CONT"  . comint-continue-subjob))
526          (define-key signals-map [stop]  '("STOP"  . comint-stop-subjob))
527          (define-key signals-map [break] '("BREAK" . comint-interrupt-subjob)))
528        ;; Put them in the menu bar:
529        (setq menu-bar-final-items (append '(completion inout signals)
530                                           menu-bar-final-items))
531        map))
532    
533  ;; Fixme: Is this still relevant?  ;; Fixme: Is this still relevant?
534  (defvar comint-ptyp t  (defvar comint-ptyp t
# Line 548  Entry to this mode runs the hooks on `co Line 644  Entry to this mode runs the hooks on `co
644    ;; This behavior is not useful in comint buffers, and is annoying    ;; This behavior is not useful in comint buffers, and is annoying
645    (set (make-local-variable 'next-line-add-newlines) nil))    (set (make-local-variable 'next-line-add-newlines) nil))
646    
 (if comint-mode-map  
     nil  
   ;; Keys:  
   (setq comint-mode-map (make-sparse-keymap))  
   (define-key comint-mode-map "\ep" 'comint-previous-input)  
   (define-key comint-mode-map "\en" 'comint-next-input)  
   (define-key comint-mode-map [C-up] 'comint-previous-input)  
   (define-key comint-mode-map [C-down] 'comint-next-input)  
   (define-key comint-mode-map "\er" 'comint-previous-matching-input)  
   (define-key comint-mode-map "\es" 'comint-next-matching-input)  
   (define-key comint-mode-map [?\C-c ?\M-r] 'comint-previous-matching-input-from-input)  
   (define-key comint-mode-map [?\C-c ?\M-s] 'comint-next-matching-input-from-input)  
   (define-key comint-mode-map "\e\C-l" 'comint-show-output)  
   (define-key comint-mode-map "\C-m" 'comint-send-input)  
   (define-key comint-mode-map "\C-d" 'comint-delchar-or-maybe-eof)  
   (define-key comint-mode-map "\C-c " 'comint-accumulate)  
   (define-key comint-mode-map "\C-c\C-x" 'comint-get-next-from-history)  
   (define-key comint-mode-map "\C-c\C-a" 'comint-bol-or-process-mark)  
   (define-key comint-mode-map "\C-c\C-u" 'comint-kill-input)  
   (define-key comint-mode-map "\C-c\C-w" 'backward-kill-word)  
   (define-key comint-mode-map "\C-c\C-c" 'comint-interrupt-subjob)  
   (define-key comint-mode-map "\C-c\C-z" 'comint-stop-subjob)  
   (define-key comint-mode-map "\C-c\C-\\" 'comint-quit-subjob)  
   (define-key comint-mode-map "\C-c\C-m" 'comint-insert-input)  
   (define-key comint-mode-map "\C-c\C-o" 'comint-delete-output)  
   (define-key comint-mode-map "\C-c\C-r" 'comint-show-output)  
   (define-key comint-mode-map "\C-c\C-e" 'comint-show-maximum-output)  
   (define-key comint-mode-map "\C-c\C-l" 'comint-dynamic-list-input-ring)  
   (define-key comint-mode-map "\C-c\C-n" 'comint-next-prompt)  
   (define-key comint-mode-map "\C-c\C-p" 'comint-previous-prompt)  
   (define-key comint-mode-map "\C-c\C-d" 'comint-send-eof)  
   (define-key comint-mode-map "\C-c\C-s" 'comint-write-output)  
   (define-key comint-mode-map "\C-c." 'comint-insert-previous-argument)  
   ;; Mouse Buttons:  
   (define-key comint-mode-map [mouse-2] 'comint-mouse-insert-input)  
   ;; Menu bars:  
   ;; completion:  
   (define-key comint-mode-map [menu-bar completion]  
     (cons "Complete" (make-sparse-keymap "Complete")))  
   (define-key comint-mode-map [menu-bar completion complete-expand]  
     '("Expand File Name" . comint-replace-by-expanded-filename))  
   (define-key comint-mode-map [menu-bar completion complete-listing]  
     '("File Completion Listing" . comint-dynamic-list-filename-completions))  
   (define-key comint-mode-map [menu-bar completion complete-file]  
     '("Complete File Name" . comint-dynamic-complete-filename))  
   (define-key comint-mode-map [menu-bar completion complete]  
     '("Complete Before Point" . comint-dynamic-complete))  
   ;; Input history:  
   (define-key comint-mode-map [menu-bar inout]  
     (cons "In/Out" (make-sparse-keymap "In/Out")))  
   (define-key comint-mode-map [menu-bar inout delete-output]  
     '("Delete Current Output Group" . comint-delete-output))  
   (define-key comint-mode-map [menu-bar inout append-output-to-file]  
     '("Append Current Output Group to File" . comint-append-output-to-file))  
   (define-key comint-mode-map [menu-bar inout write-output]  
     '("Write Current Output Group to File" . comint-write-output))  
   (define-key comint-mode-map [menu-bar inout next-prompt]  
     '("Forward Output Group" . comint-next-prompt))  
   (define-key comint-mode-map [menu-bar inout previous-prompt]  
     '("Backward Output Group" . comint-previous-prompt))  
   (define-key comint-mode-map [menu-bar inout show-maximum-output]  
     '("Show Maximum Output" . comint-show-maximum-output))  
   (define-key comint-mode-map [menu-bar inout show-output]  
     '("Show Current Output Group" . comint-show-output))  
   (define-key comint-mode-map [menu-bar inout kill-input]  
     '("Kill Current Input" . comint-kill-input))  
   (define-key comint-mode-map [menu-bar inout copy-input]  
     '("Copy Old Input" . comint-insert-input))  
   (define-key comint-mode-map [menu-bar inout forward-matching-history]  
     '("Forward Matching Input..." . comint-forward-matching-input))  
   (define-key comint-mode-map [menu-bar inout backward-matching-history]  
     '("Backward Matching Input..." . comint-backward-matching-input))  
   (define-key comint-mode-map [menu-bar inout next-matching-history]  
     '("Next Matching Input..." . comint-next-matching-input))  
   (define-key comint-mode-map [menu-bar inout previous-matching-history]  
     '("Previous Matching Input..." . comint-previous-matching-input))  
   (define-key comint-mode-map [menu-bar inout next-matching-history-from-input]  
     '("Next Matching Current Input" . comint-next-matching-input-from-input))  
   (define-key comint-mode-map [menu-bar inout previous-matching-history-from-input]  
     '("Previous Matching Current Input" . comint-previous-matching-input-from-input))  
   (define-key comint-mode-map [menu-bar inout next-history]  
     '("Next Input" . comint-next-input))  
   (define-key comint-mode-map [menu-bar inout previous-history]  
     '("Previous Input" . comint-previous-input))  
   (define-key comint-mode-map [menu-bar inout list-history]  
     '("List Input History" . comint-dynamic-list-input-ring))  
   (define-key comint-mode-map [menu-bar inout expand-history]  
     '("Expand History Before Point" . comint-replace-by-expanded-history))  
   ;; Signals  
   (define-key comint-mode-map [menu-bar signals]  
     (cons "Signals" (make-sparse-keymap "Signals")))  
   (define-key comint-mode-map [menu-bar signals eof]  
     '("EOF" . comint-send-eof))  
   (define-key comint-mode-map [menu-bar signals kill]  
     '("KILL" . comint-kill-subjob))  
   (define-key comint-mode-map [menu-bar signals quit]  
     '("QUIT" . comint-quit-subjob))  
   (define-key comint-mode-map [menu-bar signals cont]  
     '("CONT" . comint-continue-subjob))  
   (define-key comint-mode-map [menu-bar signals stop]  
     '("STOP" . comint-stop-subjob))  
   (define-key comint-mode-map [menu-bar signals break]  
     '("BREAK" . comint-interrupt-subjob))  
   ;; Put them in the menu bar:  
   (setq menu-bar-final-items (append '(completion inout signals)  
                                      menu-bar-final-items))  
   )  
   
647  (defun comint-check-proc (buffer)  (defun comint-check-proc (buffer)
648    "Return t if there is a living process associated w/buffer BUFFER.    "Return t if there is a living process associated w/buffer BUFFER.
649  Living means the status is `open', `run', or `stop'.  Living means the status is `open', `run', or `stop'.
# Line 798  buffer.  The hook `comint-exec-hook' is Line 786  buffer.  The hook `comint-exec-hook' is
786          (set-process-coding-system proc decoding encoding))          (set-process-coding-system proc decoding encoding))
787      proc))      proc))
788    
789  (defun comint-insert-input ()  (defun comint-insert-input (&optional event)
790    "In a Comint buffer, set the current input to the previous input at point."    "In a Comint buffer, set the current input to the previous input at point."
791    (interactive)    (interactive (list last-input-event))
792      (if event (mouse-set-point event))
793    (let ((pos (point)))    (let ((pos (point)))
794      (if (not (eq (get-char-property pos 'field) 'input))      (if (not (eq (get-char-property pos 'field) 'input))
795          ;; No input at POS, fall back to the global definition.          ;; No input at POS, fall back to the global definition.
# Line 818  buffer.  The hook `comint-exec-hook' is Line 807  buffer.  The hook `comint-exec-hook' is
807        ;; Insert the input at point        ;; Insert the input at point
808        (insert (buffer-substring-no-properties        (insert (buffer-substring-no-properties
809                 (previous-single-char-property-change (1+ pos) 'field)                 (previous-single-char-property-change (1+ pos) 'field)
810                 (next-single-char-property-change pos 'field))))))                 (next-single-char-property-change pos 'field))))))
   
 (defun comint-mouse-insert-input (event)  
   "In a Comint buffer, set the current input to the previous input you click on."  
   (interactive "e")  
   (mouse-set-point event)  
   (comint-insert-input))  
811    
812    
813  ;; Input history processing in a buffer  ;; Input history processing in a buffer
# Line 1734  Make backspaces delete the previous char Line 1717  Make backspaces delete the previous char
1717                       (1- prompt-start) prompt-start 'read-only 'fence))                       (1- prompt-start) prompt-start 'read-only 'fence))
1718                  (add-text-properties                  (add-text-properties
1719                   prompt-start (point)                   prompt-start (point)
1720                   '(read-only t rear-non-sticky t front-sticky (read-only))))                   '(read-only t rear-nonsticky t front-sticky (read-only))))
1721                (unless (and (bolp) (null comint-last-prompt-overlay))                (unless (and (bolp) (null comint-last-prompt-overlay))
1722                  ;; Need to create or move the prompt overlay (in the case                  ;; Need to create or move the prompt overlay (in the case
1723                  ;; where there is no prompt ((bolp) == t), we still do                  ;; where there is no prompt ((bolp) == t), we still do
# Line 2136  This command also kills the pending inpu Line 2119  This command also kills the pending inpu
2119  between the process mark and point.  between the process mark and point.
2120    
2121  WARNING: if there is no current subjob, you can end up suspending  WARNING: if there is no current subjob, you can end up suspending
2122  the top-level process running in the buffer. If you accidentally do  the top-level process running in the buffer.  If you accidentally do
2123  this, use \\[comint-continue-subjob] to resume the process. (This  this, use \\[comint-continue-subjob] to resume the process.  (This
2124  is not a problem with most shells, since they ignore this signal.)"  is not a problem with most shells, since they ignore this signal.)"
2125    (interactive)    (interactive)
2126    (comint-skip-input)    (comint-skip-input)
# Line 2357  preceding newline is removed." Line 2340  preceding newline is removed."
2340    
2341  (defun comint-kill-whole-line (&optional arg)  (defun comint-kill-whole-line (&optional arg)
2342    "Kill current line, ignoring read-only and field properties.    "Kill current line, ignoring read-only and field properties.
2343  With prefix arg, kill that many lines starting from the current line.  With prefix ARG, kill that many lines starting from the current line.
2344  If arg is negative, kill backward.  Also kill the preceding newline,  If arg is negative, kill backward.  Also kill the preceding newline,
2345  instead of the trailing one.  \(This is meant to make C-x z work well  instead of the trailing one.  \(This is meant to make \\[repeat] work well
2346  with negative arguments.)  with negative arguments.)
2347  If arg is zero, kill current line but exclude the trailing newline.  If arg is zero, kill current line but exclude the trailing newline.
2348  The read-only status of newlines is updated with `comint-update-fence',  The read-only status of newlines is updated with `comint-update-fence',
# Line 2505  Provides a default, if there is one, and Line 2488  Provides a default, if there is one, and
2488    
2489  See `comint-source-default' for more on determining defaults.  See `comint-source-default' for more on determining defaults.
2490    
2491  PROMPT is the prompt string. PREV-DIR/FILE is the (directory . file) pair  PROMPT is the prompt string.  PREV-DIR/FILE is the (directory . file) pair
2492  from the last source processing command.  SOURCE-MODES is a list of major  from the last source processing command.  SOURCE-MODES is a list of major
2493  modes used to determine what file buffers contain source files.  (These  modes used to determine what file buffers contain source files.  (These
2494  two arguments are used for determining defaults).  If MUSTMATCH-P is true,  two arguments are used for determining defaults).  If MUSTMATCH-P is true,
# Line 3503  REGEXP-GROUP is the regular expression g Line 3486  REGEXP-GROUP is the regular expression g
3486    
3487  (provide 'comint)  (provide 'comint)
3488    
3489  ;;; arch-tag: 1793314c-09db-40be-9549-9aeae3e75164  ;; arch-tag: 1793314c-09db-40be-9549-9aeae3e75164
3490  ;;; comint.el ends here  ;;; comint.el ends here

Legend:
Removed from v.1.289.2.3  
changed lines
  Added in v.1.289.2.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26