shell.elc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. (provide (quote shell))
  2. (or (fboundp (quote process-send-string)) (progn (fset (quote process-send-string) (quote send-string)) (fset (quote process-send-region) (quote send-region))))
  3. (defvar last-input-start nil "\
  4. In a shell-mode buffer, marker for start of last unit of input.")
  5. (defvar last-input-end nil "\
  6. In a shell-mode buffer, marker for start of last unit of input.")
  7. (defvar shell-mode-map nil)
  8. (defvar shell-directory-stack nil "\
  9. List of directories saved by pushd in this buffer's shell.")
  10. (defvar shell-popd-regexp "popd" "\
  11. *Regexp to match subshell commands equivalent to popd.")
  12. (defvar shell-pushd-regexp "pushd" "\
  13. *Regexp to match subshell commands equivalent to pushd.")
  14. (defvar shell-cd-regexp "cd" "\
  15. *Regexp to match subshell commands equivalent to cd.")
  16. (defvar explicit-shell-file-name nil "\
  17. *If non-nil, is file name to use for explicitly requested inferior shell.")
  18. (defun shell-mode nil "\
  19. Major mode for interacting with an inferior shell.
  20. Shell name is same as buffer name, sans the asterisks.
  21. Return at end of buffer sends line as input.
  22. Return not at end copies rest of line to end and sends it.
  23. The following commands imitate the usual Unix interrupt and
  24. editing control characters:
  25. \\{shell-mode-map}
  26. Entry to this mode calls the value of shell-mode-hook with no args,
  27. if that value is non-nil.
  28. cd, pushd and popd commands given to the shell are watched
  29. by Emacs to keep this buffer's default directory
  30. the same as the shell's working directory.
  31. Variables shell-cd-regexp, shell-pushd-regexp and shell-popd-regexp
  32. are used to match these command names.
  33. You can send text to the shell (or its subjobs) from other buffers
  34. using the commands process-send-region, process-send-string
  35. and lisp-send-defun." (interactive) (byte-code "ÅˆÈ ˆÉ‰ˆÊ‰ˆË‰ˆÌ !ˆÍÄ!ˆÅ‰ˆÍÆ!ˆÎ ‰ˆÍÇ!ˆÎ ‰ˆÏÐ!‡" [major-mode mode-name mode-line-process shell-mode-map shell-directory-stack nil last-input-start last-input-end kill-all-local-variables shell-mode "Shell" (": %s") use-local-map make-local-variable make-marker run-hooks shell-mode-hook] 9))
  36. (if shell-mode-map nil (setq shell-mode-map (make-sparse-keymap)) (define-key shell-mode-map " " (quote shell-send-input)) (define-key shell-mode-map "" (quote shell-send-eof)) (define-key shell-mode-map "" (quote kill-shell-input)) (define-key shell-mode-map "" (quote backward-kill-word)) (define-key shell-mode-map "" (quote interrupt-shell-subjob)) (define-key shell-mode-map "" (quote stop-shell-subjob)) (define-key shell-mode-map "" (quote quit-shell-subjob)) (define-key shell-mode-map "" (quote kill-output-from-shell)) (define-key shell-mode-map "" (quote show-output-from-shell)) (define-key shell-mode-map "" (quote copy-last-shell-input)))
  37. (defvar explicit-csh-args (if (eq system-type (quote hpux)) (quote ("-i" "-T")) (quote ("-i"))) "\
  38. Args passed to inferior shell by M-x shell, if the shell is csh.
  39. Value is a list of strings, which may be nil.")
  40. (defun shell nil "\
  41. Run an inferior shell, with I/O through buffer *shell*.
  42. If buffer exists but shell process is not running, make new shell.
  43. Program used comes from variable explicit-shell-file-name,
  44. or (if that is nil) from the ESHELL environment variable,
  45. or else from SHELL if there is no ESHELL.
  46. If a file ~/.emacs_SHELLNAME exists, it is given as initial input
  47. (Note that this may lose due to a timing error if the shell
  48. discards input when it starts up.)
  49. The buffer is put in shell-mode, giving commands for sending input
  50. and controlling the subjobs of the shell. See shell-mode.
  51. See also variable shell-prompt-pattern.
  52. The shell file name (sans directories) is used to make a symbol name
  53. such as `explicit-csh-arguments'. If that symbol is a variable,
  54. its value is used as a list of arguments when invoking the shell.
  55. Otherwise, one argument `-i' is passed to the shell.
  56. Note that many people's .cshrc files unconditionally clear the prompt.
  57. If yours does, you will probably want to change it." (interactive) (byte-code "Ĉ †ÅÆ!†ÅÇ!†ÈÉ!ÊËÌÍÎÏ
  58. P!…(Ï
  59. PÐÑ
  60. ÒQ! …6Ó !ƒ> J‚?Ô)%!*‡" [prog explicit-shell-file-name name symbol nil getenv "ESHELL" "SHELL" "/bin/sh" file-name-nondirectory switch-to-buffer apply make-shell "shell" file-exists-p "~/.emacs_" intern-soft "explicit-" "-args" boundp ("-i")] 14))
  61. (defun make-shell (name program &optional startfile &rest switches) (byte-code "ÊË ËQ!ÅÅÅÌ!‰ˆ
  62. …Í
  63. !‰ˆŠqˆ Î>ƒ+Å‚u
  64. …2Ï
  65. !ˆÐÑ ÒPÓÔÕ \"Öר&
  66. ‰ˆ …oÙÚ!ˆdbˆÛ !ˆÜ`d\"‰ ˆÝ`d\"ˆÞ
  67.  \"ˆß
  68. !‰ˆdbˆàá
  69. !`\"ˆâ )ˆ,‡" [buffer name proc status size nil exec-directory program switches startfile get-buffer-create "*" get-buffer-process process-status (run stop) delete-process apply start-process "env" format "TERMCAP=emacs:co#%d:tc=unknown:" screen-width "TERM=emacs" "EMACS=t" "-" sleep-for 1 insert-file-contents buffer-substring delete-region process-send-string process-name set-marker process-mark shell-mode] 17))
  70. (defvar shell-set-directory-error-hook (quote ignore) "\
  71. Function called with no arguments when shell-send-input
  72. recognizes a change-directory command but gets an error
  73. trying to change Emacs's default directory.")
  74. (defun shell-send-input nil "\
  75. Send input to subshell.
  76. At end of buffer, sends all text after last output
  77. as input to the subshell, including a newline inserted at the end.
  78. Not at end, copies current line to the end of the buffer and sends it,
  79. after first attempting to discard any prompt at the beginning of the line
  80. by matching the regexp that is the value of shell-prompt-pattern if possible.
  81. This regexp should start with \"^\"." (interactive) (byte-code "ÃˆÇ ˆmƒÈÉÊp!!\"ˆËcˆÈ `\"‚>Ì ˆÍ
  82. ÃÄ#ˆÎ`ÏÐ!ˆ`\"dbˆÈ`\"ˆ cˆÈ `\")ˆÃÑÒ�ˆÊp!Ó #ˆÔÉ!`\")‡" [last-input-start last-input-end shell-prompt-pattern nil t copy process end-of-line move-marker process-mark get-buffer-process 10 beginning-of-line re-search-forward buffer-substring forward-line 1 (byte-code "ŠbˆÁ )‡" [last-input-start shell-set-directory] 2) ((error (byte-code "Á!‡" [shell-set-directory-error-hook funcall] 2))) process-send-region set-marker] 17))
  83. (defun shell-set-directory nil (byte-code "Ç!… ÈÉ!fÊ>ƒ …Ë @!ˆ A‰‚¸Ç
  84. !ƒvÈÉ!fÌ>ƒC …@ Ë @!ˆ AB‰)‚sÈÉ!fÍ>…sÎÏÐ!ˆÏÑ!ˆÒÓÔÕ`ÏÖ!ˆ`\"!!‰!…r B‰ˆË !)‚¸Ç!…¸ÈÉ!f×>ƒŽËØÙ!!‚¸ÈÉ!fÚ>…¸ÎÛÜ!ˆÏÑ!ˆÒÓÔÕ`ÏÖ!ˆ`\"!!‰!…·Ë !)‡" [shell-popd-regexp shell-directory-stack shell-pushd-regexp old default-directory dir shell-cd-regexp looking-at match-end 0 (59 10) cd (59 10) (32 9) nil skip-chars-forward "^ " " " file-directory-p expand-file-name substitute-in-file-name buffer-substring "^
  85. ;" (59 10) getenv "HOME" (32 9) forward-char 3] 29))
  86. (defun shell-send-eof nil "\
  87. Send eof to subshell (or to the program running under it)." (interactive) (byte-code "ÀˆÁ ‡" [nil process-send-eof] 2))
  88. (defun kill-output-from-shell nil "\
  89. Kill all output from shell since last input." (interactive) (byte-code "ÁˆdbˆÂ`\"ˆÃc‡" [last-input-end nil kill-region "> output flushed ***
  90. "] 3))
  91. (defun show-output-from-shell nil "\
  92. Display start of this batch of shell output at top of window.
  93. Also put cursor there." (interactive) (byte-code "ÁˆÂà \"ˆb‡" [last-input-end nil set-window-start selected-window] 4))
  94. (defun copy-last-shell-input nil "\
  95. Copy previous shell input, sans newline, and insert before point." (interactive) (byte-code "ˆÃ \"cˆÄÅ!‡" [last-input-end last-input-start nil buffer-substring delete-char -1] 3))
  96. (defun interrupt-shell-subjob nil "\
  97. Interrupt this shell's current subjob." (interactive) (byte-code "ÀˆÂÀÁ\"‡" [nil t interrupt-process] 3))
  98. (defun kill-shell-subjob nil "\
  99. Send kill signal to this shell's current subjob." (interactive) (byte-code "ÀˆÂÀÁ\"‡" [nil t kill-process] 3))
  100. (defun quit-shell-subjob nil "\
  101. Send quit signal to this shell's current subjob." (interactive) (byte-code "ÀˆÂÀÁ\"‡" [nil t quit-process] 3))
  102. (defun stop-shell-subjob nil "\
  103. Stop this shell's current subjob." (interactive) (byte-code "ÀˆÂÀÁ\"‡" [nil t stop-process] 3))
  104. (defun kill-shell-input nil "\
  105. Kill all text since last stuff output by the shell or its subjobs." (interactive) (byte-code "ÀˆÁÂÃp!!`\"‡" [nil kill-region process-mark get-buffer-process] 5))
  106. (defvar inferior-lisp-mode-map nil)
  107. (if inferior-lisp-mode-map nil (setq inferior-lisp-mode-map (copy-alist shell-mode-map)) (lisp-mode-commands inferior-lisp-mode-map) (define-key inferior-lisp-mode-map "" (quote lisp-send-defun)))
  108. (defvar inferior-lisp-program "lisp" "\
  109. *Program name for invoking an inferior Lisp with `run-lisp'.")
  110. (defvar inferior-lisp-load-command "(load \"%s\")
  111. " "*Format-string for building a Lisp expression to load a file.
  112. This format string should use %s to substitute a file name
  113. and should result in a Lisp expression that will command the inferior Lisp
  114. to load that file. The default works acceptably on most Lisps.
  115. The string \"(progn (load \\\"%s\\\" :verbose nil :print t) (values))\\
  116. \"
  117. produces cosmetically superior output for this application,
  118. but it works only in Common Lisp.")
  119. (defvar inferior-lisp-prompt "^.*>:? *$" "\
  120. *Regexp to recognize prompts from the inferior Lisp.
  121. Default is right for Franz Lisp and kcl.")
  122. (defun inferior-lisp-mode nil "\
  123. Major mode for interacting with an inferior Lisp process.
  124. The following commands are available:
  125. \\{inferior-lisp-mode-map}
  126. Entry to this mode calls the value of lisp-mode-hook with no arguments,
  127. if that value is non-nil. Likewise with the value of shell-mode-hook.
  128. lisp-mode-hook is called after shell-mode-hook.
  129. You can send text to the inferior Lisp from other buffers
  130. using the commands process-send-region, process-send-string
  131. and \\[lisp-send-defun].
  132. Commands:
  133. Delete converts tabs to spaces as it moves back.
  134. Tab indents for Lisp; with argument, shifts rest
  135. of expression rigidly with the current line.
  136. Meta-Control-Q does Tab on each line starting within following expression.
  137. Paragraphs are separated only by blank lines. Semicolons start comments.
  138. Return at end of buffer sends line as input.
  139. Return not at end copies rest of line to end and sends it.
  140. C-d at end of buffer sends end-of-file as input.
  141. C-d not at end or with arg deletes or kills characters.
  142. C-u and C-w are kill commands, imitating normal Unix input editing.
  143. C-c interrupts the shell or its current subjob if any.
  144. C-z stops, likewise. C-\\ sends quit signal, likewise.
  145. C-x C-k deletes last batch of output from shell.
  146. C-x C-v puts top of last batch of output at top of window." (interactive) (byte-code "ÆˆÇ ˆÈ‰ˆÉ‰ˆÊ‰ˆË ˆÌ !ˆÍÄ!ˆÎ ‰ˆÍÅ!ˆÎ ‰ˆÏÐÑ\"‡" [major-mode mode-name mode-line-process inferior-lisp-mode-map last-input-start last-input-end nil kill-all-local-variables inferior-lisp-mode "Inferior Lisp" (": %s") lisp-mode-variables use-local-map make-local-variable make-marker run-hooks shell-mode-hook lisp-mode-hook] 10))
  147. (defun run-lisp nil "\
  148. Run an inferior Lisp process, input and output via buffer *lisp*." (interactive) (byte-code "ÁˆÂÃÄ\"!ˆÅ ‡" [inferior-lisp-program nil switch-to-buffer make-shell "lisp" inferior-lisp-mode] 4))
  149. (defun lisp-send-defun (display-flag) "\
  150. Send the current defun to the Lisp process made by M-x run-lisp.
  151. With argument, force redisplay and scrolling of the *lisp* buffer.
  152. Variable `inferior-lisp-load-command' controls formatting of
  153. the `load' form that is set to the Lisp process." (interactive "P") (byte-code "ˆŠÊ ˆ`ËÌÍÎÏ!!\"Ð ˆÑ` ÂÒ%ˆÓÏË \"\"*ˆ …†ÎÏ!Ô !Õ!†=Ö!×!Šqˆd‰ˆØ !ˆdbˆÙ ˆdU†eÚ !?…mˆ‚Pˆd‰ˆÛÜZ!ˆÝ`\")ˆÞ\"-)‡" [end filename nil inferior-lisp-load-command display-flag process buffer w height inferior-lisp-prompt end-of-defun format "/tmp/emlisp%d" process-id get-process "lisp" beginning-of-defun write-region nomessage process-send-string process-buffer get-buffer-window display-buffer window-height accept-process-output beginning-of-line looking-at vertical-motion 4 set-window-start set-window-point] 21))
  154. (defun lisp-send-defun-and-go nil "\
  155. Send the current defun to the inferior Lisp, and switch to *lisp* buffer." (interactive) (byte-code "ÀˆÁ ˆÂÃ!‡" [nil lisp-send-defun switch-to-buffer "*lisp*"] 3))