all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ryan Barrett <emacs@ryanb.org>
To: 9647@debbugs.gnu.org
Cc: Juanma Barranquero <lekktu@gmail.com>
Subject: bug#9647: dirtrack.el patch to support prefixed paths, e.g. tramp remote shells
Date: Sat, 1 Oct 2011 14:09:41 -0700	[thread overview]
Message-ID: <CA+caGh8RtC0VHVKfsNRSjUkS1j2HDBdftJy3g8BSzsxZaYm=_w@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2488 bytes --]

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 #2: dirtrack_prefixed_paths.bundle.txt --]
[-- Type: text/plain, Size: 3293 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: ryanb@purgatory-20111001204821-fv5s4vthocfpzz7e
# target_branch: bzr://bzr.savannah.gnu.org/emacs/trunk/
# testament_sha1: 405f8b72d8bca3a91961477c6505ba0d1c3e077e
# timestamp: 2011-10-01 13:49:23 -0700
# base_revision_id: julien@danjou.info-20111001132215-ip6o7qyy6uu6h7lk
# 
# Begin patch
=== modified file 'lisp/dirtrack.el'
--- 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)))

# Begin bundle
IyBCYX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XBe0/EqxDrSyA8236F4lMYvfaoUOBVrJIFKO15KSqIkAfFwPiyjgp0RZMstMXJ9C4q48Cb
QZEUeHFIXBSvA9Cxw+E61ipUYsyuHMmgT0mohEZl9mOVFCOqVoreK4LTYoBcDfXBYBfOjXb8oGKU
vStKkrZD2qjFpA6ZkL6nzGr69Lqdpw8ik+FnSrcxv1a4MzagfUrYQqCgVU1sdNaIu/0uydRIvnKW
Q87CdPKsxmkFc4oDmZ1s4TQ1PcoS69VWtqvx38lx0Ys1GxLqoC3K7BYB4FfhrJ7lempChWgvVN8M
lu/K9RbYCGIPAXckU4UJB6ZMQVA=

             reply	other threads:[~2011-10-01 21:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-01 21:09 Ryan Barrett [this message]
2011-10-09  9:52 ` bug#9647: dirtrack.el patch to support prefixed paths, e.g. tramp remote shells Michael Albinus
2011-10-10  2:17   ` Ryan Barrett
2011-10-16  8:40     ` Michael Albinus
2011-10-16 16:47       ` Ryan Barrett
2011-10-17 19:52         ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+caGh8RtC0VHVKfsNRSjUkS1j2HDBdftJy3g8BSzsxZaYm=_w@mail.gmail.com' \
    --to=emacs@ryanb.org \
    --cc=9647@debbugs.gnu.org \
    --cc=lekktu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.