GNU bug report logs - #41706
26.1; sort-subr predicate cannot be set successfully

Previous Next

Package: emacs;

Reported by: Marvin Gülker <post+ebugs <at> guelker.eu>

Date: Thu, 4 Jun 2020 11:10:01 UTC

Severity: minor

Found in version 26.1

Full log


View this message in rfc822 format

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Marvin Gülker <post+ebugs <at> guelker.eu>
Cc: 41706 <at> debbugs.gnu.org
Subject: bug#41706: 26.1; sort-subr predicate cannot be set successfully
Date: Thu, 04 Jun 2020 14:11:33 +0200
Marvin Gülker <post+ebugs <at> guelker.eu> writes:

> I copied the source code of `sort-lines' and
> adapted the call to `sort-subr' to use `string-collate-lessp',
> resulting in this function:
>
> (defun my-sort-lines-collate (reverse beg end)
>  (interactive "P\nr")
>  (save-excursion
>    (save-restriction
>      (narrow-to-region beg end)
>      (goto-char (point-min))
>      (let ;; To make `end-of-line' and etc. to ignore fields.
> 	  ((inhibit-field-text-motion t))
> 	(sort-subr reverse 'forward-line 'end-of-line nil nil 'string-collate-lessp)))))
>
> This function, when called, only results in an error "Wrong type
> argument: stringp" (tested in `emacs -Q')

> Wrong type argument: stringp, (193 . 215)

I think you use it wrong: the keys are not strings but cons cells.  So
the predicate function should be something like
`compare-buffer-substrings'.

I guess it would be better to specify a STARTKEYFUN to return a value to
be used as the key.

Michael.




This bug report was last modified 5 years and 5 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.