;; 1) Set your shell's prompt to contain the current working directory.
;; You may need to consult your shell's documentation to find out how to
;; do this.
;; 1) Set your shell's prompt to contain the current working directory.
;; You may need to consult your shell's documentation to find out how to
;; do this.
;; therefore it is *VERY IMPORTANT* for your prompt to be easily
;; distinguishable from other output. If your prompt regexp is too general,
;; you will see error messages from the dirtrack filter as it attempts to cd
;; therefore it is *VERY IMPORTANT* for your prompt to be easily
;; distinguishable from other output. If your prompt regexp is too general,
;; you will see error messages from the dirtrack filter as it attempts to cd
;; 2) Set the variable `dirtrack-list' to an appropriate value. This
;; should be a list of two elements: the first is a regular expression
;; which matches your prompt up to and including the pathname part.
;; 2) Set the variable `dirtrack-list' to an appropriate value. This
;; should be a list of two elements: the first is a regular expression
;; which matches your prompt up to and including the pathname part.
;; match to extract only the pathname. If you use a multi-line prompt,
;; add 't' as a third element. Note that some of the functions in
;; 'comint.el' assume a single-line prompt (eg, comint-bol).
;; match to extract only the pathname. If you use a multi-line prompt,
;; add 't' as a third element. Note that some of the functions in
;; 'comint.el' assume a single-line prompt (eg, comint-bol).
;; Determining this information may take some experimentation. Setting
;; the variable `dirtrack-debug' may help; it causes the directory-tracking
;; filter to log messages to the buffer `dirtrack-debug-buffer'. You can easily
;; toggle this setting with the `dirtrack-debug-toggle' function.
;; Determining this information may take some experimentation. Setting
;; the variable `dirtrack-debug' may help; it causes the directory-tracking
;; filter to log messages to the buffer `dirtrack-debug-buffer'. You can easily
;; toggle this setting with the `dirtrack-debug-toggle' function.
;; 'dirtrack-list' is set to (list "^\\([/~].*\\)\nemacs@[^%]+% *" 1 t)
;;
;; I'd appreciate other examples from people who use this package.
;; 'dirtrack-list' is set to (list "^\\([/~].*\\)\nemacs@[^%]+% *" 1 t)
;;
;; I'd appreciate other examples from people who use this package.
;; It might be worth mentioning in your file that emacs sources start up
;; files of the form: ~/.emacs_<SHELL> where <SHELL> is the name of the
;; shell. So for example, I have the following in ~/.emacs_tcsh:
;; It might be worth mentioning in your file that emacs sources start up
;; files of the form: ~/.emacs_<SHELL> where <SHELL> is the name of the
;; shell. So for example, I have the following in ~/.emacs_tcsh:
;; I run LOTS of shell buffers through Emacs, sometimes as different users
;; (eg, when logged in as myself, I'll run a root shell in the same Emacs).
;; If you do this, and the shell prompt contains a ~, Emacs will interpret
;; I run LOTS of shell buffers through Emacs, sometimes as different users
;; (eg, when logged in as myself, I'll run a root shell in the same Emacs).
;; If you do this, and the shell prompt contains a ~, Emacs will interpret
(defcustom dirtrack-list (list "^emacs \\([a-zA-Z]:.*\\)>" 1)
"*List for directory tracking.
First item is a regexp that describes where to find the path in a prompt.
(defcustom dirtrack-list (list "^emacs \\([a-zA-Z]:.*\\)>" 1)
"*List for directory tracking.
First item is a regexp that describes where to find the path in a prompt.
-Second is a number, the regexp group to match. Optional third item is
-whether the prompt is multi-line. If nil or omitted, prompt is assumed to
+Second is a number, the regexp group to match. Optional third item is
+whether the prompt is multi-line. If nil or omitted, prompt is assumed to
'dirtrack-windows-directory-function
'dirtrack-default-directory-function)
"*Function to apply to the prompt directory for comparison purposes."
'dirtrack-windows-directory-function
'dirtrack-default-directory-function)
"*Function to apply to the prompt directory for comparison purposes."
(defun dirtrack-windows-directory-function (dir)
"Return a canonical directory for comparison purposes.
(defun dirtrack-windows-directory-function (dir)
"Return a canonical directory for comparison purposes.
+(defun dirtrack-cygwin-directory-function (dir)
+ "Return a canonical directory taken from a Cygwin path for comparison purposes."
+ (if (string-match "/cygdrive/\\([A-Z]\\)\\(.*\\)" dir)
+ (concat (match-string 1 dir) ":" (match-string 2 dir))
+ dir))
+
(defconst dirtrack-forward-slash (regexp-quote "/"))
(defconst dirtrack-backward-slash (regexp-quote "\\"))
(defun dirtrack-replace-slash (string &optional opposite)
"Replace forward slashes with backwards ones.
(defconst dirtrack-forward-slash (regexp-quote "/"))
(defconst dirtrack-backward-slash (regexp-quote "\\"))
(defun dirtrack-replace-slash (string &optional opposite)
"Replace forward slashes with backwards ones.
If directory tracking does not seem to be working, you can use the
function `dirtrack-debug-toggle' to turn on debugging output.
If directory tracking does not seem to be working, you can use the
function `dirtrack-debug-toggle' to turn on debugging output.
;; Transform prompts into canonical forms
(setq prompt-path (funcall dirtrack-directory-function
prompt-path))
(setq current-dir (funcall dirtrack-canonicalize-function
current-dir))
(and dirtrack-debug
;; Transform prompts into canonical forms
(setq prompt-path (funcall dirtrack-directory-function
prompt-path))
(setq current-dir (funcall dirtrack-canonicalize-function
current-dir))
(and dirtrack-debug
(format "Not changing directory")))
;; It's possible that Emacs will think the directory
;; won't exist (eg, rlogin buffers)
(format "Not changing directory")))
;; It's possible that Emacs will think the directory
;; won't exist (eg, rlogin buffers)
(format "Changing directory to %s" prompt-path)))
(error "Directory %s does not exist" prompt-path)))
)))))
(format "Changing directory to %s" prompt-path)))
(error "Directory %s does not exist" prompt-path)))
)))))