[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Sorting buffer with string-collate-lessp
From: |
Rasmus |
Subject: |
Re: Sorting buffer with string-collate-lessp |
Date: |
Tue, 26 May 2015 18:36:06 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Emanuel Berg <embe8573@student.uu.se> writes:
> Cool - I didn't know there was a new version.
> That will be interesting to see if that breaks any of
> my code. But it isn't in the Debian repos so probably
> you compiled it yourself, ay?
Indeed. The Emacs wiki suggest that there is a Debian repo with Emacs
snapshots.
> Anyhow, that function name ends with a "p" so it is
> a unary function which returns a boolean, I take it.
> So why doesn't it work to do just as you suggested
> with `sort-subr' with that as the third optional
> argument, namely PREDICATE?
Yeah, but you get bufferf pointers. As I hinted in my first post you can
write a boilerplate around it,
(with-temp-buffer
(save-excursion (insert (mapconcat 'symbol-name '(c b a รก) "\n")))
(sort-subr nil 'forward-line 'end-of-line nil nil
(lambda (a b) (funcall
(if (fboundp 'string-collate-lessp)
'string-collate-lessp
'string-lessp)
(buffer-substring (car a) (cdr a))
(buffer-substring (car b) (cdr b)))))
(buffer-string))
But this seems like a lot of trouble just to get locale-aware sorting...
Rasmus
--
Bang bang
- Re: Sorting buffer with string-collate-lessp, Emanuel Berg, 2015/05/26
- Re: Sorting buffer with string-collate-lessp, Rasmus, 2015/05/26
- Re: Sorting buffer with string-collate-lessp, Tassilo Horn, 2015/05/26
- Message not available
- Re: Sorting buffer with string-collate-lessp, Emanuel Berg, 2015/05/26
- Re: Sorting buffer with string-collate-lessp, Rasmus, 2015/05/26
- Message not available
- Re: Sorting buffer with string-collate-lessp, Emanuel Berg, 2015/05/26