all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: help-gnu-emacs@gnu.org
Subject: Re: Sorting buffer with string-collate-lessp
Date: Tue, 26 May 2015 18:40:39 +0200	[thread overview]
Message-ID: <87zj4rfg1k.fsf@gmx.us> (raw)
In-Reply-To: 874mmzgutl.fsf@gmx.us

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




  reply	other threads:[~2015-05-26 16:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.3682.1432641217.904.help-gnu-emacs@gnu.org>
2015-05-26 15:37 ` Sorting buffer with string-collate-lessp Emanuel Berg
2015-05-26 15:43   ` Rasmus
2015-05-26 15:52     ` Rasmus
     [not found]     ` <mailman.3702.1432655548.904.help-gnu-emacs@gnu.org>
2015-05-26 16:06       ` Emanuel Berg
2015-05-26 16:36         ` Rasmus
2015-05-26 16:40           ` Rasmus [this message]
2015-05-26 18:01         ` Tassilo Horn
     [not found]         ` <mailman.3706.1432658186.904.help-gnu-emacs@gnu.org>
2015-05-26 22:44           ` Emanuel Berg
2015-05-27  0:12             ` Rasmus
     [not found]             ` <mailman.3732.1432685593.904.help-gnu-emacs@gnu.org>
2015-05-27  0:25               ` Emanuel Berg
2015-05-26 11:53 Rasmus
2015-05-26 14:49 ` Tassilo Horn
2015-05-26 14:53   ` Rasmus
2015-05-26 17:57     ` Tassilo Horn
2015-05-27 11:23       ` Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zj4rfg1k.fsf@gmx.us \
    --to=rasmus@gmx.us \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.