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

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

bug#9647: dirtrack.el patch to support prefixed paths, e.g. tramp remote


From: Ryan Barrett
Subject: bug#9647: dirtrack.el patch to support prefixed paths, e.g. tramp remote shells
Date: Sat, 1 Oct 2011 14:09:41 -0700

hi! i've attached a small patch to dirtrack.el that makes it support
shell buffers with path prefixes, e.g. tramp-based remote shells.
without this patch, it uses the local filesystem, which can be
particularly confusing because the local and remote filesystems
usually have some paths in common, but not all.

here are reproduction instructions (fill in [HOST] and [REGEX]):

(require 'tramp)
(require 'tramp-sh)
(let ((default-directory "/ssh:[HOST]:")) (shell))

;; run these with M-x eval-expression
(shell-dirtrack-mode 0)
(set-variable 'dirtrack-list "[REGEX]")
(dirtrack-mode 1)

now, in the remote shell, cd to a directory that doesn't exist on the
local filesystem. you'll see warnings like this:

Warning (emacs): Directory ... does not exist

and file completion won't work. this patch fixes that.


here's the proposed ChangeLog entry:

dirtrack-mode bugfix to support shell buffers with path prefixes, e.g.
tramp-based remote shells


i've attached a bzr bundle, and here's a diff:

--- lisp/dirtrack.el    2011-04-19 13:44:55 +0000
+++ lisp/dirtrack.el    2011-10-01 20:48:21 +0000
@@ -243,8 +243,9 @@
           (if (not (> (length prompt-path) 0))
               (dirtrack-debug-message "Match is empty string")
             ;; Transform prompts into canonical forms
-            (setq prompt-path (funcall dirtrack-directory-function
-                                       prompt-path)
+            (setq orig-prompt-path (funcall dirtrack-directory-function
+                                            prompt-path)
+                  prompt-path (shell-prefixed-directory-name orig-prompt-path)
                   current-dir (funcall dirtrack-canonicalize-function
                                        current-dir))
             (dirtrack-debug-message
@@ -257,8 +258,9 @@
               ;; It's possible that Emacs will think the directory
               ;; won't exist (eg, rlogin buffers)
               (if (file-accessible-directory-p prompt-path)
-                  ;; Change directory
-                  (and (shell-process-cd prompt-path)
+                  ;; Change directory. shell-process-cd adds the prefix, so we
+                  ;; need to give it the original (un-prefixed) path.
+                  (and (shell-process-cd orig-prompt-path)
                        (run-hooks 'dirtrack-directory-change-hook)
                        (dirtrack-debug-message
                         (format "Changing directory to %s" prompt-path)))


thanks in advance!

Attachment: dirtrack_prefixed_paths.bundle.txt
Description: Text document


reply via email to

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