;ELC ;;; compiled by rms@mole.gnu.ai.mit.edu on Sun Sep 11 21:10:22 1994 ;;; from file /home/fsf/rms/e19/lisp/shell.el ;;; emacs version 19.26.1. ;;; 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"))) (error "`/home/fsf/rms/e19/lisp/shell.el' was compiled for Emacs 19")) (require (quote comint)) (defvar shell-prompt-pattern "^[^#$%>\n]*[#$%>] *" "\ 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-completion-fignore nil "\ *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-delimiter-argument-list (quote (124 38 60 62 40 41 59)) "\ 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-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)) "\ 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-command-regexp "[^;&|\n]+" "\ *Regexp to match a single command within a pipeline. This is used for directory tracking and does not do a perfect job.") (defvar shell-completion-execonly t "\ *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-popd-regexp "popd" "\ *Regexp to match subshell commands equivalent to popd.") (defvar shell-pushd-regexp "pushd" "\ *Regexp to match subshell commands equivalent to pushd.") (defvar shell-pushd-tohome nil "\ *If non-nil, make pushd with no arg behave as \"pushd ~\" (like cd). This mirrors the optional behavior of tcsh.") (defvar shell-pushd-dextract nil "\ *If non-nil, make \"pushd +n\" pop the nth dir to the stack top. This mirrors the optional behavior of tcsh.") (defvar shell-pushd-dunique nil "\ *If non-nil, make pushd only add unique directories to the stack. This mirrors the optional behavior of tcsh.") (defvar shell-cd-regexp "cd" "\ *Regexp to match subshell commands equivalent to cd.") (defvar explicit-shell-file-name nil "\ *If non-nil, is file name to use for explicitly requested inferior shell.") (defvar explicit-csh-args (byte-code "Á=ƒ‡Ç" [system-type hpux ("-i" "-T") ("-i")] 2) "\ *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 shell-input-autoexpand (quote history) "\ *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-dirstack nil "\ List of directories saved by pushd in this buffer's shell. Thus, this does not include the shell's current directory.") (defvar shell-dirtrackp t "\ Non-nil in a shell buffer means directory tracking is enabled.") (defvar shell-last-dir nil "\ Keep track of last directory for ksh `cd -' command.") (defvar shell-dirstack-query nil "\ Command used by `shell-resync-dir' to query the shell.") (byte-code "ÀÁ!„ „<Ã\f!Å ÆÇ#ˆÅ ÈÉ#ˆÅ ÊË#ˆÅ ÌÍ#ˆÎÏ Ð\"ÑÒÓ$ˆÎÏ Ô\"ÕÖ×$ˆÂ‡" [boundp shell-mode-map nil copy-keymap comint-mode-map define-key "" shell-forward-command "" shell-backward-command " " comint-dynamic-complete "¿" comint-dynamic-list-filename-completions define-key-after lookup-key [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] 5) (defvar shell-mode-hook nil "\ *Hook for customising Shell mode.") (defalias 'shell-mode #[nil "À ˆÁÃÅ!ˆ \n \f ÏÐ!ˆÏÑ!ˆÒÒÏÔ!ˆÕÖ×Ø\"ˆÛÜÝp!!@!ßà!†eᘃYâ‚e㘃dä‚eå‰&皃pÒ&èé\"ƒ|ê‚}ë,)íî!ˆïÕ!‡" [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-dynamic-complete-functions comint-dynamic-complete-functions make-local-variable paragraph-start shell-dirstack nil shell-last-dir shell-dirtrackp t add-hook comint-input-filter-functions shell-directory-tracker shell-input-autoexpand comint-input-autoexpand file-name-nondirectory process-command get-buffer-process shell getenv "HISTFILE" "bash" "~/.bash_history" "ksh" "~/.sh_history" "~/.history" comint-input-ring-file-name "/dev/null" string-match "^k?sh$" "pwd" "dirs" shell-dirstack-query run-hooks shell-mode-hook comint-read-input-ring] 5 "\ Major mode for interacting with an inferior shell. Return after the end of the process' output sends the text from the end of process to the end of the current line. Return before end of process output copies the current line (except for the prompt) to the end of the buffer and sends it. M-x 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 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. M-x dirs queries the shell and resyncs Emacs' idea of what the current directory stack is. M-x 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." nil]) (defalias 'shell #[nil "ÀÁ!„V\n†ÃÄ!†ÃÅ!†ÆÈ! Ê P ÌÍ ÎQ!ÐÑÒÓ !…< ƒNÔ!ƒNJ‚OÕ%qˆÖ ˆ,×Á!‡" [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 apply make-comint "shell" file-exists-p boundp ("-i") shell-mode switch-to-buffer] 7 "\ 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.)" nil]) (defalias 'shell-directory-tracker #[(str) "…ÁÂÇ" [shell-dirtrackp chdir-failure (byte-code "ÀÁ\n\"ˆÃ•Ä‰‰À \n#…}ÕÊ\nOÉ#Ê\nOˉ#À\f\"Ã=ƒJÍÎ !!ˆ‚oÀ\"Ã=ƒ^ÐÎ !!ˆ‚oÀ\"Ã=ƒoÒÎ !!ˆÀÓ\n#ˆÃ•‚,‡" [string-match "^[;\\s ]*" 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 "[;\\s ]*"] 4) ((error "Couldn't cd"))] 3 "\ 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'."]) (byte-code "ÀÁÂ\"ˆÀÃÄ\"ˆÀÅÆ\"ˆÀÇÈ\"ˆÀÉÊ\"‡" [defalias shell-process-popd #[(arg) "À !†‰ƒ# ÂUƒ#\fƒ#Å\f@!ˆ\fAÆ ‚S ƒP ÂVƒP \fGXƒPÇ\fB S›‰ ‰AA¡ˆAÆ *‚SÊË!)‡" [shell-extract-num arg 0 num shell-dirstack cd shell-dirstack-message nil ds cell error "Couldn't popd"] 3] shell-prefixed-directory-name #[(dir) "GÁUƒ \n‡Ã\n!ƒ\nP‡Ä\n!‡" [comint-file-name-prefix 0 dir file-name-absolute-p expand-file-name] 2] shell-process-cd #[(arg) "GÁUƒ \nÃP‚Ęƒ ‚Æ!É!ˆÊ )‡" [arg 0 comint-file-name-prefix "~" "-" shell-last-dir shell-prefixed-directory-name new-dir default-directory cd shell-dirstack-message] 2] shell-process-pushd #[(arg) "À ! GÃUƒ;\fƒÅÇP!‚Ôƒ5 \nË@!ˆ\nABÌ )‚ÔÍÎ!‚Ô\n§ƒ³\nGVƒNÍÏ!‚Ô\nÃUƒ\\ÐÍÑ!!‚Ôƒ|\nS8Ô !ˆÅ !ˆË!ˆÌ )‚Ô B‰G\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 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] shell-extract-num #[(str) "ÀÁ\n\"…\nÃ\n!‡" [string-match "^\\+[1-9][0-9]*$" str string-to-int] 3]] 3) (defalias 'shell-dirtrack-toggle #[nil "?Áƒ ÂÄ\"‡" [shell-dirtrackp message "Directory tracking %s" "ON" "OFF"] 3 "\ Turn directory tracking on and off in a shell buffer." nil]) (defalias (quote dirtrack-toggle) (quote shell-dirtrack-toggle)) (defalias 'shell-resync-dirs #[nil "Àp! !‰bˆ\fcˆÅcˆÆÇ!ˆÈ \f\"ˆÈ Å\"ˆ `É“ˆ`\nÅcˆËÌ!ˆÍÎ!„?Ï !ˆ\nbˆ‚.) bˆÐÌ!ˆÇ”Ç•S{‰GÉÇÇWƒÕÖ#ˆ̔̕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à ‡" [cd ds shell-dirstack shell-dirstack-message] 2) ((error (message "Couldn't cd.")))] 5 "\ 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." nil]) (byte-code "ÀÁÂ\"ˆÀÃÄ\"‡" [defalias dirs shell-resync-dirs shell-dirstack-message #[nil "À\n BÅÇP!‰G \fƒu\f@‰\nG Yƒ8\nË O˜ƒ8Ç\n ÌOP\nƒf\nGGYƒf\nËGO˜ƒf\nGÌO‰\nƒf\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]] 3) (defalias 'shell-forward-command #[(&optional arg) "ŠÀˆ`) ÄP Å$…ÇÈ!)‡" [nil limit re-search-forward shell-command-regexp "\\([;&|][ ]*\\)+" move arg skip-syntax-backward " "] 5 "\ Move forward across ARG shell command(s). Does not cross lines. See `shell-command-regexp'." "p"]) (defalias 'shell-backward-command #[(&optional arg) "ŠÀÁ!ˆ`)‰`VƒŠÃyˆ`)ÄÅ\n\"ˆÆÇÈ \"\nÊ $…/Ì”bˆÍÁw)‡" [comint-bol nil limit 0 skip-syntax-backward " " re-search-backward format "[;&|]+[ ]*\\(%s\\)" shell-command-regexp move arg 1 ";&|"] 6 "\ Move backward across ARG shell command(s). Does not cross lines. See `shell-command-regexp'." "p"]) (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 "\ 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." nil]) (defalias 'shell-dynamic-complete-as-command #[nil "À †ÁÃ\n!Å!AÈÉ\n!! \f…%ÍÎ\fÏ#ÁÒÁÁÒƒ°È×@†DØ!!Ù!…TÚ\f\"‰ƒ§@P„žƒ|Û\"„ž ˜„‹Ü!„žƒ—Þ!ƒžBA‰„ZA‰„;Òà\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 "\ Dynamically complete at point as a command. See `shell-dynamic-complete-filename'. Returns t if successful."]) (defalias 'shell-match-partial-variable #[nil "Š`ÁÂÃÄ#ƒÅÆ!„Çuˆl†ÅÈ!?…)ÉÊ\"ˆË”Ë•{*‡" [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 "\ Return the variable at point, or nil if non is found."]) (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 "\ 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." nil]) (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 "\ Dynamically complete at point as an environment variable. Used by `shell-dynamic-complete-environment-variable'. Uses `comint-dynamic-simple-complete'."]) (defalias 'shell-replace-by-expanded-directory #[nil "À …UŠÁ”bˆ\n BÄÅ!ƒ G‚%ÄÆ!…%ÇȔȕ{! \n „2Ë‚T \nGYƒAÌÍ!‚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 "\ 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." nil]) (defalias 'shell-strip-ctrl-m #[(&optional string) "ÀÁp!!Štƒ ‚\fbˆÅÆ\nÇ#…#ÈÉlj#ˆ‚*‡" [process-mark get-buffer-process pmark comint-last-input-end comint-last-output-start re-search-forward " +$" t replace-match ""] 4 "\ Strip trailing `^M' characters from the current output group. This function could be in the list `comint-output-filter-functions' or bound to a key." nil]) (provide (quote shell))