I'm trying to use tabbar to setup groups for each remote host where I have buffers open. I need to get the full buffer name, so I can parse the hostname to set the group name.

I've figured out how to do everything I want, except for when using tramp and dired.

When I initially open /ssh:dev:/home/fandingo/, I get some strange values for dired-directory and default-directory:

 (default-directory .
   #("/ssh:fandingo@dev:/home/fandingo/" 5 12
     (tramp-default t)))

 (dired-directory .
                  #("/ssh:fandingo@dev:/home/fandingo/" 5 12
                    (tramp-default t)))

(I used M-x pp-eval-expression RET (buffer-local-variables) RET to get this info.)

If I navigate to a directory within this buffer (say elisp/), these variables become "normal:"

 (default-directory . "/ssh:fandingo@dev:/home/fandingo/elisp/")

 (dired-directory . "/ssh:fandingo@dev:/home/fandingo/elisp/")

If I go up (..) to the original directory, things go back to the weird values.

What variable or function can I use to consistently get the full tramp path, regardless of whether I've navigated anywhere or not in the dired buffer?

Alternatively, how can I transparently handle both data structures to get the tramp path? I'm not sure I even understand what Emacs is returning in the originally visited directory (It's not a list, or at least I couldn't car it.).

GNU Emacs 24.5.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.16.6)

  • Here is a related thread to test for a particular remote host: stackoverflow.com/questions/24481381/…
    – lawlist
    Commented Dec 16, 2015 at 19:16
  • 1
    The form #("/ssh:fandingo@dev:/home/fandingo/" 5 12 (tramp-default t)) is how Emacs writes a string that has text properties. This is just the string "/ssh:fandingo@dev:/home/fandingo/", but with text property tramp-default with value t. You can use that string anywhere, as an ordinary string. This is just the way Emacs prints the value of a propertized string.
    – Drew
    Commented Dec 16, 2015 at 19:28
  • 1
    Wrt having different remote directories set up ahead of time: Instead of using tab bar for this, consider using bookmarks. You can bookmark a Dired buffer, including one for a remote directory. "Jumping" to a Dired bookmark just opens Dired on that directory.
    – Drew
    Commented Dec 16, 2015 at 19:30
  • Wow, elisp continues to blow me away. That's really cool. Thanks for the info @Drew!
    – fandingo
    Commented Dec 17, 2015 at 5:10
  • Emacs strings can be pretty cool. Just as symbols have a property list, where you can store any info you like, the same is true of Emacs-Lisp strings. Both Lisp symbols and Emacs-Lisp strings are objects of a sort. An odd feature, especially for strings, but one that can actually be pretty handy.
    – Drew
    Commented Dec 17, 2015 at 5:58

1 Answer 1


As Drew wrote, you see strings with text properties. If you worry about, use (substring-no-properties default-directory) and (substring-no-properties dired-directory)

  • That's really neat. Thanks for the info1
    – fandingo
    Commented Dec 17, 2015 at 5:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.