;;; Basic Procedures
+(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))
+
(put 'shell-mode 'mode-class 'special)
(define-derived-mode shell-mode comint-mode "Shell"
;; replace it with a process filter that watches for and strips out
;; these messages.
-(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'."
- :type '(choice (const nil) regexp))
-
(defun shell-dir-cookie-watcher (text)
;; This is fragile: the TEXT could be split into several chunks and we'd
;; miss it. Oh well. It's a best effort anyway. I'd expect that it's
((string-match "\\`\\(.*\\)\\(?:/.*\\)?\n\\(.*/\\)\\1\\(?:/.*\\)?\\'"
(setq text (concat dir "\n" default-directory)))
(shell-cd (concat (match-string 2 text) dir)))))))
-
(defun shell-directory-tracker (str)
"Tracks cd, pushd and popd commands issued to the shell.