My version of ls supports a time-style format (with a space) as follows:

--time-style=+%m-%d-%Y %H:%M:%S

The entire dired-listing-switches looks like this:

"-alh --group-directories-first --time-style=+%m-%d-%Y %H:%M:%S"

The space between the date and the time breaks the functionality. Any ideas on how to use (setq dired-listing-switches . . .) with a space between the date and time would be appreciated.

I've tried single quotes and I've tried \" but that format is rejected.

EDIT (October 28, 2014)

I've tried single quotes:

--time-style='+%m-%d-%Y %H:%M:%S'
'--time-style=+%m-%d-%Y %H:%M:%S'

I've tried escaped double quotes:

--time-style=\"+%m-%d-%Y %H:%M:%S\"

\"--time-style=+%m-%d-%Y %H:%M:%S\"

Based on Drew's suggestion below, I tried an escaped space:

--time-style=+%m-%d-%Y\ %H:%M:%S

The following link is the thread for the new Emacs bug report that I filed today:

EDIT October 29, 2014:  For clarification purposes, the proposed dired-listing-switches string will either generate an error, or it will omit hours:minutes:seconds. Although dired-mode does not support a list for switches when using dired-insert-directory, it is interesting to note that insert-directory from files.el permits a list format which works. The following screen shot was generated with insert-directory using a list format for the switches argument. I have already updated the bug report to mention the following expression (which bypasses dired-mode altogether).

(insert-directory "/" '("--dired" "-alth" "--time-style=+%m-%d-%Y %H:%M:%S") nil t)


  • 1
    Did you try backslash-escaping the SPC char? Try one or more backslashes ;-). If you do not find a reasonable workaround or a good answer here, consider filing an Emacs bug: M-x report-emacs-bug. (Why did you try backslashing a double-quote char?) – Drew Oct 28 '14 at 2:00
  • 2
    @Drew -- I found a hack, but not a good solution. The function indirect-directory in files.el supports switches in the form of either a string or a list. The function dired-indirect-directory within dired.el expects only a string, as is reflected by the line of code: (setq switches (concat "--dired " switches)) Replacing that line of code with (setq switches '("--dired" "-alh" "--group-directories-first" "--time-style=+%m-%d-%Y %H:%M:%S"))) permits a proper display of a dired-mode buffer with a space between the date and time. I'll file a bug report when I have some free time. – lawlist Oct 28 '14 at 4:04
  • @Drew -- It is possible that either or both of the above-mentioned functions need to be modified to better support both strings and lists for switches. – lawlist Oct 28 '14 at 4:08
  • 2
    Yes, it's possible. File the bug report, and Emacs Dev will work with you to find out what the best approach might be. Thanks for finding this and working on it. – Drew Oct 28 '14 at 6:50
  • Just a note to fix erroneous references to function names mentioned in my previous comment -- I should have written insert-directory from files.el and dired-insert-directory from dired.el. [I had erroneously used the word indirect instead of insert.] It is possible to use a list instead of a string for the switches with insert-directory from files.el -- the expression to be evaluated (which works) looks like: (insert-directory "/" '("--dired" "-alth" "--time-style=+%m-%d-%Y %H:%M:%S") nil t). However, that won't work as a string using dired-insert-directory. – lawlist Oct 30 '14 at 2:36

I succeeded to use a Unicode char U+2008 PUNCTUATION SPACE to split the time style:

(setq dired-listing-switches (purecopy (concat "-AhFlv --group-directories-first --time-style=+%d/%m/%y" (string ?\u2008) "%R")))

Although I don't know whether it has any implication on dired. Note, that you must also add this:

(setq directory-listing-before-filename-regexp
      (purecopy (concat "\\([0-2][0-9]:[0-5][0-9] \\)\\|"

to prevent a “No file on this line” error.

Tested with 24.5.1 and on Arch Linux.


  • Can you also achieve seconds using your method? "--time-style=+%m-%d-%Y %H:%M:%S" Your example looks very similar to the generic default. – lawlist Oct 3 '15 at 20:09
  • Yes, why not. Replace %R with %H:%M:%S and [0-2][0-9]:[0-5][0-9] with [0-2][0-9]:[0-5][0-9]:[0-6][0-9]\\([.,][0-9]+\\)?This is not like a generic default: The space before %R is not a regular space, so split-string, that works on ls switches doesn't split by it – igorepst Oct 3 '15 at 20:16
  • Sounds promising -- I'll test it out in the next day or so, as I am presently working on another project -- thank you for the proposed solution -- I look forwarding to trying it out. – lawlist Oct 3 '15 at 20:21
  • I actually tried right now my solution with an addition of seconds, before posting it :) – igorepst Oct 3 '15 at 20:25
  • Does it also work with U+00A0 NO-BREAK SPACE? That might work better with setups that don't use Unicode throughout. – Gilles Oct 3 '15 at 21:08

This works for me:

(setq dired-listing-switches "-alh --group-directories-first --time-style \"+%m-%d-%Y %H:%M:%S\"")

The key is replacing --time-style=xxxx with --time-style xxxx which doesn't confuse the function split-string-and-unquote.

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.