help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting buffer with string-collate-lessp


From: Michael Heerdegen
Subject: Re: Sorting buffer with string-collate-lessp
Date: Wed, 27 May 2015 13:23:42 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Tassilo Horn <tsdh@gnu.org> writes:

> (cl-letf (((symbol-function 'compare-buffer-substrings)
>            (lambda (b1 s1 e1 b2 s2 e2)
>              (if (string-collate-lessp (buffer-substring s1 e1)
>                                        (buffer-substring s2 e2))
>                  -1
>                1))))
>   (sort-lines nil (point-min) 191))


Alternatively one could call `sort-subr' directly to avoid `cl-letf':

--8<---------------cut here---------------start------------->8---
(sort-subr
 nil
 #'forward-line #'end-of-line
 (lambda () (buffer-substring-no-properties
        (point) (line-end-position)))
 nil
 #'string-collate-lessp)
--8<---------------cut here---------------end--------------->8---


Michael.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]