aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/comint.el
diff options
context:
space:
mode:
authorJim Blandy1992-06-10 01:34:51 +0000
committerJim Blandy1992-06-10 01:34:51 +0000
commit87ef29fd4c779b40f56cca5a5bb208c8fd79680d (patch)
tree3cefcf252375adeef383f6a908fc9cc48b7dced6 /lisp/comint.el
parenta88b5c25733e18049f8b6f713a8f4229b83586b1 (diff)
downloademacs-87ef29fd4c779b40f56cca5a5bb208c8fd79680d.tar.gz
emacs-87ef29fd4c779b40f56cca5a5bb208c8fd79680d.zip
*** empty log message ***
Diffstat (limited to 'lisp/comint.el')
-rw-r--r--lisp/comint.el72
1 files changed, 50 insertions, 22 deletions
diff --git a/lisp/comint.el b/lisp/comint.el
index 93bed741388..5ba3fc6163f 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -58,7 +58,7 @@
58;;; background, dbx, gdb, kermit, prolog, telnet) to use comint-mode 58;;; background, dbx, gdb, kermit, prolog, telnet) to use comint-mode
59;;; instead of shell-mode, see the notes at the end of this file. 59;;; instead of shell-mode, see the notes at the end of this file.
60 60
61(defconst comint-version "2.02") 61(defconst comint-version "2.03")
62 62
63 63
64;;; Brief Command Documentation: 64;;; Brief Command Documentation:
@@ -69,7 +69,7 @@
69;;; m-p comint-previous-input Cycle backwards in input history 69;;; m-p comint-previous-input Cycle backwards in input history
70;;; m-n comint-next-input Cycle forwards 70;;; m-n comint-next-input Cycle forwards
71;;; m-s comint-previous-similar-input Previous similar input 71;;; m-s comint-previous-similar-input Previous similar input
72;;; c-c c-r comint-previous-input-matching Search backwards in input history 72;;; c-m-r comint-previous-input-matching Search backwards in input history
73;;; return comint-send-input 73;;; return comint-send-input
74;;; c-a comint-bol Beginning of line; skip prompt. 74;;; c-a comint-bol Beginning of line; skip prompt.
75;;; c-d comint-delchar-or-maybe-eof Delete char unless at end of buff. 75;;; c-d comint-delchar-or-maybe-eof Delete char unless at end of buff.
@@ -107,6 +107,7 @@
107;;;============================================================================ 107;;;============================================================================
108;;; Comint mode buffer local variables: 108;;; Comint mode buffer local variables:
109;;; comint-prompt-regexp - string comint-bol uses to match prompt. 109;;; comint-prompt-regexp - string comint-bol uses to match prompt.
110;;; comint-last-input-start - marker Handy if inferior always echos
110;;; comint-last-input-end - marker For comint-kill-output command 111;;; comint-last-input-end - marker For comint-kill-output command
111;;; input-ring-size - integer For the input history 112;;; input-ring-size - integer For the input history
112;;; input-ring - ring mechanism 113;;; input-ring - ring mechanism
@@ -213,6 +214,8 @@ Entry to this mode runs the hooks on comint-mode-hook"
213 (setq mode-name "Comint") 214 (setq mode-name "Comint")
214 (setq mode-line-process '(": %s")) 215 (setq mode-line-process '(": %s"))
215 (use-local-map comint-mode-map) 216 (use-local-map comint-mode-map)
217 (make-local-variable 'comint-last-input-start)
218 (setq comint-last-input-start (make-marker))
216 (make-local-variable 'comint-last-input-end) 219 (make-local-variable 'comint-last-input-end)
217 (setq comint-last-input-end (make-marker)) 220 (setq comint-last-input-end (make-marker))
218 (make-local-variable 'comint-last-input-match) 221 (make-local-variable 'comint-last-input-match)
@@ -229,6 +232,7 @@ Entry to this mode runs the hooks on comint-mode-hook"
229 (make-local-variable 'comint-eol-on-send) 232 (make-local-variable 'comint-eol-on-send)
230 (make-local-variable 'comint-ptyp) 233 (make-local-variable 'comint-ptyp)
231 (setq comint-ptyp old-ptyp) 234 (setq comint-ptyp old-ptyp)
235 (make-local-variable 'comint-exec-hook)
232 (run-hooks 'comint-mode-hook) 236 (run-hooks 'comint-mode-hook)
233 ;Do this after the hook so the user can mung INPUT-RING-SIZE w/his hook. 237 ;Do this after the hook so the user can mung INPUT-RING-SIZE w/his hook.
234 ;The test is so we don't lose history if we run comint-mode twice in 238 ;The test is so we don't lose history if we run comint-mode twice in
@@ -316,7 +320,7 @@ buffer. The hook comint-exec-hook is run after each exec."
316 (setq comint-ptyp process-connection-type) ; T if pty, NIL if pipe. 320 (setq comint-ptyp process-connection-type) ; T if pty, NIL if pipe.
317 ;; Jump to the end, and set the process mark. 321 ;; Jump to the end, and set the process mark.
318 (goto-char (point-max)) 322 (goto-char (point-max))
319 (set-marker (process-mark proc) (point))) 323 (set-marker (process-mark proc) (point))
320 ;; Feed it the startfile. 324 ;; Feed it the startfile.
321 (cond (startfile 325 (cond (startfile
322 ;;This is guaranteed to wait long enough 326 ;;This is guaranteed to wait long enough
@@ -331,7 +335,7 @@ buffer. The hook comint-exec-hook is run after each exec."
331 (delete-region (point) (point-max)) 335 (delete-region (point) (point-max))
332 (comint-send-string proc startfile))) 336 (comint-send-string proc startfile)))
333 (run-hooks 'comint-exec-hook) 337 (run-hooks 'comint-exec-hook)
334 buffer)) 338 buffer)))
335 339
336;;; This auxiliary function cranks up the process for comint-exec in 340;;; This auxiliary function cranks up the process for comint-exec in
337;;; the appropriate environment. 341;;; the appropriate environment.
@@ -676,16 +680,17 @@ Similarly for Soar, Scheme, etc.."
676 (input (if (>= (point) pmark-val) 680 (input (if (>= (point) pmark-val)
677 (progn (if comint-eol-on-send (end-of-line)) 681 (progn (if comint-eol-on-send (end-of-line))
678 (buffer-substring pmark (point))) 682 (buffer-substring pmark (point)))
679 (let ((copy (funcall comint-get-old-input))) 683 (let ((copy (funcall comint-get-old-input)))
680 (goto-char pmark) 684 (goto-char pmark)
681 (insert copy) 685 (insert copy)
682 copy)))) 686 copy))))
683 (insert ?\n) 687 (insert ?\n)
684 (if (funcall comint-input-filter input) (ring-insert input-ring input)) 688 (if (funcall comint-input-filter input) (ring-insert input-ring input))
685 (funcall comint-input-sentinel input) 689 (funcall comint-input-sentinel input)
686 (funcall comint-input-sender proc input) 690 (funcall comint-input-sender proc input)
687 (set-marker (process-mark proc) (point)) 691 (set-marker comint-last-input-start pmark)
688 (set-marker comint-last-input-end (point)))))) 692 (set-marker comint-last-input-end (point))
693 (set-marker (process-mark proc) (point))))))
689 694
690(defun comint-get-old-input-default () 695(defun comint-get-old-input-default ()
691 "Default for comint-get-old-input: take the current line, and discard 696 "Default for comint-get-old-input: take the current line, and discard
@@ -741,22 +746,27 @@ in your hook, comint-mode-hook."
741;;; saved -- typically passwords to ftp, telnet, or somesuch. 746;;; saved -- typically passwords to ftp, telnet, or somesuch.
742;;; Just enter m-x send-invisible and type in your line. 747;;; Just enter m-x send-invisible and type in your line.
743 748
744(defun comint-read-noecho (prompt) 749(defun comint-read-noecho (prompt &optional stars)
745 "Prompt the user with argument PROMPT. Read a single line of text 750 "Prompt the user with argument PROMPT. Read a single line of text
746without echoing, and return it. Note that the keystrokes comprising 751without echoing, and return it. Note that the keystrokes comprising
747the text can still be recovered (temporarily) with \\[view-lossage]. This 752the text can still be recovered (temporarily) with \\[view-lossage]. This
748may be a security bug for some applications." 753may be a security bug for some applications. Optional argument STARS
754causes input to be echoed with '*' characters on the prompt line."
749 (let ((echo-keystrokes 0) 755 (let ((echo-keystrokes 0)
756 (cursor-in-echo-area t)
750 (answ "") 757 (answ "")
751 tem) 758 tem)
752 (if (and (stringp prompt) (not (string= (message prompt) ""))) 759 (if (not (stringp prompt)) (setq prompt ""))
753 (message prompt)) 760 (message prompt)
754 (while (not(or (= (setq tem (read-char)) ?\^m) 761 (while (not(or (= (setq tem (read-char)) ?\^m)
755 (= tem ?\n))) 762 (= tem ?\n)))
756 (setq answ (concat answ (char-to-string tem)))) 763 (setq answ (concat answ (char-to-string tem)))
764 (if stars (setq prompt (concat prompt "*")))
765 (message prompt))
757 (message "") 766 (message "")
758 answ)) 767 answ))
759 768
769
760(defun send-invisible (str) 770(defun send-invisible (str)
761 "Read a string without echoing, and send it to the process running 771 "Read a string without echoing, and send it to the process running
762in the current buffer. A new-line is additionally sent. String is not 772in the current buffer. A new-line is additionally sent. String is not
@@ -769,7 +779,7 @@ Security bug: your string can still be temporarily recovered with
769 (if (not proc) (error "Current buffer has no process") 779 (if (not proc) (error "Current buffer has no process")
770 (comint-send-string proc 780 (comint-send-string proc
771 (if (stringp str) str 781 (if (stringp str) str
772 (comint-read-noecho "Enter non-echoed text"))) 782 (comint-read-noecho "Non-echoed text: " t)))
773 (comint-send-string proc "\n")))) 783 (comint-send-string proc "\n"))))
774 784
775 785
@@ -1184,8 +1194,8 @@ it just adds completion characters to the end of the filename."
1184;;; Most of the work is renaming variables and functions. These are the common 1194;;; Most of the work is renaming variables and functions. These are the common
1185;;; ones: 1195;;; ones:
1186;;; Local variables: 1196;;; Local variables:
1197;;; last-input-start comint-last-input-start
1187;;; last-input-end comint-last-input-end 1198;;; last-input-end comint-last-input-end
1188;;; last-input-start <unnecessary>
1189;;; shell-prompt-pattern comint-prompt-regexp 1199;;; shell-prompt-pattern comint-prompt-regexp
1190;;; shell-set-directory-error-hook <no equivalent> 1200;;; shell-set-directory-error-hook <no equivalent>
1191;;; Miscellaneous: 1201;;; Miscellaneous:
@@ -1203,11 +1213,17 @@ it just adds completion characters to the end of the filename."
1203;;; show-output-from-shell comint-show-output 1213;;; show-output-from-shell comint-show-output
1204;;; copy-last-shell-input Use comint-previous-input/comint-next-input 1214;;; copy-last-shell-input Use comint-previous-input/comint-next-input
1205;;; 1215;;;
1206;;; LAST-INPUT-START is no longer necessary because inputs are stored on the 1216;;; SHELL-SET-DIRECTORY is gone, its functionality taken over by
1207;;; input history ring. SHELL-SET-DIRECTORY is gone, its functionality taken 1217;;; SHELL-DIRECTORY-TRACKER, the shell mode's comint-input-sentinel.
1208;;; over by SHELL-DIRECTORY-TRACKER, the shell mode's comint-input-sentinel. 1218;;; Comint mode does not provide functionality equivalent to
1209;;; Comint mode does not provide functionality equivalent to
1210;;; shell-set-directory-error-hook; it is gone. 1219;;; shell-set-directory-error-hook; it is gone.
1220;;;
1221;;; comint-last-input-start is provided for modes which want to munge
1222;;; the buffer after input is sent, perhaps because the inferior
1223;;; insists on echoing the input. The LAST-INPUT-START variable in
1224;;; the old shell package was used to implement a history mechanism,
1225;;; but you should think twice before using comint-last-input-start
1226;;; for this; the input history ring often does the job better.
1211;;; 1227;;;
1212;;; If you are implementing some process-in-a-buffer mode, called foo-mode, do 1228;;; If you are implementing some process-in-a-buffer mode, called foo-mode, do
1213;;; *not* create the comint-mode local variables in your foo-mode function. 1229;;; *not* create the comint-mode local variables in your foo-mode function.
@@ -1354,12 +1370,24 @@ This is a good place to put keybindings.")
1354;;; - Added a hook, comint-exec-hook that is run each time a process 1370;;; - Added a hook, comint-exec-hook that is run each time a process
1355;;; is cranked up. Useful for things like process-kill-without-query. 1371;;; is cranked up. Useful for things like process-kill-without-query.
1356;;; 1372;;;
1373;;; These two were pointed out by tale:
1357;;; - Improved the doc string in comint-send-input a little bit. 1374;;; - Improved the doc string in comint-send-input a little bit.
1358;;; - Tweaked make-comint to check process status with comint-check-proc 1375;;; - Tweaked make-comint to check process status with comint-check-proc
1359;;; instead of equivalent inline code. 1376;;; instead of equivalent inline code.
1360;;; These two were pointed out by tale. 1377;;;
1361;;; - Prompt-search history commands have been commented out. I never 1378;;; - Prompt-search history commands have been commented out. I never
1362;;; liked them; I don't think anyone used them. 1379;;; liked them; I don't think anyone used them.
1380;;; - Made comint-exec-hook a local var, as it should have been.
1381;;; (This way, for instance, you can have cmushell procs kill-w/o-query,
1382;;; but let Scheme procs be default.)
1383;;;
1384;;; 7/91 Shivers
1385;;; - Souped up comint-read-noecho with an optional argument, STARS.
1386;;; Suggested by mjlx@EAGLE.CNSF.CORNELL.EDU.
1387;;; - Moved comint-previous-input-matching from C-c r to C-M-r.
1388;;; C-c <letter> bindings are reserved for the user.
1389;;; These bindings were done by Jim Blandy.
1390;;; These changes comprise version 2.03.
1363 1391
1364(provide 'comint) 1392(provide 'comint)
1365 1393