;ELC ;;; compiled by kwzh@hill.gnu.ai.mit.edu on Mon Jun 19 18:55:10 1995 ;;; from file /gd/gnu/emacs/19.0/lisp/shell.el ;;; emacs version 19.28.95.2. ;;; bytecomp version FSF 2.10 ;;; optimization is on. ;;; this file uses opcodes which do not exist in Emacs 18. (if (and (boundp 'emacs-version) (or (and (boundp 'epoch::version) epoch::version) (string-lessp emacs-version "19.28.90"))) (error "`shell.el' was compiled for Emacs 19.29 or later")) (require (quote comint)) #@426 Regexp to match prompts in the inferior shell. Defaults to "^[^#$%>\n]*[#$%>] *", which works pretty well. This variable is used to initialise `comint-prompt-regexp' in the shell buffer. The pattern should probably not match more than one line. If it does, shell-mode may become confused trying to distinguish prompt from input on lines which don't start with a prompt. This is a fine thing to set in your `.emacs' file. (defvar shell-prompt-pattern "^[^#$%>\n]*[#$%>] *" (#$ . 499)) #@295 *List of suffixes to be disregarded during file/command completion. This variable is used to initialize `comint-completion-fignore' in the shell buffer. The default is nil, for compatibility with most shells. Some people like ("~" "#" "%"). This is a fine thing to set in your `.emacs' file. (defvar shell-completion-fignore nil (#$ . -994)) #@242 List of characters to recognise as separate arguments. This variable is used to initialize `comint-delimiter-argument-list' in the shell buffer. The default is (?\| ?& ?< ?> ?\( ?\) ?\;). This is a fine thing to set in your `.emacs' file. (defvar shell-delimiter-argument-list (quote (124 38 60 62 40 41 59)) (#$ . 1345)) #@277 List of characters to quote when in a file name. This variable is used to initialize `comint-file-name-quote-list' in the shell buffer. The default is (? ?* ?! ?" ?' ?`) plus characters in `shell-delimiter-argument-list'. This is a fine thing to set in your `.emacs' file. (defvar shell-file-name-quote-list (append shell-delimiter-argument-list (quote (32 42 33 34 39 96))) (#$ . 1676)) #@194 List of functions called to perform completion. This variable is used to initialise `comint-dynamic-complete-functions' in the shell buffer. This is a fine thing to set in your `.emacs' file. (defvar shell-dynamic-complete-functions (quote (comint-replace-by-expanded-history shell-dynamic-complete-environment-variable shell-dynamic-complete-command shell-replace-by-expanded-directory comint-dynamic-complete-filename)) (#$ . 2074)) #@121 *Regexp to match a single command within a pipeline. This is used for directory tracking and does not do a perfect job. (defvar shell-command-regexp "[^;&|\n]+" (#$ . -2517)) #@187 *If non-nil, use executable files only for completion candidates. This mirrors the optional behavior of tcsh. Detecting executability of files may slow command completion considerably. (defvar shell-completion-execonly t (#$ . -2699)) #@56 *Regexp to match subshell commands equivalent to popd. (defvar shell-popd-regexp "popd" (#$ . -2941)) #@57 *Regexp to match subshell commands equivalent to pushd. (defvar shell-pushd-regexp "pushd" (#$ . -3049)) #@112 *If non-nil, make pushd with no arg behave as "pushd ~" (like cd). This mirrors the optional behavior of tcsh. (defvar shell-pushd-tohome nil (#$ . -3161)) #@108 *If non-nil, make "pushd +n" pop the nth dir to the stack top. This mirrors the optional behavior of tcsh. (defvar shell-pushd-dextract nil (#$ . -3324)) #@111 *If non-nil, make pushd only add unique directories to the stack. This mirrors the optional behavior of tcsh. (defvar shell-pushd-dunique nil (#$ . -3485)) #@54 *Regexp to match subshell commands equivalent to cd. (defvar shell-cd-regexp "cd" (#$ . -3647)) #@75 *If non-nil, is file name to use for explicitly requested inferior shell. (defvar explicit-shell-file-name nil (#$ . -3749)) #@113 *Args passed to inferior shell by M-x shell, if the shell is csh. Value is a list of strings, which may be nil. (defvar explicit-csh-args (byte-code "=‡Ç" [system-type hpux ("-i" "-T") ("-i")] 2) (#$ . -3881)) #@452 *If non-nil, expand input command history references on completion. This mirrors the optional behavior of tcsh (its autoexpand and histlit). If the value is `input', then the expansion is seen on input. If the value is `history', then the expansion is only when inserting into the buffer's input ring. See also `comint-magic-space' and `comint-dynamic-complete'. This variable supplies a default for `comint-input-autoexpand', for Shell mode only. (defvar shell-input-autoexpand (quote history) (#$ . -4105)) #@119 List of directories saved by pushd in this buffer's shell. Thus, this does not include the shell's current directory. (defvar shell-dirstack nil (#$ . 4624)) #@64 Non-nil in a shell buffer means directory tracking is enabled. (defvar shell-dirtrackp t (#$ . 4788)) #@54 Keep track of last directory for ksh `cd -' command. (defvar shell-last-dir nil (#$ . 4896)) #@56 Command used by `shell-resync-dir' to query the shell. (defvar shell-dirstack-query nil (#$ . 4995)) (byte-code "! B L  # # # # \"!# \"$ \"$‡" [boundp shell-mode-map nil current-load-list make-sparse-keymap comint-mode-map define-key "" shell-forward-command "" shell-backward-command " " comint-dynamic-complete "" comint-dynamic-list-filename-completions [menu-bar completion] copy-keymap lookup-key [menu-bar completion] define-key-after [menu-bar completion] [complete-env-variable] ("Complete Env. Variable Name" . shell-dynamic-complete-environment-variable) complete-file [menu-bar completion] [expand-directory] ("Expand Directory Reference" . shell-replace-by-expanded-directory) complete-expand] 7) #@35 *Hook for customising Shell mode. (defvar shell-mode-hook nil (#$ . -5768)) #@52 Additional expressions to highlight in Shell mode. (defvar shell-font-lock-keywords (byte-code "BF" [shell-prompt-pattern font-lock-keyword-face ("[ ]\\([+-][^ \n]+\\)" 1 font-lock-comment-face) ("^[^ \n]+:.*" . font-lock-string-face) ("^\\[[1-9][0-9]*\\]" . font-lock-string-face)] 4) (#$ . 5850)) #@2711 Major mode for interacting with an inferior shell. \[comint-send-input] after the end of the process' output sends the text from the end of process to the end of the current line. \[comint-send-input] before end of process output copies the current line minus the prompt to the end of the buffer and sends it (\[comint-copy-old-input] just copies the current line). \[send-invisible] reads a line of text without echoing it, and sends it to the shell. This is useful for entering passwords. Or, add the function `comint-watch-for-password-prompt' to `comint-output-filter-functions'. If you want to make multiple shell buffers, rename the `*shell*' buffer using \[rename-buffer] or \[rename-uniquely] and start a new shell. If you want to make shell buffers limited in length, add the function `comint-truncate-buffer' to `comint-output-filter-functions'. If you accidentally suspend your process, use \[comint-continue-subjob] to continue it. `cd', `pushd' and `popd' commands given to the shell are watched by Emacs to keep this buffer's default directory the same as the shell's working directory. While directory tracking is enabled, the shell's working directory is displayed by \[list-buffers] or \[mouse-buffer-menu] in the `File' field. \[dirs] queries the shell and resyncs Emacs' idea of what the current directory stack is. \[dirtrack-toggle] turns directory tracking on and off. \{shell-mode-map} Customization: Entry to this mode runs the hooks on `comint-mode-hook' and `shell-mode-hook' (in that order). Before each input, the hooks on `comint-input-filter-functions' are run. After each shell output, the hooks on `comint-output-filter-functions' are run. Variables `shell-cd-regexp', `shell-pushd-regexp' and `shell-popd-regexp' are used to match their respective commands, while `shell-pushd-tohome', `shell-pushd-dextract' and `shell-pushd-dunique' control the behavior of the relevant command. Variables `comint-completion-autolist', `comint-completion-addsuffix', `comint-completion-recexact' and `comint-completion-fignore' control the behavior of file name, command name and variable name completion. Variable `shell-completion-execonly' controls the behavior of command name completion. Variable `shell-completion-fignore' is used to initialise the value of `comint-completion-fignore'. Variables `comint-input-ring-file-name' and `comint-input-autoexpand' control the initialisation of the input ring history, and history expansion. Variables `comint-output-filter-functions', a hook, and `comint-scroll-to-bottom-on-input' and `comint-scroll-to-bottom-on-output' control whether input and output cause the window to scroll to the end of the buffer. (defalias 'shell-mode #[nil " ! \n \f !!!!$!!!p!!@!%!|%蘃p|%ꘃ{|--!𚃐-%\"5)!!" [comint-mode shell-mode major-mode "Shell" mode-name use-local-map shell-mode-map shell-prompt-pattern comint-prompt-regexp shell-completion-fignore comint-completion-fignore shell-delimiter-argument-list comint-delimiter-argument-list shell-file-name-quote-list comint-file-name-quote-list shell-dynamic-complete-functions comint-dynamic-complete-functions make-local-variable paragraph-start font-lock-defaults (shell-font-lock-keywords t) shell-dirstack nil shell-last-dir shell-dirtrackp t add-hook comint-input-filter-functions shell-directory-tracker shell-input-autoexpand comint-input-autoexpand list-buffers-directory expand-file-name default-directory file-name-nondirectory process-command get-buffer-process shell getenv "HISTFILE" "bash" "~/.bash_history" "ksh" "~/.sh_history" "~/.history" comint-input-ring-file-name "" file-truename "/dev/null" string-match "^k?sh$" "pwd" "dirs" shell-dirstack-query run-hooks shell-mode-hook comint-read-input-ring] 6 (#$ . 6166) nil]) #@1025 Run an inferior shell, with I/O through buffer *shell*. If buffer exists but shell process is not running, make new shell. If buffer exists and shell process is running, just switch to buffer `*shell*'. Program used comes from variable `explicit-shell-file-name', or (if that is nil) from the ESHELL environment variable, or else from SHELL if there is no ESHELL. If a file `~/.emacs_SHELLNAME' exists, it is given as initial input (Note that this may lose due to a timing error if the shell discards input when it starts up.) The buffer is put in Shell mode, giving commands for sending input and controlling the subjobs of the shell. See `shell-mode'. See also the variable `shell-prompt-pattern'. The shell file name (sans directories) is used to make a symbol name such as `explicit-csh-args'. If that symbol is a variable, its value is used as a list of arguments when invoking the shell. Otherwise, one argument `-i' is passed to the shell. (Type \[describe-mode] in the shell buffer for a list of commands.) (defalias 'shell #[nil "!c\n!!!  P  Q! !@ R!RJS%qp )!-!" [comint-check-proc "*shell*" explicit-shell-file-name getenv "ESHELL" "SHELL" "/bin/sh" prog file-name-nondirectory name "~/.emacs_" startfile intern-soft "explicit-" "-args" xargs-name nil shell-buffer apply make-comint "shell" file-exists-p boundp ("-i") shell-mode pop-to-buffer] 7 (#$ . 10073) nil]) #@641 Tracks cd, pushd and popd commands issued to the shell. This function is called on each input passed to the shell. It watches for cd, pushd and popd commands and sets the buffer's default directory to track these commands. You may toggle this tracking on and off with M-x dirtrack-toggle. If emacs gets confused, you can resync with the shell with M-x dirs. See variables `shell-cd-regexp', `shell-pushd-regexp', and `shell-popd-regexp', while `shell-pushd-tohome', `shell-pushd-dextract' and `shell-pushd-dunique' control the behavior of the relevant command. Environment variables are expanded, see function `substitute-in-file-name'. (defalias 'shell-directory-tracker #[(str) "Ï" [shell-dirtrackp chdir-failure (byte-code "\n\"Õĉ \n#Õ\nOÉ#\nOˉ# Q\"K !!rQ\"` !!rQ\"r !!\n#Õ," [string-match "^[; ]*" str 0 nil arg1 cmd end start shell-command-regexp comint-arguments 1 "\\`\\(" shell-popd-regexp "\\)\\($\\|[ ]\\)" shell-process-popd substitute-in-file-name shell-pushd-regexp shell-process-pushd shell-cd-regexp shell-process-cd "[; ]*"] 4) ((error "Couldn't cd"))] 3 (#$ . 11538)]) (defalias 'shell-process-popd #[(arg) " !‰# U#\f#\f@!\fA S P VP \fGXP\fB S AAA *S!)" [shell-extract-num arg 0 num shell-dirstack shell-cd shell-dirstack-message nil ds cell error "Couldn't popd"] 3]) (defalias 'shell-prefixed-directory-name #[(dir) "GU \n\n!\nP\n!" [comint-file-name-prefix 0 dir file-name-absolute-p expand-file-name] 2]) (defalias 'shell-process-cd #[(arg) "GU \nPĘ !! )" [arg 0 comint-file-name-prefix "~" "-" shell-last-dir shell-prefixed-directory-name new-dir default-directory shell-cd shell-dirstack-message] 2]) (defalias 'shell-process-pushd #[(arg) " ! GU;\fP!5 \n@!\nAB )!\n\nGVN!\nU\\!!|\nS8 ! !! ) BG\n\nZ!!\"@!A -  !!B ))" [shell-extract-num arg num 0 shell-pushd-tohome shell-process-pushd comint-file-name-prefix "~" shell-dirstack default-directory old shell-cd shell-dirstack-message message "Directory stack empty." "Directory stack not that deep." error "Couldn't cd." shell-pushd-dextract dir shell-process-popd ds dslen front reverse back append new-ds old-wd shell-prefixed-directory-name shell-pushd-dunique] 5]) (defalias 'shell-extract-num #[(str) "\n\"\n\n!" [string-match "^\\+[1-9][0-9]*$" str string-to-int] 3]) #@55 Turn directory tracking on and off in a shell buffer. (defalias 'shell-dirtrack-toggle #[nil "?\f Ƃ\"" [shell-dirtrackp default-directory list-buffers-directory nil message "Directory tracking %s" "ON" "OFF"] 3 (#$ . 14137) nil]) (defalias (quote dirtrack-toggle) (quote shell-dirtrack-toggle)) #@58 Do normal `cd' to DIR, and set `list-buffers-directory'. (defalias 'shell-cd #[(dir) "\n !! !" [shell-dirtrackp file-name-as-directory expand-file-name dir list-buffers-directory cd] 3 (#$ . 14460)]) #@496 Resync the buffer's idea of the current directory stack. This command queries the shell with the command bound to `shell-dirstack-query' (default "dirs"), reads the next line output and parses it to form the new directory stack. DON'T issue this command unless the buffer is at a shell prompt. Also, note that if some other subprocess decides to do output immediately after the query, its output will be taken as the new directory stack -- you lose. If this happens, just do the command again. (defalias 'shell-resync-dirs #[nil "p! !b\fcc! \f\" \" `ɓ`\nc!!? !\nb.) b!ǔǕS{GW#̔̕OPBǕZُ." [get-buffer-process proc process-mark pmark shell-dirstack-query "\n" sit-for 0 comint-send-string nil pt backward-char 1 looking-at ".+\n" accept-process-output delete-char dl dl-len ds i string-match "\\s *\\(\\S +\\)\\s *" comint-file-name-prefix (byte-code " @! A " [shell-cd ds shell-dirstack shell-dirstack-message] 2) ((error (message "Couldn't cd.")))] 5 (#$ . 14675) nil]) (defalias (quote dirs) (quote shell-resync-dirs)) (defalias 'shell-dirstack-message #[nil "\n BP!G \fu\f@\nG Y8\n O8\n OP\nf\nGGYf\nGOf\nGO\nf\f\n \n!Q\fA) !," ["" msg default-directory shell-dirstack ds expand-file-name comint-file-name-prefix "~/" home homelen dir 0 nil directory-file-name " " message] 5]) #@94 Move forward across ARG shell command(s). Does not cross lines. See `shell-command-regexp'. (defalias 'shell-forward-command #[(&optional arg) "`) P $!)" [nil limit re-search-forward shell-command-regexp "\\([;&|][ ]*\\)+" move arg skip-syntax-backward " "] 5 (#$ . 16126) "p"]) #@95 Move backward across ARG shell command(s). Does not cross lines. See `shell-command-regexp'. (defalias 'shell-backward-command #[(&optional arg) "!`)`Vy`)\n\" \"\n $/̔bw)" [comint-bol nil limit 0 skip-syntax-backward " " re-search-backward format "[;&|]+[ ]*\\(%s\\)" shell-command-regexp move arg 1 ";&|"] 6 (#$ . 16429) "p"]) #@458 Dynamically complete the command at point. This function is similar to `comint-dynamic-complete-filename', except that it searches `exec-path' (minus the trailing emacs library path) for completion candidates. Note that this may not be the same as the shell's idea of the path. Completion is dependent on the value of `shell-completion-execonly', plus those that effect file completion. See `shell-dynamic-complete-as-command'. Returns t if successful. (defalias 'shell-dynamic-complete-command #[nil " ( Ď \"*?(ǔ!`)=(! )" [comint-match-partial-filename filename match-data match-data ((store-match-data match-data)) string-match "[~/]" 0 shell-backward-command 1 message "Completing command name..." shell-dynamic-complete-as-command] 4 (#$ . 16795) nil]) #@110 Dynamically complete at point as a command. See `shell-dynamic-complete-filename'. Returns t if successful. (defalias 'shell-dynamic-complete-as-command #[nil " \n!!A\n!! \f%\f#@D!!!T\f\"@P|\" !!BAZA;\f\")!> !c!. " [comint-match-partial-filename "" filename file-name-nondirectory pathnondir reverse exec-path paths file-name-as-directory expand-file-name default-directory cwd comint-completion-fignore mapconcat #[(x) " !P" [regexp-quote x "$"] 2] "\\|" ignored-extensions path nil comps-in-path file filepath completions comint-directory "." file-accessible-directory-p file-name-all-completions string-match file-directory-p shell-completion-execonly file-executable-p comint-completion-addsuffix comint-dynamic-simple-complete success (sole shortest) " "] 5 (#$ . 17587)]) #@55 Return the variable at point, or nil if non is found. (defalias 'shell-match-partial-variable #[nil "`#!ul!?)\"˔˕{*" [limit re-search-backward "[^A-Za-z0-9_{}]" nil move looking-at "\\$" 1 "[^A-Za-z0-9_{}$]" re-search-forward "\\$?{?[A-Za-z0-9_]*}?" 0] 4 (#$ . 18544)]) #@738 Dynamically complete the environment variable at point. Completes if after a variable, i.e., if it starts with a "$". See `shell-dynamic-complete-as-environment-variable'. This function is similar to `comint-dynamic-complete-filename', except that it searches `process-environment' for completion candidates. Note that this may not be the same as the interpreter's idea of variable names. The main problem with this type of completion is that `process-environment' is the environment which Emacs started with. Emacs does not track changes to the environment made by the interpreter. Perhaps it would be more accurate if this function was called `shell-dynamic-complete-process-environment-variable'. Returns non-nil if successful. (defalias 'shell-dynamic-complete-environment-variable #[nil "  \"! )" [shell-match-partial-variable variable string-match "^\\$" message "Completing variable name..." shell-dynamic-complete-as-environment-variable] 4 (#$ . 18851) nil]) #@153 Dynamically complete at point as an environment variable. Used by `shell-dynamic-complete-environment-variable'. Uses `comint-dynamic-simple-complete'. (defalias 'shell-dynamic-complete-as-environment-variable #[nil " \n\"O\n\" \f \f \">x \n\"O\n\"GӂS\n\"RՂS ^n!!!mڂn,." [shell-match-partial-variable "" var string-match "[^$({]\\|$" 0 nil variable mapcar #[(x) "\"O" [x 0 string-match "="] 5] process-environment variables comint-completion-addsuffix addsuffix comint-dynamic-simple-complete success (sole shortest) "[^$({]" "{" "}" "(" ")" protection file-directory-p comint-directory getenv "/" " " suffix] 5 (#$ . 19848)]) #@181 Expand directory stack reference before point. Directory stack references are of the form "=digit" or "=-". See `default-directory' and `shell-dirstack'. Returns t if successful. (defalias 'shell-replace-by-expanded-directory #[nil " Ub\n B! G%!%Ȕȕ{! \n 2˂T \nGYA!T \n8!Љ# \"+" [comint-match-partial-filename 0 default-directory shell-dirstack looking-at "=-/?" "=\\([0-9]+\\)" string-to-number 1 index stack nil error "Directory stack not that deep." replace-match file-name-as-directory t message "Directory item: %d"] 4 (#$ . 20574) nil]) (provide (quote shell))