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

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

Re: How to use connection-local variables with dired?


From: Michael Albinus
Subject: Re: How to use connection-local variables with dired?
Date: Wed, 25 Aug 2021 09:51:38 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Vladimir Nikishkin <lockywolf@gmail.com> writes:

> Hello, everyone

Hi Vladimir,

> I generally use dired to manage files, with `dired-listing-switches` set
> to "-lahD". This "-D" is GNU-specific, and while it makes dired work
> consistently, there is no "-D" option on non-GNU machines, which I also
> have a few.
>
> I would like to tell dired to use the switches without "-D" when
> connecting to the non-GNU machines, but I have not found a way to do so.
>
> E.g.:
>
> #+begin_src: elisp
> (connection-local-set-profile-variables 'remote-ksh
>                                         '((shell-file-name . "/bin/ksh")
>                                           (shell-command-switch . "-c")
>                                           (dired-listing-switches . "-lah")))
> (connection-local-set-profiles
>  '(:application tramp
>                 :machine "bsd-machine.example"
>                 :protocol "ssh")
>  'remote-ksh) ; works
>
>
> (connection-local-set-profiles
>  '(
>    :application dired
>                 :machine "bsd-machine.example"
>                 )
>  'remote-ksh) ; broken
> #+end_src
>
> The variables are, indeed, set correctly in the
> *tramp/bsd-machine.example* buffer, but not in the dired buffer, hence
> dired does not work.
>
> Is there some way to achieve what I want?

dired is not prepared to honor connection-local variables. However, the
Tramp manual explains this case in its FAQ section:

--8<---------------cut here---------------start------------->8---
   • Remote host does not understand default options for directory
     listing

     Emacs computes the ‘dired’ options based on the local host but if
     the remote host cannot understand the same ‘ls’ command, then set
     them with a hook as follows:

          (add-hook
           'dired-before-readin-hook
           (lambda ()
             (when (file-remote-p default-directory)
               (setq dired-actual-switches "-al"))))
--8<---------------cut here---------------end--------------->8---

You might extend the lambda to check for the host name in
default-directory, and apply this only for matching hosts. Something
like

(when (string-equal (file-remote-p default-directory 'host) 
"bsd-machine.example")

> Thanks everyone for help.

Best regards, Michael.



reply via email to

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