[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:40:39 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Rasmus <rasmus@gmx.us> writes:
>> 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))
I should have given this function as well:
(with-temp-buffer
(save-excursion (insert (mapconcat 'symbol-name '(c b a á) "\n")))
(sort-subr nil 'forward-line 'end-of-line nil nil
(if (fboundp 'string-collate-lessp)
'string-collate-lessp
'string-lessp))
(buffer-string))
It results in an error (on my system).
Rasmus
--
May contains speling mistake
- 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