help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem w/Dir Tracking Code Snippet


From: gamename
Subject: Problem w/Dir Tracking Code Snippet
Date: Sun, 2 Mar 2008 10:17:22 -0800 (PST)
User-agent: G2/1.0

Hi,

 I can't get dir tracking to work correctly. Either the regex isn't
catching the prompt, or the prompt doesn't get read at the correct
time. Either way, it doesn't work. Can someone point me to what I'm
doing wrong?

My bash shell prompt is defined this way in .bashrc:

    export PS1='\h:\w\n> '

...which looks like this in practice (notice it is a 2-line prompt):

    tnsfc64:~/elisp
    >

I use this dir tracking code in my .emacs file:

    (defun my-current-directory (text)
      (if (string-match "\\w*:\\([^\n]+\\)\n> " text)
          (setq cur-dir (substring text (match-beginning 1) (match-end
1)))
        (cd cur-dir)
        (message "dir tracking %s" cur-dir)))

    (defun my-shell-setup ()
      "Track current directory"
      (add-hook 'comint-output-filter-functions 'my-current-directory
nil t))

    (setq shell-mode-hook 'my-shell-setup)

So, what am I doing wrong in the code?  I've tested the regex via re-
builder and it worked. Other suggestions?

Thanks,
-T




reply via email to

[Prev in Thread] Current Thread [Next in Thread]