2

In Windows File Explorer (FE) I can give a file or folder a name with a special character as the first character, and thereby make them move on top when sorting the files alphabetically. For instance, in FE the folder named .baby will be sorted above both of the folders atom and car, while in Dired .baby will be sorted between those two other folders, as if the character . is not seen by Dired.

How can I make Dired sort on special characters?

  • I have the same problem, it doesn't matter if the special character is in the beginning of the file name, or in between, Dired skips/ignores the special characters for sorting. So for example a.a will be sorted before ab. I also would like to know how to solve this problem. – mikl Apr 19 '18 at 18:51
2
+50

Customize ls-lisp-UCA-like-collation variable:

ls-lisp-UCA-like-collation is a variable defined in ls-lisp.el.

Non-nil means force ls-lisp use a collation order compatible with UCA.

UCA is the Unicode Collation Algorithm. GNU/Linux systems automatically follow it in their string-collation routines if the locale specifies UTF-8 as its codeset. On MS-Windows, customize this option to a non-nil value to get similar behavior.

When this option is non-nil, and ls-lisp-use-string-collate is also non-nil, the collation order produced on MS-Windows will ignore punctuation and symbol characters, which will, for example, place .foo near foo. See the documentation of string-collate-lessp and w32-collate-ignore-punctuation for more details.

  • Thanks for your quick reply! But where on my computer do I find this ls-lisp-UCA-like-collation variable? – myotis May 30 at 13:48
  • It's in your Emacs. C-h v ls-lisp-UCA-like-collation will give you documentation and with M-x customize-variable <RET> ls-lisp-UCA-like-collation you can customize it. – muffinmad May 30 at 13:51
  • You wrote : "When this option is non-nil, and ls-lisp-use-string-collate is ALSO non-nil", so there are two places where options are to be customized? I found where to customize the lisp variable, but where to customize the other? – myotis May 30 at 14:06
  • ls-lisp-use-string-collate it's just another variable. It can be customized via M-x customize-variable <RET> ls-lisp-use-string-collate – muffinmad May 30 at 14:08
  • It worked! I just had to re-start emacs. Thanks :) – myotis May 30 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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