* How to use connection-local variables with dired?
@ 2021-08-25 3:14 Vladimir Nikishkin
2021-08-25 7:51 ` Michael Albinus
0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Nikishkin @ 2021-08-25 3:14 UTC (permalink / raw)
To: help-gnu-emacs
Hello, everyone
My problem is the following:
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?
Thanks everyone for help.
--
Your sincerely,
Vladimir Nikishkin (MiEr, lockywolf)
(Laptop)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: How to use connection-local variables with dired?
2021-08-25 3:14 How to use connection-local variables with dired? Vladimir Nikishkin
@ 2021-08-25 7:51 ` Michael Albinus
0 siblings, 0 replies; 2+ messages in thread
From: Michael Albinus @ 2021-08-25 7:51 UTC (permalink / raw)
To: Vladimir Nikishkin; +Cc: help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-25 7:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-25 3:14 How to use connection-local variables with dired? Vladimir Nikishkin
2021-08-25 7:51 ` Michael Albinus
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.