* bug#25485: 25.1; Having trouble setting --time-style in dired-listing-switches
@ 2017-01-19 14:34 Chunyang Xu
2017-01-19 16:11 ` Eli Zaretskii
0 siblings, 1 reply; 8+ messages in thread
From: Chunyang Xu @ 2017-01-19 14:34 UTC (permalink / raw)
To: 25485
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:
Debugger entered--Lisp error: (error "Listing directory failed but `access-file' worked")
signal(error ("Listing directory failed but `access-file' worked"))
error("Listing directory failed but `access-file' worked")
insert-directory("/tmp/" "--dired -al --time-style='+%_m月 %d %H:%M'" nil t)
dired-insert-directory("/tmp/" "-al --time-style='+%_m月 %d %H:%M'" nil nil t)
dired-readin-insert()
dired-readin()
dired-internal-noselect("/tmp/" nil)
dired-noselect("/tmp" nil)
dired("/tmp" nil)
funcall-interactively(dired "/tmp" nil)
call-interactively(dired record nil)
command-execute(dired record)
helm-M-x(nil "dired")
funcall-interactively(helm-M-x nil "dired")
call-interactively(helm-M-x nil nil)
command-execute(helm-M-x)
I also try the following, they don't work either.
(setq dired-listing-switches "-al --time-style=\"+%_m月 %_d %H:%M\"")
(setq dired-listing-switches "-al --time-style=+%_m月\\ %d\\ %H:%M")
In GNU Emacs 25.1.1 (x86_64-apple-darwin16.3.0, Carbon Version 157 AppKit 1504.76)
of 2017-01-15 built on sierra.internal.macports.net
Windowing system distributor 'Apple Inc.', version 10.12.2
Configured using:
'configure --prefix=/opt/local --with-mac
--enable-mac-app=/Applications/MacPorts --without-rsvg
--without-imagemagick 'CFLAGS=-pipe -Os -fobjc-arc -arch x86_64'
CPPFLAGS=-I/opt/local/include 'LDFLAGS=-L/opt/local/lib
-Wl,-headerpad_max_install_names -arch x86_64''
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#25485: 25.1; Having trouble setting --time-style in dired-listing-switches
2017-01-19 14:34 bug#25485: 25.1; Having trouble setting --time-style in dired-listing-switches Chunyang Xu
@ 2017-01-19 16:11 ` Eli Zaretskii
2017-01-19 17:20 ` Chunyang Xu
0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2017-01-19 16:11 UTC (permalink / raw)
To: Chunyang Xu; +Cc: 25485
> From: Chunyang Xu <mail@xuchunyang.me>
> 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?
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#25485: 25.1; Having trouble setting --time-style in dired-listing-switches
2017-01-19 16:11 ` Eli Zaretskii
@ 2017-01-19 17:20 ` Chunyang Xu
2017-01-20 7:43 ` Eli Zaretskii
2017-01-27 13:53 ` Eli Zaretskii
0 siblings, 2 replies; 8+ messages in thread
From: Chunyang Xu @ 2017-01-19 17:20 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 25485
Eli Zaretskii writes:
>> From: Chunyang Xu <mail@xuchunyang.me>
>> 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:
~$ cd /tmp
/tmp$ ls -al --time-style='+%_m月 %d %H:%M'
total 4
drwxrwxrwt 8 root wheel 272 1月 20 00:49 .
drwxr-xr-x 6 root wheel 204 11月 15 13:17 ..
-rw-rw-rw- 1 xcy wheel 0 1月 16 13:40 .keystone_install_lock
drwx------ 3 xcy wheel 102 1月 16 13:40 com.apple.launchd.404wZSYm30
drwx------ 3 xcy wheel 102 1月 16 13:40 com.apple.launchd.ORTswTb0KX
drwx------ 3 xcy wheel 102 1月 16 13:40 com.apple.launchd.WcFjcyxZ4I
drwx------ 3 xcy wheel 102 1月 16 13:40 com.apple.launchd.g1ImzMVLVC
-rw-r--r-- 1 xcy wheel 985 1月 20 01:10 mail.log
/tmp$
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#25485: 25.1; Having trouble setting --time-style in dired-listing-switches
2017-01-19 17:20 ` Chunyang Xu
@ 2017-01-20 7:43 ` Eli Zaretskii
2017-01-27 13:53 ` Eli Zaretskii
1 sibling, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2017-01-20 7:43 UTC (permalink / raw)
To: Chunyang Xu; +Cc: 25485
> From: Chunyang Xu <mail@xuchunyang.me>
> Cc: 25485@debbugs.gnu.org
> Date: Fri, 20 Jan 2017 01:20:45 +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:
What happens if you add --dired to dired-listing-switches?
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#25485: 25.1; Having trouble setting --time-style in dired-listing-switches
2017-01-19 17:20 ` Chunyang Xu
2017-01-20 7:43 ` Eli Zaretskii
@ 2017-01-27 13:53 ` Eli Zaretskii
2017-01-28 1:01 ` Chunyang Xu
1 sibling, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2017-01-27 13:53 UTC (permalink / raw)
To: Chunyang Xu; +Cc: 25485
> From: Chunyang Xu <mail@xuchunyang.me>
> Cc: 25485@debbugs.gnu.org
> Date: Fri, 20 Jan 2017 01:20:45 +0800
>
>
> Eli Zaretskii writes:
>
> >> From: Chunyang Xu <mail@xuchunyang.me>
> >> 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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* bug#25485: 25.1; Having trouble setting --time-style in dired-listing-switches
2017-01-27 13:53 ` Eli Zaretskii
@ 2017-01-28 1:01 ` Chunyang Xu
2017-01-28 7:22 ` Eli Zaretskii
0 siblings, 1 reply; 8+ messages in thread
From: Chunyang Xu @ 2017-01-28 1:01 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 25485
Eli Zaretskii writes:
>> From: Chunyang Xu <mail@xuchunyang.me>
>> Cc: 25485@debbugs.gnu.org
>> Date: Fri, 20 Jan 2017 01:20:45 +0800
>>
>>
>> Eli Zaretskii writes:
>>
>> >> From: Chunyang Xu <mail@xuchunyang.me>
>> >> 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
I have tried the patch and changed dired-listing-switches accordingly,
it works now. Thus the solution is acceptable to me.
My first thought was, we can make dired-listing-switches also accepts a
list of arguments, then something like this
(setq dired-listing-switches
(list "-al" "--time-style=+%_m月 %d %H:%M"))
should just work. But it will require much more work and I have no idea
how 'C-u M-x dired-sort-toggle-or-edit' can work as usual.
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#25485: 25.1; Having trouble setting --time-style in dired-listing-switches
2017-01-28 1:01 ` Chunyang Xu
@ 2017-01-28 7:22 ` Eli Zaretskii
2017-02-04 10:05 ` Eli Zaretskii
0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2017-01-28 7:22 UTC (permalink / raw)
To: Chunyang Xu; +Cc: 25485
> From: Chunyang Xu <mail@xuchunyang.me>
> Cc: 25485@debbugs.gnu.org
> Date: Sat, 28 Jan 2017 09:01:15 +0800
>
> I have tried the patch and changed dired-listing-switches accordingly,
> it works now. Thus the solution is acceptable to me.
Thanks for the feedback.
> My first thought was, we can make dired-listing-switches also accepts a
> list of arguments, then something like this
>
> (setq dired-listing-switches
> (list "-al" "--time-style=+%_m月 %d %H:%M"))
>
> should just work. But it will require much more work and I have no idea
> how 'C-u M-x dired-sort-toggle-or-edit' can work as usual.
I thought about that as well, and the reason why I opted not to go
that way was that it will be more complicated for users, especially
those who are not very fluent in Lisp. But I'm open to hear other
opinions on that.
I'll wait for a few days for comments, and if no objections pop up,
will commit the above change (and fix the documentation accordingly).
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-02-04 10:05 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-19 14:34 bug#25485: 25.1; Having trouble setting --time-style in dired-listing-switches Chunyang Xu
2017-01-19 16:11 ` Eli Zaretskii
2017-01-19 17:20 ` Chunyang Xu
2017-01-20 7:43 ` Eli Zaretskii
2017-01-27 13:53 ` Eli Zaretskii
2017-01-28 1:01 ` Chunyang Xu
2017-01-28 7:22 ` Eli Zaretskii
2017-02-04 10:05 ` Eli Zaretskii
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).