Subject: bug#18051: 24.3.92; ls-lisp: Sorting; make ls-lisp-string-lessp a normal function?

From: Michael Heerdegen <[email-masked]>
Date: Sun, 20 Jul 2014 07:49:48 +0200

Eli Zaretskii <[email-masked]> writes:

> I don't think you understood what Michael wanted, but I'll let Michael
> speak for himself.

I don't use Tramp often currently.

Generally, I switched to ls-lisp because I liked that it gives me more
control over how dired looks like.

Sorting is one only thing (that could probably be done with Tramp).

There are other things.  What I don't like from ls is that it shows
symlinks like this:

   lrwxrwxrwx ... ...

rwxrwxrwx is redundant.  When you use M on a link in dired, you actually
set the modes of the target.  I want to see the target file's modes, so
I use this:

,----------------------------------------------------------------------
| (defun my-ls-lisp-treat-symlinks-ad (file-alist &rest _)
|   "Make it show modes of truenames for symlinks."
|   (mapc (lambda (file-line)
|           (let ((filename (expand-file-name (car file-line)
|                                             default-directory))
|                 modes-string)
|             (when (file-symlink-p filename)
|               (setq modes-string (nth 8 (file-attributes
|                                          (file-truename filename))))
|               (if (not modes-string) ;; link could be dead!
|                   (setq modes-string "l?????????")
|                 (aset modes-string 0 ?l))
|               (setf (nth 9 file-line) modes-string))))
|         file-alist)
|   file-alist)
| 
| (advice-add 'ls-lisp-handle-switches :after #'my-ls-lisp-treat-symlinks-ad)
`----------------------------------------------------------------------

AFAIK this can't be reached with ls.  Just one example.  Trying to do
such things with Tramp would probably indeed slow it down.