diff options
| author | Eli Zaretskii | 2014-09-01 17:57:21 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2014-09-01 17:57:21 +0300 |
| commit | 0360ec583aa754eb746ca6772ca6ca0f0212d546 (patch) | |
| tree | e6e94a7d099ac6d826f7045e11d7c280ac363992 | |
| parent | 8d033ecb9d8189a7e6b1230e86dacb253dedb055 (diff) | |
| download | emacs-0360ec583aa754eb746ca6772ca6ca0f0212d546.tar.gz emacs-0360ec583aa754eb746ca6772ca6ca0f0212d546.zip | |
Use the new string-collate-lessp function in ls-lisp.el.
lisp/ls-lisp.el (ls-lisp-use-string-collate)
(ls-lisp-UCA-like-collation): New defcustoms.
(ls-lisp-string-lessp): Use them to control sorting by file
names.
etc/NEWS: Mention that ls-lisp uses string-collate-lessp.
Fixes: debbugs:18051
| -rw-r--r-- | etc/ChangeLog | 4 | ||||
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/ls-lisp.el | 58 |
4 files changed, 69 insertions, 4 deletions
diff --git a/etc/ChangeLog b/etc/ChangeLog index ff00659cba0..8dbdb46c826 100644 --- a/etc/ChangeLog +++ b/etc/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2014-09-01 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * NEWS: Mention that ls-lisp uses string-collate-lessp. | ||
| 4 | |||
| 1 | 2014-09-01 Paul Eggert <eggert@cs.ucla.edu> | 5 | 2014-09-01 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 6 | ||
| 3 | --enable-silent-rules now suppresses more chatter. | 7 | --enable-silent-rules now suppresses more chatter. |
| @@ -75,6 +75,10 @@ environment. For the time being this is implemented for modern POSIX | |||
| 75 | systems and for MS-Windows, for other systems they fall back to their | 75 | systems and for MS-Windows, for other systems they fall back to their |
| 76 | counterparts `string-lessp' and `string-equal'. | 76 | counterparts `string-lessp' and `string-equal'. |
| 77 | 77 | ||
| 78 | *** The ls-lisp package uses `string-collate-lessp' to sort file names. | ||
| 79 | If you want the old, locale-independent sorting, customize the new | ||
| 80 | option `ls-lisp-use-string-collate' to a nil value. | ||
| 81 | |||
| 78 | *** The MS-Windows specific variable `w32-collate-ignore-punctuation', | 82 | *** The MS-Windows specific variable `w32-collate-ignore-punctuation', |
| 79 | if set to a non-nil value, causes the above 2 functions to ignore | 83 | if set to a non-nil value, causes the above 2 functions to ignore |
| 80 | symbol and punctuation characters when collating strings. This | 84 | symbol and punctuation characters when collating strings. This |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7087cde6d44..47185e01f5e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2014-09-01 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * ls-lisp.el (ls-lisp-use-string-collate) | ||
| 4 | (ls-lisp-UCA-like-collation): New defcustoms. | ||
| 5 | (ls-lisp-string-lessp): Use them to control sorting by file | ||
| 6 | names. (Bug#18051) | ||
| 7 | |||
| 1 | 2014-08-31 Christoph Scholtes <cschol2112@gmail.com> | 8 | 2014-08-31 Christoph Scholtes <cschol2112@gmail.com> |
| 2 | 9 | ||
| 3 | * ibuffer.el: Replace mode-specific quit function with | 10 | * ibuffer.el: Replace mode-specific quit function with |
diff --git a/lisp/ls-lisp.el b/lisp/ls-lisp.el index 2ff0a3a230b..410b44999f6 100644 --- a/lisp/ls-lisp.el +++ b/lisp/ls-lisp.el | |||
| @@ -113,6 +113,47 @@ update the dependent variables." | |||
| 113 | :type 'boolean | 113 | :type 'boolean |
| 114 | :group 'ls-lisp) | 114 | :group 'ls-lisp) |
| 115 | 115 | ||
| 116 | (defcustom ls-lisp-use-string-collate | ||
| 117 | (cond ((memq ls-lisp-emulation '(MacOS UNIX)) nil) | ||
| 118 | (t t)) ; GNU/Linux or MS-Windows emulate GNU ls | ||
| 119 | "Non-nil causes ls-lisp to sort files in locale-dependent collation order. | ||
| 120 | |||
| 121 | A value of nil means use ordinary string comparison (see `compare-strings') | ||
| 122 | for sorting files. A non-nil value uses `string-collate-lessp' instead, | ||
| 123 | which more closely emulates what GNU `ls' does. | ||
| 124 | |||
| 125 | On GNU/Linux systems, if the locale's codeset specifies UTF-8, as | ||
| 126 | in \"en_US.UTF-8\", the collation order follows the Unicode | ||
| 127 | Collation Algorithm (UCA), which places together file names that | ||
| 128 | differ only in punctuation characters. On MS-Windows, customize | ||
| 129 | the option `ls-lisp-UCA-like-collation' to a non-nil value to get | ||
| 130 | similar behavior." | ||
| 131 | :version "24.5" | ||
| 132 | :set-after '(ls-lisp-emulation) | ||
| 133 | :type 'boolean | ||
| 134 | :group 'ls-lisp) | ||
| 135 | |||
| 136 | (defcustom ls-lisp-UCA-like-collation t | ||
| 137 | "Non-nil means force ls-lisp use a collation order compatible with UCA. | ||
| 138 | |||
| 139 | UCA is the Unicode Collation Algorithm. GNU/Linux systems automatically | ||
| 140 | follow it in their string-collation routines if the locale specifies | ||
| 141 | UTF-8 as its codeset. On MS-Windows, customize this option to a non-nil | ||
| 142 | value to get similar behavior. | ||
| 143 | |||
| 144 | When this option is non-nil, and `ls-lisp-use-string-collate' is also | ||
| 145 | non-nil, the collation order produced on MS-Windows will ignore | ||
| 146 | punctuation and symbol characters, which will, for example, place | ||
| 147 | \`.foo' near `foo'. See the documentation of `string-collate-lessp' | ||
| 148 | and `w32-collate-ignore-punctuation' for more details. | ||
| 149 | |||
| 150 | This option is ignored on platforms other than MS-Windows; to | ||
| 151 | control the collation ordering of the file names on those other | ||
| 152 | systems, set your locale instead." | ||
| 153 | :version "24.5" | ||
| 154 | :type 'boolean | ||
| 155 | :group 'ls-lisp) | ||
| 156 | |||
| 116 | (defcustom ls-lisp-dirs-first (eq ls-lisp-emulation 'MS-Windows) | 157 | (defcustom ls-lisp-dirs-first (eq ls-lisp-emulation 'MS-Windows) |
| 117 | "Non-nil causes ls-lisp to sort directories first in any ordering. | 158 | "Non-nil causes ls-lisp to sort directories first in any ordering. |
| 118 | \(Or last if it is reversed.) Follows Microsoft Windows Explorer." | 159 | \(Or last if it is reversed.) Follows Microsoft Windows Explorer." |
| @@ -495,11 +536,20 @@ Responds to the window width as ls should but may not!" | |||
| 495 | result)) | 536 | result)) |
| 496 | 537 | ||
| 497 | (defsubst ls-lisp-string-lessp (s1 s2) | 538 | (defsubst ls-lisp-string-lessp (s1 s2) |
| 498 | "Return t if string S1 is less than string S2 in lexicographic order. | 539 | "Return t if string S1 should sort before string S2. |
| 499 | Case is significant if `ls-lisp-ignore-case' is nil. | 540 | Case is significant if `ls-lisp-ignore-case' is nil. |
| 500 | Unibyte strings are converted to multibyte for comparison." | 541 | Uses `string-collate-lessp' if `ls-lisp-use-string-collate' is non-nil, |
| 501 | (let ((u (compare-strings s1 0 nil s2 0 nil ls-lisp-ignore-case))) | 542 | \`compare-strings' otherwise. |
| 502 | (and (numberp u) (< u 0)))) | 543 | On GNU/Linux systems, if the locale specifies UTF-8 as the codeset, |
| 544 | the sorting order will place together file names that differ only | ||
| 545 | by punctuation characters, like `.emacs' and `emacs'. To have a | ||
| 546 | similar behavior on MS-Widnows, customize `ls-lisp-UCA-like-collation' | ||
| 547 | to a non-nil value." | ||
| 548 | (let ((w32-collate-ignore-punctuation ls-lisp-UCA-like-collation)) | ||
| 549 | (if ls-lisp-use-string-collate | ||
| 550 | (string-collate-lessp s1 s2 nil ls-lisp-ignore-case) | ||
| 551 | (let ((u (compare-strings s1 0 nil s2 0 nil ls-lisp-ignore-case))) | ||
| 552 | (and (numberp u) (< u 0)))))) | ||
| 503 | 553 | ||
| 504 | (defun ls-lisp-handle-switches (file-alist switches) | 554 | (defun ls-lisp-handle-switches (file-alist switches) |
| 505 | "Return new FILE-ALIST sorted according to SWITCHES. | 555 | "Return new FILE-ALIST sorted according to SWITCHES. |