+(defcustom shell-dir-cookie-re nil
+ "Regexp matching your prompt, including some part of the current directory.
+If your prompt includes the current directory or the last few elements of it,
+set this to a pattern that matches your prompt and whose subgroup 1 matches
+the directory part of it.
+This is used by `shell-dir-cookie-watcher' to try and use this info
+to track your current directory. It can be used instead of or in addition
+to `dirtrack-mode'."
+ :group 'shell
+ :type '(choice (const nil) regexp))
+
+
+(defun shell-completion-vars ()
+ "Setup completion vars for `shell-mode' and `read-shell-command'."
+ (set (make-local-variable 'comint-completion-fignore)
+ shell-completion-fignore)
+ (set (make-local-variable 'comint-delimiter-argument-list)
+ shell-delimiter-argument-list)
+ (set (make-local-variable 'comint-file-name-chars) shell-file-name-chars)
+ (set (make-local-variable 'comint-file-name-quote-list)
+ shell-file-name-quote-list)
+ (set (make-local-variable 'comint-dynamic-complete-functions)
+ shell-dynamic-complete-functions)
+ (set (make-local-variable 'pcomplete-parse-arguments-function)
+ ;; FIXME: This function should be moved to shell.el.
+ #'pcomplete-parse-comint-arguments)
+ (set (make-local-variable 'pcomplete-termination-string)
+ (cond ((not comint-completion-addsuffix) "")
+ ((stringp comint-completion-addsuffix)
+ comint-completion-addsuffix)
+ ((not (consp comint-completion-addsuffix)) " ")
+ (t (cdr comint-completion-addsuffix))))
+ ;; Don't use pcomplete's defaulting mechanism, rely on
+ ;; shell-dynamic-complete-functions instead.
+ (set (make-local-variable 'pcomplete-default-completion-function) #'ignore)
+ (setq comint-input-autoexpand shell-input-autoexpand)
+ ;; Not needed in shell-mode because it's inherited from comint-mode, but
+ ;; placed here for read-shell-command.
+ (add-hook 'completion-at-point-functions 'comint-completion-at-point nil t))
+