From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#25485: 25.1; Having trouble setting --time-style in dired-listing-switches Date: Fri, 27 Jan 2017 15:53:54 +0200 Message-ID: <837f5g1udp.fsf@gnu.org> References: <83inpb6nco.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1485528215 32511 195.159.176.226 (27 Jan 2017 14:43:35 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 27 Jan 2017 14:43:35 +0000 (UTC) Cc: 25485@debbugs.gnu.org To: Chunyang Xu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jan 27 15:43:30 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cX7kA-0006pf-CT for geb-bug-gnu-emacs@m.gmane.org; Fri, 27 Jan 2017 15:43:14 +0100 Original-Received: from localhost ([::1]:45797 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cX7kF-0001KW-KI for geb-bug-gnu-emacs@m.gmane.org; Fri, 27 Jan 2017 09:43:19 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35107) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cX6za-0004ef-5t for bug-gnu-emacs@gnu.org; Fri, 27 Jan 2017 08:55:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cX6zX-0000dW-1u for bug-gnu-emacs@gnu.org; Fri, 27 Jan 2017 08:55:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48948) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cX6zW-0000dS-Uc for bug-gnu-emacs@gnu.org; Fri, 27 Jan 2017 08:55:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cX6zW-0007Fk-Ll for bug-gnu-emacs@gnu.org; Fri, 27 Jan 2017 08:55:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 27 Jan 2017 13:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25485 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25485-submit@debbugs.gnu.org id=B25485.148552526527829 (code B ref 25485); Fri, 27 Jan 2017 13:55:02 +0000 Original-Received: (at 25485) by debbugs.gnu.org; 27 Jan 2017 13:54:25 +0000 Original-Received: from localhost ([127.0.0.1]:47147 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cX6yv-0007En-JB for submit@debbugs.gnu.org; Fri, 27 Jan 2017 08:54:25 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:43990) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cX6yt-0007Ea-Db for 25485@debbugs.gnu.org; Fri, 27 Jan 2017 08:54:23 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cX6yi-0000Rj-Jd for 25485@debbugs.gnu.org; Fri, 27 Jan 2017 08:54:18 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:47090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cX6yi-0000Rd-GK; Fri, 27 Jan 2017 08:54:12 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4219 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cX6yg-0002IJ-9h; Fri, 27 Jan 2017 08:54:11 -0500 In-reply-to: (message from Chunyang Xu on Fri, 20 Jan 2017 01:20:45 +0800) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:128682 Archived-At: > From: Chunyang Xu > Cc: 25485@debbugs.gnu.org > Date: Fri, 20 Jan 2017 01:20:45 +0800 > > > Eli Zaretskii writes: > > >> From: Chunyang Xu > >> Date: Thu, 19 Jan 2017 22:34:31 +0800 > >> > >> I want to custom the file timestamps used in dired through the option: > >> > >> --time-style='+%_m月 %d %H:%M' > >> > >> then I adjust `dired-listing-switches' accordingly: > >> > >> (setq dired-listing-switches "-al --time-style='+%_m月 %d %H:%M'") > >> > >> However, it doesn't work, it signals an error, here is the Backtrace: > > > > Isn't --time-style a GNU ls extension? You are on Darwin, so do you > > have GNU ls installed? What happens if you use that option from the > > shell prompt? > > Yes, and yes, and I have set shell and Emacs to use GNU ls, thus in > shell (via M-x shell) it works like expected: Your setting of dired-listing-switches assumes that the 'ls' command will be run by a shell: you use shell quoting. But that's not what Dired does, it in most cases invokes 'ls' directly, and for that it needs to split the switches into individual options. It does that by calling split-string on the value of dired-listing-switches, which of course knows nothing about the '..' quoting. That's why 'ls' fails: it gets the --time-style option split between several separate command-line arguments. What this means is that currently Dired doesn't support switches that include embedded whitespace at all. One way of lifting at least some of that limitation is the simple patch below; it will require you to format your switches like this: (setq dired-listing-switches "-al \"--time-style=+%_m月 %d %H:%M\"") The function combine-and-quote-strings can help in producing the correct format. Given that we document this, is this an acceptable solution? (It won't work on MS-Windows, but the default there is not to call external programs at all, so I think it's not a terrible loss, for those Windows users who set up their systems to use 'ls'.) Here's the proposed patch; comments are welcome: diff --git a/lisp/files.el b/lisp/files.el index 25392fd..0a7b6a2 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -6572,7 +6572,7 @@ insert-directory (unless (equal switches "") ;; Split the switches at any spaces so we can ;; pass separate options as separate args. - (split-string switches))) + (split-string-and-unquote switches))) ;; Avoid lossage if FILE starts with `-'. '("--") (progn