From: Arthur Miller <arthur.miller@live.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Proposal: ls-lisp.el handle --group-directories-first flag
Date: Fri, 16 Jul 2021 15:20:58 +0200 [thread overview]
Message-ID: <AM9PR09MB49771DEE6462F4DD35055EE196119@AM9PR09MB4977.eurprd09.prod.outlook.com> (raw)
In-Reply-To: <8335se5v40.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 16 Jul 2021 14:57:51 +0300")
[-- Attachment #1: Type: text/plain, Size: 1651 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Arthur Miller <arthur.miller@live.com>
>> Date: Thu, 15 Jul 2021 11:19:52 +0200
>>
>> Just a minor 'out-of-the-box' quality of life improvement mostly for
>> MS Windows users. ls-lisp.el is default on MS Windows, and some users
>> might share their init configuration between their Gnu/Linux and MS
>> Windows systems, it might be nice to have ls-lisp.el recognize
>> `--group-directories-first' flag of Gnu ls program.
>>
>> I have just piggy-back on existing code here; I am not sure if I can
>> actually set `ls-lisp-dirs-firs' var to `t' when
>> `--group-directories-first' is found, so I am just converting this flag
>> to `y' so we can per-use existing machinery. But I would happily skip
>> `y' if it is acceptable to change users choice for `ls-lisp-dirs-first'
>> variable when `--group-directories-first' is present.
>
> This is not future-proof: what if 'ls' in some future release will
> have the -y option, and we'd want to support that in ls-lisp.el?
Yes, I knowm I just thought that world does not directly see an explosion of
'ls' applications development. Yes, I had an idea you wouldn't like the
hacky patch, it was nore of a joke.
> Doesn't it work to let-bind ls-lisp-dirs-first?
I don't know about that one. ls-lisp--insert-directory effectively
ensures that switches are passed further the line as a string of
chars. The flag is lost in the first step and can't be passed further
on. I am not sure it's worth the trouble to modify that behaviour. Or
maybe I don't know what you mean.
Anyway, see if this is acceptable. It adds one extra variable, so it's still
pretty cheap.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ls-lisp.patch --]
[-- Type: text/x-patch, Size: 1456 bytes --]
--- ../emacs/lisp/ls-lisp.el 2021-06-06 23:11:38.317648694 +0200
+++ ./ls-lisp.el 2021-07-16 15:00:29.000632720 +0200
@@ -253,6 +253,9 @@
"Format to display float file sizes.")
(defvar ls-lisp-filesize-b-fmt " %.0f"
"Format to display file sizes in blocks (for the -s switch).")
+(defvar ls-lisp--really-dirs-first nil
+ "`t' if either ls-lisp-dirs-first is set to `t' or GNU ls flag
+ \"--group-directory-first\" is passed in switches to ls-lisp.")
\f
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -291,6 +294,9 @@
;; Remove --dired switch
(if (string-match "--dired " switches)
(setq switches (replace-match "" nil nil switches)))
+ (setq ls-lisp--really-dirs-first
+ (or ls-lisp-dirs-first
+ (string-match "--group-directories-first" switches)))
;; Convert SWITCHES to a list of characters.
(setq switches (delete ?\ (delete ?- (append switches nil))))
;; Sometimes we get ".../foo*/" as FILE. While the shell and
@@ -682,7 +688,7 @@
(ding) (sit-for 2)))) ; to show user the message!
(if (memq ?F switches) ; classify switch
(setq file-alist (mapcar 'ls-lisp-classify file-alist)))
- (if ls-lisp-dirs-first
+ (if ls-lisp--really-dirs-first
;; Re-sort directories first, without otherwise changing the
;; ordering, and reverse whole list. cadr of each element of
;; `file-alist' is t for directory, string (name linked to) for
next prev parent reply other threads:[~2021-07-16 13:20 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-15 9:19 Proposal: ls-lisp.el handle --group-directories-first flag Arthur Miller
2021-07-16 11:57 ` Eli Zaretskii
2021-07-16 13:20 ` Arthur Miller [this message]
2021-07-16 13:44 ` Eli Zaretskii
2021-07-16 14:58 ` Arthur Miller
2021-07-17 11:57 ` Eli Zaretskii
2021-07-19 20:59 ` Arthur Miller
2021-07-24 11:13 ` Eli Zaretskii
2021-07-24 11:27 ` Eli Zaretskii
2021-07-24 11:54 ` Arthur Miller
2021-07-24 12:07 ` Eli Zaretskii
2021-07-24 14:58 ` Arthur Miller
2021-07-24 15:43 ` Eli Zaretskii
2021-07-24 19:02 ` Arthur Miller
2021-07-25 7:46 ` Eli Zaretskii
2021-07-25 8:29 ` Arthur Miller
2021-07-25 9:11 ` Eli Zaretskii
2021-07-25 9:31 ` Arthur Miller
2021-07-25 12:44 ` Michael Albinus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AM9PR09MB49771DEE6462F4DD35055EE196119@AM9PR09MB4977.eurprd09.prod.outlook.com \
--to=arthur.miller@live.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).