From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#20739: 25.0.50; Dired switches have no effect when explicit list of files provided Date: Sat, 6 Jun 2015 11:43:20 -0700 (PDT) Message-ID: References: <<3362479c-11a3-4559-88d6-666f03933440@default>> <<837frhnppc.fsf@gnu.org>> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1433616270 30779 80.91.229.3 (6 Jun 2015 18:44:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 6 Jun 2015 18:44:30 +0000 (UTC) Cc: 20739@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jun 06 20:44:17 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z1J4m-0001AF-5R for geb-bug-gnu-emacs@m.gmane.org; Sat, 06 Jun 2015 20:44:12 +0200 Original-Received: from localhost ([::1]:52317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z1J4l-0001b3-Kn for geb-bug-gnu-emacs@m.gmane.org; Sat, 06 Jun 2015 14:44:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z1J4h-0001am-Rk for bug-gnu-emacs@gnu.org; Sat, 06 Jun 2015 14:44:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z1J4c-0006cx-N6 for bug-gnu-emacs@gnu.org; Sat, 06 Jun 2015 14:44:07 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:33493) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z1J4c-0006cl-J0 for bug-gnu-emacs@gnu.org; Sat, 06 Jun 2015 14:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Z1J4c-0005zR-89 for bug-gnu-emacs@gnu.org; Sat, 06 Jun 2015 14:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 06 Jun 2015 18:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20739 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 20739-submit@debbugs.gnu.org id=B20739.143361620922978 (code B ref 20739); Sat, 06 Jun 2015 18:44:02 +0000 Original-Received: (at 20739) by debbugs.gnu.org; 6 Jun 2015 18:43:29 +0000 Original-Received: from localhost ([127.0.0.1]:43468 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z1J44-0005yY-Jo for submit@debbugs.gnu.org; Sat, 06 Jun 2015 14:43:29 -0400 Original-Received: from userp1040.oracle.com ([156.151.31.81]:35187) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z1J41-0005yJ-4Y for 20739@debbugs.gnu.org; Sat, 06 Jun 2015 14:43:26 -0400 Original-Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t56IhJFF005960 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 6 Jun 2015 18:43:19 GMT Original-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id t56IhICJ009255 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sat, 6 Jun 2015 18:43:18 GMT Original-Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id t56IhIrr016343; Sat, 6 Jun 2015 18:43:18 GMT In-Reply-To: <<837frhnppc.fsf@gnu.org>> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9 (901082) [OL 12.0.6691.5000 (x86)] X-Source-IP: userv0021.oracle.com [156.151.31.71] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:103668 Archived-At: > they are listed in the order in which you specified them in the list > passed as the first argument to 'dired'. That just happened to > coincide with alphabetic order in your case. Right. I misspoke. > You evidently expected 'dired' to apply the order-related options in > switches to the entire list of files. But that's not what 'dired' > does when it is called with its 1st argument a list. What it does > is invoke 'insert-directory' with each of the files in the list, in > order, passing it the value of switches. So when calling 'dired' in > this manner, the order-related switches have no effect whatsoever. I think you are describing what it does, and not what it should do or perhaps could do, and which would be more in line with user expectations. Yes, that is what the behavior is now. A priori, a user can reasonably expect switches to have their usual effect. Can we at least keep this expectation/request open as an enhancement request? In any case, the problem wrt `ls' switches is not total. Some parts of this bug/enhancement can be taken care of (fixed) more easily. `i', for instance, shows inodes, and `h' shows file sizes in human-friendly units. But other switches are not reflected in the Dired behavior when you provide an explicit list of files and dirs. The behavior is limited, I'm guessing, wrt any parts of `ls' that depend on the whole list of files and subdirs. It seems that parts of the `ls' behavior that depend only on the info about a given file are retained. That makes sense, to me anyway. We should be able to easily make Dired at least report correctly about the switches behavior that it gets right, and make it tell users not to expect other switches to have any effect in this use case. > I've updated the doc string to mention this peculiarity. >=20 > > Hitting `s' any number of times has no effect on the order of the > > files. >=20 > For the same reason. First, the doc should specify what I said above (if it is in fact the case): `ls' behavior that depends on the entire list is not available for this use case - the only switches that affect the display are those that depend only on the info for an individual file or dir; other switches are ignored. And either the list of those that are useful (not ignored) should be given explicitly (but that can be platform-dependent), or at least a couple examples that are typically relevant can be given. Second, it's not just about the doc string. If no improvement in the behavior is to be expected (I would prefer that it be improved to respect the switches generally, to the extent that is possible), then I think a minimum bug fix, beyond the doc (see above), would be to change the mode-line lighter. At a bare minimum, the misleading lighter indications "by name|date" need to be removed. Whe DIRNAME is a cons, the lighter should not show anything like "by name" or "by date". Instead, it should either have just "Dired" or (better) include some indication that the listing is from an explicit list and not necessarily a directory listing. In the latter case, it could also show the (relevant) switches. Here is one possibility for the mode-line lighter: `Dired/*-hiF'. Here, I'm using: * "*" to indicate listing selected files instead of a directory. * "-hiF" are the relevant `ls' switches. (Irrelevant switches given by the user are ignored - this indicates which are used.) * "/" instead of "by ". So `Dired/name' and `Dired/date'. FWIW: I do this /-for-by replacement anyway in my code, to save space and because I add more info to the lighter than just the sort order. When files are marked or flagged I add that info to the lighter. E.g., `Dired/name 3* 2D', with the `3*' and the `2D' highlighted using,by default, the same faces as marks `*' and `D'. If the current line is marked/flagged, then the lighter shows how many are, both through that line and total. For example, `Dired/date 6* 2/9D' says this: There are 6 marked lines and 9 flagged lines; the file on the current line is flagged; there is one flagged above it and there are 8 flagged below it. That's just one possibility, for discussion. `*' is maybe not the best indicator of an explicit listing; dunno. And maybe it won't be easy to always correctly get the list of relevant switches; dunno. FYI - The code for the mode-line indicator that I use now (e.g., showing number of marks and flags) is in function `diredp-nb-marked-in-mode-name', in `dired+.el'. It could be added to vanilla dired.el, if wanted. In dired+.el, that function is added to these hooks: (add-hook 'dired-after-readin-hook 'diredp-nb-marked-in-mode-name) ;; `find-dired' does not call `dired-readin'. (add-hook 'dired-mode-hook 'diredp-nb-marked-in-mode-name) Here is the code for the function. (defun diredp-nb-marked-in-mode-name () "Add number of marked and flagged lines to mode name in the mode line. \(Flagged means flagged for deletion.) If the current line is marked/flagged and there are others marked/flagged after it then show `N/M', where N is the number marked/flagged through the current line and M is the total number marked/flagged. Also abbreviate `mode-name', using \"Dired/\" instead of \"Dired by\"." (let ((mname (format-mode-line mode-name))) ;; Prop `dired+-mode-name' indicates whether `mode-name' was changed. (unless (get-text-property 0 'dired+-mode-name mname) (save-match-data (setq mode-name `(,(propertize (if (string-match "^[dD]ired \\(by \\)?\\(.*\\)" mname) (format "Dired/%s" (match-string 2 mname)) mname) 'dired+-mode-name t) (:eval (let* ((dired-marker-char (if (eq ?D dired-marker-char) ?* dired-marker-char)) (marked-regexp (dired-marker-regexp)) (nb-marked (count-matches marked-regexp (point-min) (point-max)))) (if (not (> nb-marked 0)) "" (propertize (format " %s%d%c" (save-excursion (forward-line 0) (if (looking-at (concat marked-regexp ".*")) (format "%d/" (1+ (count-matches marked-regexp (point-min) (point)))) "")) nb-marked dired-marker-char) 'face 'diredp-mode-line-marked 'dired+-mode-name t)))) (:eval (let* ((flagged-regexp (let ((dired-marker-char dired-del-marker)) (dired-marker-regexp))) (nb-flagged (count-matches flagged-regexp (point-min) (point-max)))) (if (not (> nb-flagged 0)) "" (propertize (format " %s%dD" (save-excursion (forward-line 0) (if (looking-at (concat flagged-regexp ".*")) (format "%d/" (1+ (count-matches flagged-regexp (point-min) (point)))) "")) nb-flagged) 'face 'diredp-mode-line-flagged))))))))))