all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Tramp and `dired-listing-switches'
@ 2023-12-07 14:50 Emanuel Berg
  2023-12-08  9:35 ` Michael Albinus
  2023-12-18  3:44 ` Emanuel Berg
  0 siblings, 2 replies; 24+ messages in thread
From: Emanuel Berg @ 2023-12-07 14:50 UTC (permalink / raw)
  To: emacs-devel

I'd like one setting for `dired-listing-switches' locally on
Debian and one remotely with Tramp, on an OpenBSD system.

If I use Tramp with the Debian setting (below), and list files
on the remote server I don't get any listing since the options
does not compute on what is another ls(1), not GNU ls but the BSD
(OpenBSD?) one.

[ OT: I never understood if all BSDs use the same toolchain or
  if they have different tools as well, if anyone knows that? ]

Anyway, I wrote this to cycle between sets of
`dired-listing-switches' options. Optimally, it would be done
automatically so one don't have to strike the command.
Maybe one can use `tramp-bsd-unames' and
`tramp-check-remote-uname' to automate it.

Cycling the sets works, but I don't know if that method is the
cleanest way to do it. It uses a lexical let-closure and
`setf', `cdr' and `last' to make it circular.

Also, after cycling, how can I revert the the dired buffer?
`revert-buffer' doesn't seem to do it, nothing happens, but
cycling the option, then killing the buffer and revisiting
it, works. Files are displayed with the new set in play.

(setq dired-listing-switches
  "-AGlX --group-directories-first -I \"*.meta\" -I \"#*#\" -I \"*.elc\"")

(let*((dired-ls-opts (list dired-listing-switches "-Al"))
      (_ (setf (cdr (last dired-ls-opts)) dired-ls-opts)) )
  (defun dired-ls-opts-cycle ()
    (interactive)
    (setq dired-listing-switches (pop dired-ls-opts)) )
  (declare-function dired-ls-opts-cycle nil)
  (defalias 'lc #'dired-ls-opts-cycle) )

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Tramp and `dired-listing-switches'
  2023-12-07 14:50 Tramp and `dired-listing-switches' Emanuel Berg
@ 2023-12-08  9:35 ` Michael Albinus
  2023-12-08 11:59   ` Eli Zaretskii
  2023-12-09 14:29   ` Emanuel Berg
  2023-12-18  3:44 ` Emanuel Berg
  1 sibling, 2 replies; 24+ messages in thread
From: Michael Albinus @ 2023-12-08  9:35 UTC (permalink / raw)
  To: emacs-devel

Emanuel Berg <incal@dataswamp.org> writes:

Hi Emanuel,

> I'd like one setting for `dired-listing-switches' locally on
> Debian and one remotely with Tramp, on an OpenBSD system.
>
> If I use Tramp with the Debian setting (below), and list files
> on the remote server I don't get any listing since the options
> does not compute on what is another ls(1), not GNU ls but the BSD
> (OpenBSD?) one.

The canonical way to achieve this are connection-local
variables. Unfortunately, dired does not support them (shell we extend
this?). Therefore, the Tramp manual describes an alternative:

--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

--8<---------------cut here---------------start------------->8---
(when (string-equal (file-remote-p default-directory 'host) "machine.example")
--8<---------------cut here---------------end--------------->8---

Best regards, Michael.



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

* Re: Tramp and `dired-listing-switches'
  2023-12-08  9:35 ` Michael Albinus
@ 2023-12-08 11:59   ` Eli Zaretskii
  2023-12-08 12:08     ` Michael Albinus
  2023-12-09 14:29   ` Emanuel Berg
  1 sibling, 1 reply; 24+ messages in thread
From: Eli Zaretskii @ 2023-12-08 11:59 UTC (permalink / raw)
  To: Michael Albinus; +Cc: emacs-devel

> From: Michael Albinus <michael.albinus@gmx.de>
> Date: Fri, 08 Dec 2023 10:35:32 +0100
> 
> > I'd like one setting for `dired-listing-switches' locally on
> > Debian and one remotely with Tramp, on an OpenBSD system.
> >
> > If I use Tramp with the Debian setting (below), and list files
> > on the remote server I don't get any listing since the options
> > does not compute on what is another ls(1), not GNU ls but the BSD
> > (OpenBSD?) one.
> 
> The canonical way to achieve this are connection-local
> variables. Unfortunately, dired does not support them (shell we extend
> this?)

I think so, yes.  Are there any downsides to such an extension?



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

* Re: Tramp and `dired-listing-switches'
  2023-12-08 11:59   ` Eli Zaretskii
@ 2023-12-08 12:08     ` Michael Albinus
  2023-12-10 11:43       ` Michael Albinus
  0 siblings, 1 reply; 24+ messages in thread
From: Michael Albinus @ 2023-12-08 12:08 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

Hi Eli,

>> The canonical way to achieve this are connection-local
>> variables. Unfortunately, dired does not support them (shell we extend
>> this?)
>
> I think so, yes.  Are there any downsides to such an extension?

I'm not aware of downsides. Will try to implement next days.

Best regards, Michael.



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

* Re: Tramp and `dired-listing-switches'
  2023-12-08  9:35 ` Michael Albinus
  2023-12-08 11:59   ` Eli Zaretskii
@ 2023-12-09 14:29   ` Emanuel Berg
  2023-12-09 15:33     ` tomas
  1 sibling, 1 reply; 24+ messages in thread
From: Emanuel Berg @ 2023-12-09 14:29 UTC (permalink / raw)
  To: emacs-devel

Michael Albinus wrote:

>> I'd like one setting for `dired-listing-switches' locally
>> on Debian and one remotely with Tramp, on an
>> OpenBSD system.
>>
>> If I use Tramp with the Debian setting (below), and list
>> files on the remote server I don't get any listing since
>> the options does not compute on what is another ls(1), not
>> GNU ls but the BSD (OpenBSD?) one.
>
> The canonical way to achieve this are connection-local
> variables. Unfortunately, dired does not support them (shell
> we extend this?). Therefore, the Tramp manual describes an
> alternative:
>
>    • 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"))))

That only worked one time?

But I re-wrote it like this, now it works, thanks!

(setq dired-listing-switches
  "-AGlX --group-directories-first -I \"*.meta\" -I \"#*#\" -I \"*.elc\"")

(add-hook 'dired-before-readin-hook
  (lambda ()
    (if (file-remote-p default-directory)
        (setq dired-actual-switches "-Al")
      (setq dired-actual-switches dired-listing-switches) )))

(Is there a typo in `dired-before-readin-hook' BTW?)

> 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)
>  "machine.example")

(file-remote-p default-directory 'host) is nil locally but the
remote host remotely, so that would work as well. But not
necessary if one only has one local system and one remote
server, right?

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Tramp and `dired-listing-switches'
  2023-12-09 14:29   ` Emanuel Berg
@ 2023-12-09 15:33     ` tomas
  2023-12-09 15:49       ` Emanuel Berg
  0 siblings, 1 reply; 24+ messages in thread
From: tomas @ 2023-12-09 15:33 UTC (permalink / raw)
  To: emacs-devel

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

On Sat, Dec 09, 2023 at 03:29:54PM +0100, Emanuel Berg wrote:

[...]

> (Is there a typo in `dired-before-readin-hook' BTW?)

No, cf. the docstring. It's "readin" as in "read in".

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: Tramp and `dired-listing-switches'
  2023-12-09 15:33     ` tomas
@ 2023-12-09 15:49       ` Emanuel Berg
  2023-12-09 16:10         ` Emanuel Berg
                           ` (3 more replies)
  0 siblings, 4 replies; 24+ messages in thread
From: Emanuel Berg @ 2023-12-09 15:49 UTC (permalink / raw)
  To: emacs-devel

tomas wrote:

>> (Is there a typo in `dired-before-readin-hook' BTW?)
>
> No, cf. the docstring. It's "readin" as in "read in".

Ugh, but then shouldn't it be "read-in"?

Anyway, bad news, the dired listing part works but when I hit
RET at a file I don't get to the file, maybe because those
public_html directories are symlinked?

I get this kind of message:

  Tramp: Checking ‘vc-registered’ for /sudo:root@ebc:/:/scp:incal@srv.dataswamp.org:/var/www/htdocs/dataswamp.org/~incal/sth/scripts/senior...done
  Use M-x make-directory RET RET to create the directory and its parents

Doing it like this works:

  (find-file "/-:incal@srv.dataswamp.org:public_html/sth/scripts/senior")

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Tramp and `dired-listing-switches'
  2023-12-09 15:49       ` Emanuel Berg
@ 2023-12-09 16:10         ` Emanuel Berg
  2023-12-09 16:53           ` Emanuel Berg
  2023-12-09 16:14         ` Emanuel Berg
                           ` (2 subsequent siblings)
  3 siblings, 1 reply; 24+ messages in thread
From: Emanuel Berg @ 2023-12-09 16:10 UTC (permalink / raw)
  To: emacs-devel

> Anyway, bad news, the dired listing part works but when
> I hit RET at a file I don't get to the file, maybe because
> those public_html directories are symlinked?
>
> I get this kind of message:
>
>   Tramp: Checking ‘vc-registered’ for
> /sudo:root@ebc:/:/scp:incal@srv.dataswamp.org:/var/www/htdocs/dataswamp.org/~incal/sth/scripts/senior...done
>   Use M-x make-directory RET RET to create the directory and its parents
>
> Doing it like this works:
>
>   (find-file "/-:incal@srv.dataswamp.org:public_html/sth/scripts/senior")

This is my whole Tramp config.

It says "sunos-ssh" - yes, I used to do this to
a SunOS system. But now I don't, so maybe that whole config is
out the window?

Or is it just a name, i.e., still in effect?

;;; -*- lexical-binding: t -*-
;;
;; this file:
;;   https://dataswamp.org/~incal/emacs-init/tramp-incal.el

(require 'tramp)
(require 'tramp-sh)

(setq tramp-histfile-override nil)

(add-to-list 'tramp-methods
  '("sunos-ssh"
    (tramp-login-program       "ssh")
    (tramp-login-args        (("-l" "%u")
                              ("-p" "%p")
                              ("%c")
                              ("-e" "none")
                              ("-t" "-t")
                              ("%h")
                              ("\"/bin/sh -i\"") ))
    (tramp-async-args        (("-q")))
    (tramp-remote-shell        "/bin/sh")
    (tramp-remote-shell-login ("-l"))
    (tramp-remote-shell-args  ("-c")) ))

(provide 'tramp-incal)

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Tramp and `dired-listing-switches'
  2023-12-09 15:49       ` Emanuel Berg
  2023-12-09 16:10         ` Emanuel Berg
@ 2023-12-09 16:14         ` Emanuel Berg
  2023-12-09 17:39         ` Michael Albinus
  2023-12-10 11:25         ` Benjamin Riefenstahl
  3 siblings, 0 replies; 24+ messages in thread
From: Emanuel Berg @ 2023-12-09 16:14 UTC (permalink / raw)
  To: emacs-devel

> Anyway, bad news, the dired listing part works but when
> I hit RET at a file I don't get to the file, maybe because
> those public_html directories are symlinked?

I.e., /home/incal/public_html is actually
/var/www/htdocs/dataswamp.org/~incal

> I get this kind of message:
>
>   Tramp: Checking ‘vc-registered’ for
> /sudo:root@ebc:/:/scp:incal@srv.dataswamp.org:/var/www/htdocs/dataswamp.org/~incal/sth/scripts/senior...done
>   Use M-x make-directory RET RET to create the directory and its parents

But it looks like it actually tries that?

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Tramp and `dired-listing-switches'
  2023-12-09 16:10         ` Emanuel Berg
@ 2023-12-09 16:53           ` Emanuel Berg
  2023-12-09 17:12             ` Emanuel Berg
  0 siblings, 1 reply; 24+ messages in thread
From: Emanuel Berg @ 2023-12-09 16:53 UTC (permalink / raw)
  To: emacs-devel

> It says "sunos-ssh" - yes, I used to do this to
> a SunOS system. But now I don't, so maybe that whole config is
> out the window?
>
> Or is it just a name, i.e., still in effect?

As long as you don't refer to it, it isn't used, right?

So I might as well throw that stuff away since I don't connect
to any SunOS system anymore.

But still don't know why going to individual files directly
works but not from dired.

I don't think it is a symlink issue, either.

But let me try something else then, hang on.

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Tramp and `dired-listing-switches'
  2023-12-09 16:53           ` Emanuel Berg
@ 2023-12-09 17:12             ` Emanuel Berg
  0 siblings, 0 replies; 24+ messages in thread
From: Emanuel Berg @ 2023-12-09 17:12 UTC (permalink / raw)
  To: emacs-devel

> But let me try something else then, hang on.

Yeah, I had a custom command to find files from dired, that's
why it didn't work. I removed it, whatever problem that solved
locally screwed things up remotely. Now it works remotely
as well.

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Tramp and `dired-listing-switches'
  2023-12-09 15:49       ` Emanuel Berg
  2023-12-09 16:10         ` Emanuel Berg
  2023-12-09 16:14         ` Emanuel Berg
@ 2023-12-09 17:39         ` Michael Albinus
  2023-12-10  5:23           ` Emanuel Berg
  2023-12-10 11:25         ` Benjamin Riefenstahl
  3 siblings, 1 reply; 24+ messages in thread
From: Michael Albinus @ 2023-12-09 17:39 UTC (permalink / raw)
  To: emacs-devel

Emanuel Berg <incal@dataswamp.org> writes:

Hi Emanuel,

>   Tramp: Checking ‘vc-registered’ for /sudo:root@ebc:/:/scp:incal@srv.dataswamp.org:/var/www/htdocs/dataswamp.org/~incal/sth/scripts/senior...done

I don't know what you're doing, but this isn't a valid Tramp file name.

Best regards, Michael.



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

* Re: Tramp and `dired-listing-switches'
  2023-12-09 17:39         ` Michael Albinus
@ 2023-12-10  5:23           ` Emanuel Berg
  0 siblings, 0 replies; 24+ messages in thread
From: Emanuel Berg @ 2023-12-10  5:23 UTC (permalink / raw)
  To: emacs-devel

Michael Albinus wrote:

>>   Tramp: Checking ‘vc-registered’ for
>> /sudo:root@ebc:/:/scp:incal@srv.dataswamp.org:/var/www/htdocs/dataswamp.org/~incal/sth/scripts/senior...done
>
> I don't know what you're doing, but this isn't a valid Tramp
> file name.

No kidding! It was the a custom `dired-find-file' that worked
locally but produced that bogus path when used on the server.

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Tramp and `dired-listing-switches'
  2023-12-09 15:49       ` Emanuel Berg
                           ` (2 preceding siblings ...)
  2023-12-09 17:39         ` Michael Albinus
@ 2023-12-10 11:25         ` Benjamin Riefenstahl
  2023-12-10 11:48           ` tomas
  3 siblings, 1 reply; 24+ messages in thread
From: Benjamin Riefenstahl @ 2023-12-10 11:25 UTC (permalink / raw)
  To: emacs-devel

Hi Emanuel,

Emanuel Berg writes:
>   Tramp: Checking ‘vc-registered’ for
> /sudo:root@ebc:/:/scp:incal@srv.dataswamp.org:/var/www/htdocs/dataswamp.org/~incal/sth/scripts/senior...done
>   Use M-x make-directory RET RET to create the directory and its parents
>
> Doing it like this works:
>
>   (find-file "/-:incal@srv.dataswamp.org:public_html/sth/scripts/senior")


> I.e., /home/incal/public_html is actually
> /var/www/htdocs/dataswamp.org/~incal

I don't think so.  "~incal" is the home directory of the user "incal".
But only, if "~incal" is the first part of a file name.

Also, if I take what you wrote above, namely that
"incal@srv.dataswamp.org:public_html" works, that means that
"public_html" is a subdirectory *inside* of the home directory of user
"incal".

Be not confused by how Apache re-uses this concept.  Apache makes the
*directory* "~incal/public_html" into the *URL*
"http://srv.dataswamp.org/~incal" without "public_html".  But that
mapping is not active in the underlying file system.

HTH, benny



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

* Re: Tramp and `dired-listing-switches'
  2023-12-08 12:08     ` Michael Albinus
@ 2023-12-10 11:43       ` Michael Albinus
  2023-12-12 20:07         ` Emanuel Berg
  0 siblings, 1 reply; 24+ messages in thread
From: Michael Albinus @ 2023-12-10 11:43 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Michael Albinus <michael.albinus@gmx.de> writes:

Hi Eli,

>>> The canonical way to achieve this are connection-local
>>> variables. Unfortunately, dired does not support them (shell we extend
>>> this?)
>>
>> I think so, yes.  Are there any downsides to such an extension?
>
> I'm not aware of downsides. Will try to implement next days.

Pushed to master. The Tramp manual explains now

--8<---------------cut here---------------start------------->8---
     Emacs computes the ‘dired’ options based on the local host.  Since
     Emacs 30, these options can be set connection-local.  *Note
     (emacs)Connection Variables::.

          (connection-local-set-profile-variables
            'my-dired-profile
            '((dired-listing-switches . "-ahl")))

          (connection-local-set-profiles
           '(:application tramp :machine "remotehost")
           'my-dired-profile)
--8<---------------cut here---------------end--------------->8---

Best regards, Michael.



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

* Re: Tramp and `dired-listing-switches'
  2023-12-10 11:25         ` Benjamin Riefenstahl
@ 2023-12-10 11:48           ` tomas
  2023-12-12 20:15             ` Emanuel Berg
  0 siblings, 1 reply; 24+ messages in thread
From: tomas @ 2023-12-10 11:48 UTC (permalink / raw)
  To: Benjamin Riefenstahl; +Cc: emacs-devel

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

On Sun, Dec 10, 2023 at 12:25:00PM +0100, Benjamin Riefenstahl wrote:
> Hi Emanuel,
> 
> Emanuel Berg writes:
> >   Tramp: Checking ‘vc-registered’ for
> > /sudo:root@ebc:/:/scp:incal@srv.dataswamp.org:/var/www/htdocs/dataswamp.org/~incal/sth/scripts/senior...done
> >   Use M-x make-directory RET RET to create the directory and its parents
> >
> > Doing it like this works:
> >
> >   (find-file "/-:incal@srv.dataswamp.org:public_html/sth/scripts/senior")
> 
> 
> > I.e., /home/incal/public_html is actually
> > /var/www/htdocs/dataswamp.org/~incal
> 
> I don't think so.  "~incal" is the home directory of the user "incal".
> But only, if "~incal" is the first part of a file name.

And only if you've told your web server to do this mapping for you
(for Apache, it's mod_userdir [1] and its config, lighttpd has a
module with the same name [2], and I'm sure nginx has that too.

It's the Web, so it's all smoke and mirrors.

Cheers

[1] https://httpd.apache.org/docs/2.4/mod/mod_userdir.html
[2] https://doc.lighttpd.net/lighttpd2/mod_userdir.html
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: Tramp and `dired-listing-switches'
  2023-12-10 11:43       ` Michael Albinus
@ 2023-12-12 20:07         ` Emanuel Berg
  2023-12-13  7:13           ` Michael Albinus
  0 siblings, 1 reply; 24+ messages in thread
From: Emanuel Berg @ 2023-12-12 20:07 UTC (permalink / raw)
  To: emacs-devel

Michael Albinus wrote:

> Pushed to master.

Good work! Fun to be part of as well :)

>           (connection-local-set-profile-variables
>             'my-dired-profile
>             '((dired-listing-switches . "-ahl")))
>
>           (connection-local-set-profiles
>            '(:application tramp :machine "remotehost")
>            'my-dired-profile)

I'll be happy to try this the next time I upgrade Emacs!

Should that be "remotehost" or should it be replaced by what
is returned by 

  (file-remote-p default-directory 'host)

on the remote system?

I liked that so much I made a function from it so you can just
do `M-x machine RET' to find out. Don't know if
`emacs-build-system' is appropriate for the local one?

;;; -*- lexical-binding: t -*-
;;
;; this file:
;;   https://dataswamp.org/~incal/emacs-init/remote.el

(require 'cl-lib)
(require 'url-parse)

(defun machine ()
  (interactive)
  (let ((name (or (file-remote-p default-directory 'host)
                  emacs-build-system) ))
    (prog1
        name
      (message "machine: %s" name) )))

(defun valid-url (url)
  (let ((data (url-generic-parse-url url)))
    (when (cl-struct-slot-value 'url 'type data)
      t) ))

;; (valid-url "https://dataswamp.org/~incal/") ; t
;; (valid-url "dataswamp.org/~incal/")         ; nil

(provide 'remote)

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Tramp and `dired-listing-switches'
  2023-12-10 11:48           ` tomas
@ 2023-12-12 20:15             ` Emanuel Berg
  0 siblings, 0 replies; 24+ messages in thread
From: Emanuel Berg @ 2023-12-12 20:15 UTC (permalink / raw)
  To: emacs-devel

tomas wrote:

>>> I.e., /home/incal/public_html is actually
>>> /var/www/htdocs/dataswamp.org/~incal
>> 
>> I don't think so. "~incal" is the home directory of the
>> user "incal". But only, if "~incal" is the first part of
>> a file name.
>
> And only if you've told your web server to do this mapping
> for you (for Apache, it's mod_userdir and its config,
> lighttpd has a module with the same name, and I'm sure nginx
> has that too.
>
> It's the Web, so it's all smoke and mirrors.

Actually I just did

  $ file public_html
  public_html: symbolic link to '/var/www/htdocs/dataswamp.org/~incal'

so I don't know how/why it is setup like that. But it is!

But again that wasn't the issue anyway. (Actually it was the
second theory as to why it didn't work that I presented in
this thread, and both were incorrect LOL.)

I got it to work with the below code, so one can use it until
one upgrades Emacs and get the sanctioned, built-in solution.
Which also should be better.

(setq dired-listing-switches
  "-AGlX --group-directories-first -I \"*.meta\" -I \"#*#\" -I \"*.elc\"")

(add-hook 'dired-before-readin-hook
  (lambda ()
    (if (file-remote-p default-directory)
        (setq dired-actual-switches "-Al")
      (setq dired-actual-switches dired-listing-switches) )))

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Tramp and `dired-listing-switches'
  2023-12-12 20:07         ` Emanuel Berg
@ 2023-12-13  7:13           ` Michael Albinus
  2023-12-17 20:05             ` Emanuel Berg
  2023-12-17 20:23             ` Emanuel Berg
  0 siblings, 2 replies; 24+ messages in thread
From: Michael Albinus @ 2023-12-13  7:13 UTC (permalink / raw)
  To: emacs-devel

Emanuel Berg <incal@dataswamp.org> writes:

Hi Emanuel,

>>           (connection-local-set-profile-variables
>>             'my-dired-profile
>>             '((dired-listing-switches . "-ahl")))
>>
>>           (connection-local-set-profiles
>>            '(:application tramp :machine "remotehost")
>>            'my-dired-profile)
>
> Should that be "remotehost" or should it be replaced by what
> is returned by
>
>   (file-remote-p default-directory 'host)
>
> on the remote system?

It's an example host name, so pls replace it with the real one. If you
don't care which host is meant, i.e. if you want the same setting for
all remote machines, you could shorten the specification to

--8<---------------cut here---------------start------------->8---
          (connection-local-set-profiles
           '(:application tramp)
           'my-dired-profile)
--8<---------------cut here---------------end--------------->8---

> I liked that so much I made a function from it so you can just
> do `M-x machine RET' to find out. Don't know if
> `emacs-build-system' is appropriate for the local one?

No, connection-local variables are not meant for the local machine. Here
the default value of the variable is used.

Best regards, Michael.



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

* Re: Tramp and `dired-listing-switches'
  2023-12-13  7:13           ` Michael Albinus
@ 2023-12-17 20:05             ` Emanuel Berg
  2023-12-18  9:11               ` Michael Albinus
  2023-12-17 20:23             ` Emanuel Berg
  1 sibling, 1 reply; 24+ messages in thread
From: Emanuel Berg @ 2023-12-17 20:05 UTC (permalink / raw)
  To: emacs-devel

Michael Albinus wrote:

> It's an example host name, so pls replace it with the real
> one. If you don't care which host is meant, i.e. if you want
> the same setting for all remote machines, you could shorten
> the specification to
>
>           (connection-local-set-profiles
>            '(:application tramp)
>            'my-dired-profile)

I tried this (code last) but it seem now I only get the
'-Al' behavior, local and remote.

Even as `dired-listing-switches' is reported, with 'C-h v', as
the expected

  "-AGlX --group-directories-first -I \"*.meta\" -I \"#*#\" -I \"*.elc\""

Maybe you pushed your change onto some other branch? I'm on this

GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, cairo version 1.16.0)
of 2023-12-17 [commit 4fc2fcb37d62748ef5fbaeddde91447de69bf2a6]

(setq dired-listing-switches
  "-AGlX --group-directories-first -I \"*.meta\" -I \"#*#\" -I \"*.elc\"")

(connection-local-set-profile-variables
 'my-dired-profile
 '((dired-listing-switches . "-Al")))

(connection-local-set-profiles
 '(:application tramp)
 'my-dired-profile)

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Tramp and `dired-listing-switches'
  2023-12-13  7:13           ` Michael Albinus
  2023-12-17 20:05             ` Emanuel Berg
@ 2023-12-17 20:23             ` Emanuel Berg
  1 sibling, 0 replies; 24+ messages in thread
From: Emanuel Berg @ 2023-12-17 20:23 UTC (permalink / raw)
  To: emacs-devel

> branch [...]

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

Install commands:

  https://dataswamp.org/~incal/conf/.zsh/install-emacs

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Tramp and `dired-listing-switches'
  2023-12-07 14:50 Tramp and `dired-listing-switches' Emanuel Berg
  2023-12-08  9:35 ` Michael Albinus
@ 2023-12-18  3:44 ` Emanuel Berg
  2024-01-09  5:22   ` Emanuel Berg
  1 sibling, 1 reply; 24+ messages in thread
From: Emanuel Berg @ 2023-12-18  3:44 UTC (permalink / raw)
  To: emacs-devel

> Cycling the sets works, but I don't know if that method is
> the cleanest way to do it. It uses a lexical let-closure and
> `setf', `cdr' and `last' to make it circular [...]
>
> (setq dired-listing-switches
>   "-AGlX --group-directories-first -I \"*.meta\" -I \"#*#\" -I \"*.elc\"")
>
> (let*((dired-ls-opts (list dired-listing-switches "-Al"))
>       (_ (setf (cdr (last dired-ls-opts)) dired-ls-opts)) )
>   (defun dired-ls-opts-cycle ()
>     (interactive)
>     (setq dired-listing-switches (pop dired-ls-opts)) )
>   (declare-function dired-ls-opts-cycle nil)
>   (defalias 'lc #'dired-ls-opts-cycle) )

I had a feeling there was a better way to do the cycling part.
Here it is, much cleaner than the method above.

(let*((clist '#1=(1 2 3 4 5 6 . #1#)))
  (defun next ()
    (pop clist) ))

;; (next)

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Tramp and `dired-listing-switches'
  2023-12-17 20:05             ` Emanuel Berg
@ 2023-12-18  9:11               ` Michael Albinus
  0 siblings, 0 replies; 24+ messages in thread
From: Michael Albinus @ 2023-12-18  9:11 UTC (permalink / raw)
  To: emacs-devel

Emanuel Berg <incal@dataswamp.org> writes:

Hi Emanuel,

>> If you don't care which host is meant, i.e. if you want
>> the same setting for all remote machines, you could shorten
>> the specification to
>>
>>           (connection-local-set-profiles
>>            '(:application tramp)
>>            'my-dired-profile)
>
> I tried this (code last) but it seem now I only get the
> '-Al' behavior, local and remote.

You're right, my bad. You need to specify at least one of :protocol,
:user or :machine in addition to :application.

Best regards, Michael.



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

* Re: Tramp and `dired-listing-switches'
  2023-12-18  3:44 ` Emanuel Berg
@ 2024-01-09  5:22   ` Emanuel Berg
  0 siblings, 0 replies; 24+ messages in thread
From: Emanuel Berg @ 2024-01-09  5:22 UTC (permalink / raw)
  To: emacs-devel

Now this whole thing works with the following code:

;;; -*- lexical-binding: t -*-

(require 'files-x)

(setq dired-listing-switches
  "-AGlX --group-directories-first -I \"*.meta\" -I \"#*#\" -I \"*.elc\"")

(connection-local-set-profile-variables
 'my-dired-profile
 '((dired-listing-switches . "-Al")) )

(connection-local-set-profiles
 '(:application tramp
   :machine "srv.dataswamp.org")
 'my-dired-profile)

I had to upgrade for it to work, now I'm on

GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, cairo version
1.16.0) of 2024-01-09 [commit
774c8ec74c98d69d56b2511a613145f2b69fb2eb]

and it works great!

This feature is pretty cool BTW, because the transition
between systems is pretty seamless. Different systems and
different ls even. And actually it isn't seamless since you
use different options, that's the whole point. But that also
makes you see from how a directory listing looks on what
system you are on B)

Thanks for the help.

https://dataswamp.org/~incal/emacs-init/dired-incal.el
https://dataswamp.org/~incal/conf/.zsh/install-emacs

-- 
underground experts united
https://dataswamp.org/~incal




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

end of thread, other threads:[~2024-01-09  5:22 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-07 14:50 Tramp and `dired-listing-switches' Emanuel Berg
2023-12-08  9:35 ` Michael Albinus
2023-12-08 11:59   ` Eli Zaretskii
2023-12-08 12:08     ` Michael Albinus
2023-12-10 11:43       ` Michael Albinus
2023-12-12 20:07         ` Emanuel Berg
2023-12-13  7:13           ` Michael Albinus
2023-12-17 20:05             ` Emanuel Berg
2023-12-18  9:11               ` Michael Albinus
2023-12-17 20:23             ` Emanuel Berg
2023-12-09 14:29   ` Emanuel Berg
2023-12-09 15:33     ` tomas
2023-12-09 15:49       ` Emanuel Berg
2023-12-09 16:10         ` Emanuel Berg
2023-12-09 16:53           ` Emanuel Berg
2023-12-09 17:12             ` Emanuel Berg
2023-12-09 16:14         ` Emanuel Berg
2023-12-09 17:39         ` Michael Albinus
2023-12-10  5:23           ` Emanuel Berg
2023-12-10 11:25         ` Benjamin Riefenstahl
2023-12-10 11:48           ` tomas
2023-12-12 20:15             ` Emanuel Berg
2023-12-18  3:44 ` Emanuel Berg
2024-01-09  5:22   ` Emanuel Berg

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.