Commit 7e1d6bdb authored by Stefan Monnier's avatar Stefan Monnier
Browse files

(regexp-opt-group): Sort the strings when extracting a suffix.

parent 42121c23
...@@ -205,7 +205,10 @@ so we can use character sets rather than grouping parenthesis." ...@@ -205,7 +205,10 @@ so we can use character sets rather than grouping parenthesis."
(if (> (length xiffus) 0) (if (> (length xiffus) 0)
;; common suffix: take it and recurse on the prefixes. ;; common suffix: take it and recurse on the prefixes.
(let* ((n (- (length xiffus))) (let* ((n (- (length xiffus)))
(prefixes (mapcar (lambda (s) (substring s 0 n)) strings))) (prefixes
;; Sorting is necessary in cases such as ("ad" "d").
(sort (mapcar (lambda (s) (substring s 0 n)) strings)
'string-lessp)))
(concat open-group (concat open-group
(regexp-opt-group prefixes t t) (regexp-opt-group prefixes t t)
(regexp-quote (regexp-quote
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment