all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
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 16:58:16 +0200	[thread overview]
Message-ID: <AM9PR09MB4977B60DD2E9E4BF14D74C5296119@AM9PR09MB4977.eurprd09.prod.outlook.com> (raw)
In-Reply-To: <83y2a64bla.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 16 Jul 2021 16:44:49 +0300")

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

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Arthur Miller <arthur.miller@live.com>
>> Cc: emacs-devel@gnu.org
>> Date: Fri, 16 Jul 2021 15:20:58 +0200
>> 
>> > 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.
>
> Which flag is lost and why?

Ok, I take my words back, it is actually not lost. I was to fast didn't
reallize --group-directories-first was just converted with rest to a
list of chars.

Doesn't it mean that ls-lisp could potentialy recieve flags that user
didn't ment to use?

> I'm still missing something, because I don't see how this is different
> from just let-binding ls-lisp-dirs-first.

Since --group-directories-first is still there, then let bind works fine
:-).


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ls-lisp.patch --]
[-- Type: text/x-patch, Size: 2170 bytes --]

--- ../emacs/lisp/ls-lisp.el	2021-06-06 23:11:38.317648694 +0200
+++ ./ls-lisp.el	2021-07-16 16:54:51.413276991 +0200
@@ -682,24 +682,27 @@
 	       (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
-  ;; 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
-  ;; symbolic link, or nil.
-      (let (el dirs files)
-	(while file-alist
-	  (if (or (eq (cadr (setq el (car file-alist))) t) ; directory
-                  (and (stringp (cadr el))
-                       (file-directory-p (cadr el)))) ; symlink to a directory
-	      (setq dirs (cons el dirs))
-	    (setq files (cons el files)))
-	  (setq file-alist (cdr file-alist)))
-	(setq file-alist
-	      (if (memq ?U switches)	; unsorted order is reversed
-		  (nconc dirs files)
-		(nconc files dirs)
-		))))
+  (let ((dirs-first (or ls-lisp-dirs-first
+                        (string-match "groupdirectoriesfirst" (concat
+                                                               switches))))) 
+    (if 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
+        ;; symbolic link, or nil.
+        (let (el dirs files)
+	  (while file-alist
+	    (if (or (eq (cadr (setq el (car file-alist))) t) ; directory
+                    (and (stringp (cadr el))
+                         (file-directory-p (cadr el)))) ; symlink to a directory
+	        (setq dirs (cons el dirs))
+	      (setq files (cons el files)))
+	    (setq file-alist (cdr file-alist)))
+	  (setq file-alist
+	        (if (memq ?U switches)	; unsorted order is reversed
+		    (nconc dirs files)
+		  (nconc files dirs)
+		  )))))
   ;; Finally reverse file alist if necessary.
   ;; (eq below MUST compare `(not (memq ...))' to force comparison of
   ;; t or nil, rather than list tails!)

  reply	other threads:[~2021-07-16 14:58 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
2021-07-16 13:44     ` Eli Zaretskii
2021-07-16 14:58       ` Arthur Miller [this message]
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM9PR09MB4977B60DD2E9E4BF14D74C5296119@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 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.