unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#9647: dirtrack.el patch to support prefixed paths, e.g. tramp remote shells
@ 2011-10-01 21:09 Ryan Barrett
  2011-10-09  9:52 ` Michael Albinus
  0 siblings, 1 reply; 6+ messages in thread
From: Ryan Barrett @ 2011-10-01 21:09 UTC (permalink / raw)
  To: 9647; +Cc: Juanma Barranquero

[-- 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
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWX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yjgp0RZMstMXJ9C4q48Cb
QZEUeHFIXBSvA9Cxw+E61ipUYsyuHMmgT0mohEZl9mOVFCOqVoreK4LTYoBcDfXBYBfOjXb8oGKU
vStKkrZD2qjFpA6ZkL6nzGr69Lqdpw8ik+FnSrcxv1a4MzagfUrYQqCgVU1sdNaIu/0uydRIvnKW
Q87CdPKsxmkFc4oDmZ1s4TQ1PcoS69VWtqvx38lx0Ys1GxLqoC3K7BYB4FfhrJ7lempChWgvVN8M
lu/K9RbYCGIPAXckU4UJB6ZMQVA=

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#9647: dirtrack.el patch to support prefixed paths, e.g. tramp remote shells
  2011-10-01 21:09 bug#9647: dirtrack.el patch to support prefixed paths, e.g. tramp remote shells Ryan Barrett
@ 2011-10-09  9:52 ` Michael Albinus
  2011-10-10  2:17   ` Ryan Barrett
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Albinus @ 2011-10-09  9:52 UTC (permalink / raw)
  To: Ryan Barrett; +Cc: 9647, lekktu

Ryan Barrett <emacs@ryanb.org> writes:

> hi!

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.

This looks to me like a similar bug as bug #9616, which has been said to
be solved a week ago. Could you, please, check whether it is solved for
you as well?

> thanks in advance!

Best regards, Michael.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#9647: dirtrack.el patch to support prefixed paths, e.g. tramp remote shells
  2011-10-09  9:52 ` Michael Albinus
@ 2011-10-10  2:17   ` Ryan Barrett
  2011-10-16  8:40     ` Michael Albinus
  0 siblings, 1 reply; 6+ messages in thread
From: Ryan Barrett @ 2011-10-10  2:17 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 9647, lekktu

thanks for looking!

On Sun, Oct 9, 2011 at 2:52 AM, Michael Albinus <michael.albinus@gmx.de> wrote:
>
> This looks to me like a similar bug as bug #9616, which has been said to
> be solved a week ago. Could you, please, check whether it is solved for
> you as well?

i looked at http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9616 , and
this is a different bug. that one is for shell-dirtrack-mode (in
shell.el); mine is for dirtrack-mode (in dirtrack.el).

i synched to head and rebuilt, and the reproduction steps and patch i
posted still work.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#9647: dirtrack.el patch to support prefixed paths, e.g. tramp remote shells
  2011-10-10  2:17   ` Ryan Barrett
@ 2011-10-16  8:40     ` Michael Albinus
  2011-10-16 16:47       ` Ryan Barrett
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Albinus @ 2011-10-16  8:40 UTC (permalink / raw)
  To: Ryan Barrett; +Cc: 9647, lekktu

Ryan Barrett <emacs@ryanb.org> writes:

>> This looks to me like a similar bug as bug #9616, which has been said to
>> be solved a week ago. Could you, please, check whether it is solved for
>> you as well?
>
> i looked at http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9616 , and
> this is a different bug. that one is for shell-dirtrack-mode (in
> shell.el); mine is for dirtrack-mode (in dirtrack.el).
>
> i synched to head and rebuilt, and the reproduction steps and patch i
> posted still work.

I see.

However, I still don't know whether this shall be fixed in
dirtrack.el. Maybe it would be better if Tramp could support.

I do not use dirtrack.el myself, so I need some guidance from you to
reproduce. You wrote as recipe:

(shell-dirtrack-mode 0)
(set-variable 'dirtrack-list "[REGEX]")
(dirtrack-mode 1)

What do you use as "[REGEX]"? Shouldn't this be a list?

Remote shells as implemented by Tramp do not provide any directory
information in the prompt. By default, the prompt looks like this:

/sudo:root@hostname: #$ 

How do you customize that prompt?

Best regards, Michael.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#9647: dirtrack.el patch to support prefixed paths, e.g. tramp remote shells
  2011-10-16  8:40     ` Michael Albinus
@ 2011-10-16 16:47       ` Ryan Barrett
  2011-10-17 19:52         ` Michael Albinus
  0 siblings, 1 reply; 6+ messages in thread
From: Ryan Barrett @ 2011-10-16 16:47 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 9647, lekktu

On Sun, Oct 16, 2011 at 1:40 AM, Michael Albinus <michael.albinus@gmx.de> wrote:

> However, I still don't know whether this shall be fixed in
> dirtrack.el. Maybe it would be better if Tramp could support.

yeah, i understand that instinct. i think dirtrack may be the more
appropriate place, though.

notably, if you look at the patch, it doesn't actually depend on tramp
at all. it uses shell-prefixed-directory-name and
comint-file-name-prefix, which are generic mechanisms in shell and
comint, which dirtrack already depends on.

> (set-variable 'dirtrack-list "[REGEX]")
...
> What do you use as "[REGEX]"? Shouldn't this be a list?
>
> Remote shells as implemented by Tramp do not provide any directory
> information in the prompt. By default, the prompt looks like this:

tramp does use the user's shell and dotfiles on the remote machine,
but still, good points, the instructions needed more details. i use
tcsh with this dirtrack-list:

(set-variable 'dirtrack-list '(":\\([^ :>]*\\)> *$" 1 nil))

try that, and then run tcsh on the remote machine and run this:

set prompt="%m:%~%# "

that gives you a prompt that looks like this:

purgatory:~/foo/bar>





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#9647: dirtrack.el patch to support prefixed paths, e.g. tramp remote shells
  2011-10-16 16:47       ` Ryan Barrett
@ 2011-10-17 19:52         ` Michael Albinus
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Albinus @ 2011-10-17 19:52 UTC (permalink / raw)
  To: Ryan Barrett; +Cc: 9647, lekktu

Ryan Barrett <emacs@ryanb.org> writes:

> On Sun, Oct 16, 2011 at 1:40 AM, Michael Albinus <michael.albinus@gmx.de> wrote:
>
>> However, I still don't know whether this shall be fixed in
>> dirtrack.el. Maybe it would be better if Tramp could support.
>
> yeah, i understand that instinct. i think dirtrack may be the more
> appropriate place, though.
>
> notably, if you look at the patch, it doesn't actually depend on tramp
> at all. it uses shell-prefixed-directory-name and
> comint-file-name-prefix, which are generic mechanisms in shell and
> comint, which dirtrack already depends on.

You've convinced me. I've applied your patch to the trunk, slightly
modified.

Thanks, and best regards, Michael.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-10-17 19:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-01 21:09 bug#9647: dirtrack.el patch to support prefixed paths, e.g. tramp remote shells Ryan Barrett
2011-10-09  9:52 ` 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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).