From unknown Tue Jun 17 01:28:18 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#41706 <41706@debbugs.gnu.org> To: bug#41706 <41706@debbugs.gnu.org> Subject: Status: 26.1; sort-subr predicate cannot be set successfully Reply-To: bug#41706 <41706@debbugs.gnu.org> Date: Tue, 17 Jun 2025 08:28:18 +0000 retitle 41706 26.1; sort-subr predicate cannot be set successfully reassign 41706 emacs submitter 41706 Marvin G=C3=BClker severity 41706 minor thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 04 07:09:17 2020 Received: (at submit) by debbugs.gnu.org; 4 Jun 2020 11:09:17 +0000 Received: from localhost ([127.0.0.1]:45217 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jgnkL-000648-Ak for submit@debbugs.gnu.org; Thu, 04 Jun 2020 07:09:17 -0400 Received: from lists.gnu.org ([209.51.188.17]:37762) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jgnkK-000641-5E for submit@debbugs.gnu.org; Thu, 04 Jun 2020 07:09:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgnkK-0001c7-19 for bug-gnu-emacs@gnu.org; Thu, 04 Jun 2020 07:09:16 -0400 Received: from mout-p-103.mailbox.org ([80.241.56.161]:21300) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1jgnkI-0005ZD-5u for bug-gnu-emacs@gnu.org; Thu, 04 Jun 2020 07:09:15 -0400 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 49d31x59rRzKmP7 for ; Thu, 4 Jun 2020 13:09:09 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=guelker.eu; s=MBO0001; t=1591268947; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=mikMZsrKR3YDVbHyNWuh6o3vkkY7yKi2A+p2ZXnY0ZU=; b=AqSpAePd8wVwvD72bC64uGKQgx/YdMVCLMRclq2hWkIM0tBmk/pBuslfgILkTNoiS7Vhvw gehLTvxJWoS0UtqhrzdhMLIHtjPE2UHJRxgDZwvhYsxOBJ/NagXltl1rV/u53H8+xJ4LMN RuwoDXuJLVp5YoOG+NBcZwVZ/HcHUkMY3wrAuflrQJMOXx6fzuT+cTuCjnKmiHtK4kGxe4 jC9Y2OpcAF+ZmFnYZXzS+IVih06GN/jysV5W0zV88WMj2HjH7KvYItyB67syzwy/JpfseM +Jc97JknTH6NAnHz7gNu9JAgK2NYzrT95HrmT+WzIztyZI13lc8+maJE7o4/eQ== Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id gJs9eDFTovMi for ; Thu, 4 Jun 2020 13:09:06 +0200 (CEST) Date: Thu, 4 Jun 2020 13:09:22 +0200 From: Marvin =?utf-8?Q?G=C3=BClker?= To: bug-gnu-emacs@gnu.org Subject: 26.1; sort-subr predicate cannot be set successfully Message-ID: <20200604110922.GA9116@atlantis> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline X-Rspamd-Queue-Id: BB8A3175E X-Rspamd-Score: -5.23 / 15.00 / 15.00 Received-SPF: pass client-ip=80.241.56.161; envelope-from=post+ebugs@guelker.eu; helo=mout-p-103.mailbox.org X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/04 07:09:09 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) Dear maintainers, I was trying to define a variant of `sort-lines' which sorts lines according to the current locale's rules, i.e. instead of comparing the strings with the default (as the docs of the underlying function `sort-subr' say) predicate of `string<' they should be compared with `string-collate-lessp'. 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'). Interestingly, if the 6th argument to `sort-subr' is changed to `string<' (which is said to be the default value!) the very same error results. It does not make a difference to explicitely define it with a lambda instead: (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 (lambda (a b) (string-collate-lessp a b))))))) This code results in the same error. I assume this is a kind of bug. Either way, I'd like to request as a feature a variant of `sort-lines' that is aware of the locale's sorting rules. In GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.5) of 2019-09-23, modified by Debian built on x86-grnet-01 Windowing system distributor 'The X.Org Foundation', version 11.0.12004000 System Description: Debian GNU/Linux 10 (buster) Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Mark set my-sort-lines-collate Mark set Wrong type argument: stringp, (193 . 215) Configured using: 'configure --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --enable-libsystemd --with-pop=yes --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/26.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/usr/share/emacs/site-lisp --with-sound=alsa --without-gconf --with-mailutils --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --enable-libsystemd --with-pop=yes --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/26.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/usr/share/emacs/site-lisp --with-sound=alsa --without-gconf --with-mailutils --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2 -fdebug-prefix-map=/build/emacs-StqULU/emacs-26.1+1=. -fstack-protector-strong -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro' Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 THREADS LIBSYSTEMD LCMS2 Important settings: value of $LANG: de_DE.UTF-8 locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow mail-extr emacsbug message rmc puny seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib dired dired-loaddefs format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils sort elec-pair time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 95777 7946) (symbols 48 20407 1) (miscs 40 49 118) (strings 32 28381 1410) (string-bytes 1 744119) (vectors 16 14643) (vector-slots 8 496828 7804) (floats 8 50 209) (intervals 56 304 7) (buffers 992 11)) From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 04 08:11:42 2020 Received: (at 41706) by debbugs.gnu.org; 4 Jun 2020 12:11:43 +0000 Received: from localhost ([127.0.0.1]:45268 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jgoik-0001If-LO for submit@debbugs.gnu.org; Thu, 04 Jun 2020 08:11:42 -0400 Received: from mout.web.de ([212.227.17.11]:49413) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jgoii-0001IP-Ot for 41706@debbugs.gnu.org; Thu, 04 Jun 2020 08:11:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1591272694; bh=IKmgez3QM9hphkwqv5PFR9M8JftKJ/uY+R5zLLe1aLA=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=SqtUbCA6uyEDhrvxccG1/tV9/6CWP2OV+Nvsy+azrQpoaIg1ZTXv5OQzdglL0HTEb Rfy2AbLUceDfmrmn8UO8rWQzkbOpOZAiEDq9iK8CXi23xJo1yzEqpUGFBwzjJHWRT3 /DnfZncIC8E00Ffskmu+XBTIYSDzeNZvs+amgRts= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from drachen.dragon ([94.217.119.187]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LvSU3-1izPGP12ep-010dsy; Thu, 04 Jun 2020 14:11:34 +0200 From: Michael Heerdegen To: Marvin =?utf-8?Q?G=C3=BClker?= Subject: Re: bug#41706: 26.1; sort-subr predicate cannot be set successfully References: <20200604110922.GA9116@atlantis> Date: Thu, 04 Jun 2020 14:11:33 +0200 In-Reply-To: <20200604110922.GA9116@atlantis> ("Marvin =?utf-8?Q?G=C3=BClk?= =?utf-8?Q?er=22's?= message of "Thu, 4 Jun 2020 13:09:22 +0200") Message-ID: <87pnafxc7e.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:fgAZkPkDs3zzHe8QkurTPOMLgOMSoU1ccKXmKuLUywHVjk+vdCh Vgpa3l+YrKQG8OcEh1TvgyKfVJ2d6bfpONXMyV2FmbhzBH5k7E80x12QzmlouDZ+lxUbbrQ U7IbrdrDfTOlTYlw3YGgIHBspesxBY6upu1sEVysi3joG1A0rR15V5fd2ewDg2lsF1pv1sF IXLt2UBZD/vdmlteQEscA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:wV8zUtKl+6I=:8MfEfi6txUYcw0J7KjFhsj aFWPLEbqRNh3W0qiOA6HzciDI/PY0QupRxSyvuPCip576qFSCi5E8hfo6Up0wcWR3G4JlInIm WF2OuqnrUgaxaSFBRKaU55BCWHS9FAFNpLPf0/cjA1WsyD7FqeIc7LSWfAPid03H+HiS0NOmo 2GrFwMJT5w3E246pA+NdXGtOJo+4L5MFguzn08DOdy5wscZw4zdl7tqMIKBp61yIa9XgvLQkD Y/j6ByWu4xXH0SJlysgLC0cd4BTe6dk9qTE/aO7COmSGbg3zoKNHQbwpBAt9AGwab98osRoCe /Ozhq29kI97mGg5ejJtZ5jjGuJDCGlVMQGj0rQ41AOMXT5kqWlY2lwav/qToCseHxik4SmJnT jNRJDnMUdj6anEa0kL1xliBaHZUWxFaSepmZfeKvgvVDtXm814KWNKmQXpSfCQ1kZOwrGB41w 0wq6k2Gl9A81Plxg95G+gWbyIpB+4WsZ4tC6QqDEy6SQRmjGCU/WTZekOpezzlmPQW6E+L+5c 6daCEefi6TEMyqrNdHd12Sb5VXXy4LUXX+U7Cw+n1OOfxy2+7xY1Mx7W/JUom1I6CFttsyrOM hf+K5DdEQyewnXVlSYdaqhGhCGb+kSMRhy2ofAlCQsNrRRmqkvVyQADm1Hp4ZhKkjsOiNZfbg aU0yMXvALNyWIfaqqH6VNrSwtrTkrfmkLXu0rkD9gGwd/sCDDw46HbJJ9N9ndsnxBD+xkLA8D mynJFr2iOp9G+SQUFeyC+GRFozNL0lqG91uIw0YmE/kGEwzX3HLBPmM8+guurwBsFAKAmeMc8 Wq0n9DzSOzyPW65v3rH8SN7OZWk3H6YfIMVkyaejBowZ8gw2qFwxssn+chRnNBAinlnuXsio4 6U7br8frBYuLc/e8PpJ5IF0Hl1gMOv9rafLj6146FLlRRXVnTDPGWIV7AdoTo9HdGVjwkQ9IH 7YDZft/vKQz1ooYwrg0fzDxccbQNJKqC/OgpFhfnUFrekFMsiZa5dX9fZcE/J8ORHdfBGw1q8 VmKZJc6BmIw6vXX5GcV18OZvZqJQLU5ysiUDxmy0Cl+8j9V55tatFeUb6Sz2rCUQRmsZgsJPG tomk79ARPKSOo6NwrD9ZaK3ZAo6tn/CR92irhb5ZSD2TVfY4SS0wGwq35zrRzSKJGjl7EexhK WfBm5WanWxnORnyOG+Lb9wBpD1v0ejISFTD9QAAX9GayrrebVa+HwtrwVePVPimomm7G8y5jm bqZ5OtAyHDFnrT/5LRiepY4kam2O14lef8ATOXg== X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 41706 Cc: 41706@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Marvin G=C3=BClker 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-le= ssp))))) > > 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. From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 04 15:05:07 2020 Received: (at 41706) by debbugs.gnu.org; 4 Jun 2020 19:05:07 +0000 Received: from localhost ([127.0.0.1]:47472 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jgvAp-00084x-CD for submit@debbugs.gnu.org; Thu, 04 Jun 2020 15:05:07 -0400 Received: from mout-p-202.mailbox.org ([80.241.56.172]:29750) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jgvAn-00084I-Ka for 41706@debbugs.gnu.org; Thu, 04 Jun 2020 15:05:06 -0400 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 49dFZz32zFzQlJR; Thu, 4 Jun 2020 21:04:59 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=guelker.eu; s=MBO0001; t=1591297497; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jFSEx/uvn1P5l/BpJODP2JAUMhEyOzuLzRAyEKV3uGc=; b=c2UPxdnRdG64sCXa0nFaAbn/MpGQ2HIK29SJcqcXpS4RnTbjS04DD8UqMF1uPEtkAjXYuZ 6ZV5QLDM3GDWBbjjSpws7xs9Zfl7cK4hI5JqDr3vwmnyUL2c5zJa0q8dxxl6qFURaJQXG2 M0D7ef7EEhduQCr6t3dQ2gL4yzCUsqh/tnFQWEfkn/mobANz3ot4U0mztysCSmytioFfsr wQzp+pnVkb3NWmyK/16ui5ZB3PQaxBTrZ9NRGmSWtrOkTPzl8rbrkkj+OMvIK98Yyy40le 0RZBl8Uu41ilkLgSi/UIrBwdrCKW9RtD13hgPsl56XvAIFaigCg0I5bDlnkvvw== Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de [80.241.56.116]) (amavisd-new, port 10030) with ESMTP id nHllZbPc8vwS; Thu, 4 Jun 2020 21:04:55 +0200 (CEST) Date: Thu, 4 Jun 2020 21:05:26 +0200 From: Marvin =?utf-8?Q?G=C3=BClker?= To: Michael Heerdegen Subject: Re: bug#41706: 26.1; sort-subr predicate cannot be set successfully Message-ID: <20200604190526.GA14104@atlantis> References: <20200604110922.GA9116@atlantis> <87pnafxc7e.fsf@web.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87pnafxc7e.fsf@web.de> X-Rspamd-Queue-Id: F3D4217FA X-Rspamd-Score: -2.63 / 15.00 / 15.00 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 41706 Cc: 41706@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Am 04. Juni 2020 um 14:11 Uhr +0200 schrieb Michael Heerdegen: >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'. You are correct. Your comment put me on the right track (but see below). This version works and sorts the lines according to the locale's rules: (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 (lambda (a b) (string-collate-lessp (buffer-substring (car a) (cdr a)) (buffer-substring (car b) (cdr b))))))))) I have broken it slightly different for readability. The change I did was to use `buffer-substring' in the predicate lambda. It was not clear to me that the arguments given to the predicate function are actually buffer positions and not the buffer substrings themselves as I expected. This is not explained in the manual (section § 32.15) on `sort-subr'). >To understand how ‘sort-subr’ works, consider the whole accessible >portion of the buffer as being divided into disjoint pieces called >“sort records”. The records may or may not be contiguous, but they >must not overlap. A portion of each sort record (perhaps all of >it) is designated as the sort key. [...] >The argument PREDICATE is the function to use to compare keys. If >keys are numbers, it defaults to ‘<’; otherwise it defaults to >string<’. No further mention of how to use PREDICATE is made, and the manual continues with reproducing the source code of `sort-lines'. I took that section to mean that the PREDICATE is in the default case `<' and with strings `string<'. From the manual's text it became not clear to me under which condition the keys are not strings, and I assumed they will normally always be strings as buffer substrings are always strings. Now I see that the documentation for the `sort-subr' function is a little more specific, but still it doesn't really make clear which kind of "key" is received as arguments in the PREDICATE under which conditions. The call above appearently yields cons cell keys whose CAR and CDR correspond to buffer positions, but the documentation makes me suspect that calling `sort-subr' differently will yield other kinds of keys. I would suggest to amend the manual to be more precise about the arguments that PREDICATE receives, and perhaps add an example. Thank you for your explanation. -- Blog: https://mg.guelker.eu From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 05 04:33:11 2020 Received: (at 41706) by debbugs.gnu.org; 5 Jun 2020 08:33:11 +0000 Received: from localhost ([127.0.0.1]:48259 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jh7mp-0002hZ-5X for submit@debbugs.gnu.org; Fri, 05 Jun 2020 04:33:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48948) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jh7mn-0002hM-TP for 41706@debbugs.gnu.org; Fri, 05 Jun 2020 04:33:10 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:48906) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jh7mh-00008r-ET; Fri, 05 Jun 2020 04:33:03 -0400 Received: from [176.228.60.248] (port=2913 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jh7mg-0008S6-6J; Fri, 05 Jun 2020 04:33:03 -0400 Date: Fri, 05 Jun 2020 11:32:51 +0300 Message-Id: <83d06dc3po.fsf@gnu.org> From: Eli Zaretskii To: Marvin =?utf-8?Q?G=C3=BClker?= In-Reply-To: <20200604190526.GA14104@atlantis> (message from Marvin =?utf-8?Q?G=C3=BClker?= on Thu, 4 Jun 2020 21:05:26 +0200) Subject: Re: bug#41706: 26.1; sort-subr predicate cannot be set successfully References: <20200604110922.GA9116@atlantis> <87pnafxc7e.fsf@web.de> <20200604190526.GA14104@atlantis> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41706 Cc: michael_heerdegen@web.de, 41706@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Thu, 4 Jun 2020 21:05:26 +0200 > From: Marvin Gülker > Cc: 41706@debbugs.gnu.org > > >To understand how ‘sort-subr’ works, consider the whole accessible > >portion of the buffer as being divided into disjoint pieces called > >“sort records”. The records may or may not be contiguous, but they > >must not overlap. A portion of each sort record (perhaps all of > >it) is designated as the sort key. [...] > >The argument PREDICATE is the function to use to compare keys. If > >keys are numbers, it defaults to ‘<’; otherwise it defaults to > >string<’. > > No further mention of how to use PREDICATE is made, and the manual > continues with reproducing the source code of `sort-lines'. I took that > section to mean that the PREDICATE is in the default case `<' and > with strings `string<'. From the manual's text it became not clear to me > under which condition the keys are not strings, and I assumed they will > normally always be strings as buffer substrings are always strings. > > Now I see that the documentation for the `sort-subr' function is a > little more specific, but still it doesn't really make clear which kind > of "key" is received as arguments in the PREDICATE under which > conditions. The call above appearently yields cons cell keys whose CAR > and CDR correspond to buffer positions, but the documentation makes me > suspect that calling `sort-subr' differently will yield other kinds of > keys. > > I would suggest to amend the manual to be more precise about the > arguments that PREDICATE receives, and perhaps add an example. It is hard to be specific about the arguments to PREDICATE, because they depend on what the other arguments to sort-subr return. I augmented the manual to at least have the same information as the doc string; more detail is only possible if we discuss specific values of STARTKEYFUN and ENDKEYFUN. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 05 05:43:29 2020 Received: (at 41706) by debbugs.gnu.org; 5 Jun 2020 09:43:29 +0000 Received: from localhost ([127.0.0.1]:48367 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jh8sr-0004SB-2s for submit@debbugs.gnu.org; Fri, 05 Jun 2020 05:43:29 -0400 Received: from mout.web.de ([212.227.17.12]:34235) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jh8sp-0004Rw-0v for 41706@debbugs.gnu.org; Fri, 05 Jun 2020 05:43:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1591350200; bh=F7m6B/s7yhpaHmDVjDHTBjkSim+ztdRsuHV5yW8TN58=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=LVVvUkAzoRZTKAqdePwe+qmRQFF/yOPGsa/G2mSPcN6nzMODknMcOFoT3w57haN2s zMWbTDAKd5GkCR6oftNJiYW3Y74m0LcDAMVl93Flsj7wvhsLLSJUiN6w45a6Dz4TKI EdUTHC6cBSHeciFi8+bi4gvIeTXStVJ696Hw1nxE= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from drachen.dragon ([94.217.119.187]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1Mfc8o-1j1TOq1cbI-00fqjh; Fri, 05 Jun 2020 11:43:20 +0200 From: Michael Heerdegen To: Eli Zaretskii Subject: Re: bug#41706: 26.1; sort-subr predicate cannot be set successfully References: <20200604110922.GA9116@atlantis> <87pnafxc7e.fsf@web.de> <20200604190526.GA14104@atlantis> <83d06dc3po.fsf@gnu.org> Date: Fri, 05 Jun 2020 11:43:19 +0200 In-Reply-To: <83d06dc3po.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 05 Jun 2020 11:32:51 +0300") Message-ID: <87h7vpg85k.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:C58sWIGsDf+l3d6KeAv5FJGPLrunquze8Km6ifP+gCnOSUJ86Qt u/dGX2tM7oVw0roctun+pRs1vUsUJHKVA5+5xKF8D2Migyd0+BviYnA3ZjQHG4BMsJJ449F V92n1mwaMfJR7hx7ZDwFa4k/OBPCwXHEg8NK/4mNmd1a01ZqzXKGPCeaWRGdsT+/SaQVBak KK61gs8Y1WkS3uYjS+ONQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:FNGWDKc7THg=:m3J/eo0uxOy4chW5Zm3z2y th1BM5CNzNHwPwCfMRSs/vrzHM9kTKcJRiqqpycRwa1r/ovfP97CgNDzblxGT52nVT7jJaCny ljHcptRs9J9J6oBe+5smkkk/nH8fxphcZBzXhKxyRweJwxTB1zCCltoL0wa1qX4vwleCADjLC 6UjE3lfU6ZPn7QgEgL88zGsvPExIyJoD3V+5PD728UcgZOKcl7N8bpRkRUBpbQzHV3TwTiQw+ r/p8l/TFUKWA+beM7rwpTyKhKzKjg+l12tVae9pWYawnETdvnyHNL4OqL4RN0lp9Ni3/k9OUh ZzxFxwp2RJlC/4A9z9Gu2GF0PGiBOdtPp3Odq6WRoQriMsruMZMQMx3jPbZiyNw1aj/28k/Cf s5FCpbvZUKhdDWGsMH74urRGQk41EmzBTwq3xb1fetGg/1FtPCmzPGUhWqWgUali35OyZ6gdB G4iBazY0r0uMVZ+dx0ApGeJsyCRZthH7LGqN3oWVyOxNuYql5cZrC/QmHhJpLvS25xVFO4S+n AwSgCc3/Pm3EvgWmhruhEUlvtGzyLZCQGD0NUicRmvvP7vS0iBF0faQCvcatU+t6LGdtEtucC xSHpILFjgTDUKcxx1BsvPXDe1+toYW2KxP1IfG/x3gf5qSMW8IqWHfY8VpnFkKfd3G+jSqzNm uLdJfuP/KD7YRPMCX/Gfpi30bWr9171aexRzUQtO6CR9KZF2W+VNFU/VL09XYRkj8ja0GapSn ghjodfztBP2u/UvycaZEwppG+Ax6ppDn4VX0Svyp5gyHNibcictQoAcGy0vGG5Oo1XC2dLDyN yLhlLJD9/IyZj+FyW2UucbDuJkJfV2yMMa+/LjfZ81hVpCzRzjFd8apBD1kbdJQTnPlG1SvqC hm3G9e3E7LCZdZmaApCHkgNO+jWE/J4H3qxviJgNnABJinkL+PCP0Vs+YFf43TgvP+aYnZT6o WwzjPGUlVWatZbpWkTNn3hWlTSg7beOeIzrx27xepeEejsTbQuxd9qoQJdV8VOWHDEWbgzgz1 xVB1XijJvDtyUsGC4ch0aybqEdY33gYPp5Un6cpOD/8jnyU0Ep545oWTSXoYqkyPOoX2ii/Fa wDQANJOxa2NgB07tXrsAHLPfCL6NHXQkgymvZZx8pxcMmhZTwPZ7B7o0Ft5wdrKIeVtWFAVJM px6u9SllpPQAtWPBr/pYclDT9+VutMzgToOb3/ZJE1bkXFyb3Ii+zBtYJepu6AdXT7bBTFqij yXCN6+RN9UGIku+2Bq9KJoX2Egq6SJ6OEseLSsw== X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 41706 Cc: 41706@debbugs.gnu.org, Marvin =?utf-8?Q?G=C3=BClker?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Eli Zaretskii writes: > It is hard to be specific about the arguments to PREDICATE, because > they depend on what the other arguments to sort-subr return. I > augmented the manual to at least have the same information as the doc > string; more detail is only possible if we discuss specific values of > STARTKEYFUN and ENDKEYFUN. But this sentence is not correct: "It [i.e. STARTKEYFUN, added by me] may return either a non-nil value to be used as the key, or else the key is the substring between the values of point after STARTKEYFUN and ENDKEYFUN are called." This is the sentence that misled the OP I think. Could we be more precise and tell that the key is actually the cons cell (BEG . END) denoting these strings? Michael. From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 05 07:43:59 2020 Received: (at 41706) by debbugs.gnu.org; 5 Jun 2020 11:43:59 +0000 Received: from localhost ([127.0.0.1]:48440 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhAlS-00016E-UW for submit@debbugs.gnu.org; Fri, 05 Jun 2020 07:43:59 -0400 Received: from eggs.gnu.org ([209.51.188.92]:41318) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhAlR-00015x-Jx for 41706@debbugs.gnu.org; Fri, 05 Jun 2020 07:43:57 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:60511) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhAlJ-0005xo-Pe; Fri, 05 Jun 2020 07:43:52 -0400 Received: from [176.228.60.248] (port=2606 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jhAlJ-0005rh-65; Fri, 05 Jun 2020 07:43:49 -0400 Date: Fri, 05 Jun 2020 14:43:39 +0300 Message-Id: <83a71hbuvo.fsf@gnu.org> From: Eli Zaretskii To: Michael Heerdegen In-Reply-To: <87h7vpg85k.fsf@web.de> (message from Michael Heerdegen on Fri, 05 Jun 2020 11:43:19 +0200) Subject: Re: bug#41706: 26.1; sort-subr predicate cannot be set successfully References: <20200604110922.GA9116@atlantis> <87pnafxc7e.fsf@web.de> <20200604190526.GA14104@atlantis> <83d06dc3po.fsf@gnu.org> <87h7vpg85k.fsf@web.de> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41706 Cc: 41706@debbugs.gnu.org, post+ebugs@guelker.eu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Michael Heerdegen > Cc: Marvin Glker , > 41706@debbugs.gnu.org > Date: Fri, 05 Jun 2020 11:43:19 +0200 > > Eli Zaretskii writes: > > > It is hard to be specific about the arguments to PREDICATE, because > > they depend on what the other arguments to sort-subr return. I > > augmented the manual to at least have the same information as the doc > > string; more detail is only possible if we discuss specific values of > > STARTKEYFUN and ENDKEYFUN. > > But this sentence is not correct: > > "It [i.e. STARTKEYFUN, added by me] may return either a non-nil value to > be used as the key, or else the key is the substring between the values > of point after STARTKEYFUN and ENDKEYFUN are called." I didn't change that part. > This is the sentence that misled the OP I think. Could we be more > precise and tell that the key is actually the cons cell (BEG . END) > denoting these strings? Patches welcome. From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 10 14:59:41 2020 Received: (at 41706) by debbugs.gnu.org; 10 Jun 2020 18:59:41 +0000 Received: from localhost ([127.0.0.1]:35369 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jj5wq-0000Xk-QL for submit@debbugs.gnu.org; Wed, 10 Jun 2020 14:59:41 -0400 Received: from mout.web.de ([212.227.17.12]:48267) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jj5wp-0000XV-GY for 41706@debbugs.gnu.org; Wed, 10 Jun 2020 14:59:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1591815572; bh=NLi6KIKH+bDIz6D9++VyryuiPcKn9woWG6dxwdlhZrk=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=Uas1e2e5gkd6lLJLvlcTC3j+6a8aRZiTtd02uci2RDv+RlivcCnEl8fOTjCex0RZ+ VcqRlbJ2T7e2igV8tXQn41snTskrhXGBcY6AFinwl0N/awAMzMvZcWRXzEke8mOKFn Z5s/PiDVvia/alZuhMkztAPqmNVx9WMgDIdGFfu4= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from drachen.dragon ([94.217.119.187]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MnpGi-1j8MQQ1a4w-00pMYH; Wed, 10 Jun 2020 20:59:32 +0200 From: Michael Heerdegen To: Eli Zaretskii Subject: Re: bug#41706: 26.1; sort-subr predicate cannot be set successfully References: <20200604110922.GA9116@atlantis> <87pnafxc7e.fsf@web.de> <20200604190526.GA14104@atlantis> <83d06dc3po.fsf@gnu.org> <87h7vpg85k.fsf@web.de> <83a71hbuvo.fsf@gnu.org> Date: Wed, 10 Jun 2020 20:59:30 +0200 In-Reply-To: <83a71hbuvo.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 05 Jun 2020 14:43:39 +0300") Message-ID: <874kriiw6l.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Provags-ID: V03:K1:BUdh0W6I4ma1+RgBOV+g5ztciR+3IEcsBifxpSBKhDUaIj8eW9d 9KxyqWTa5WGvAxbq0yI/BgkbnW9kDGT7ntgz8RTT0LNIJEHGi0CC8uj+OLNoVCkNwC6XCyq StFXsT8hBzaMCeQDeVIgcie0ys3WTU76crCoyddBUKZU/ITxXBcwIj2VuHi1iCOrPypJIwO R9tBFIcutkPffFVBJ3mHw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:WTCfR/7ko6Y=:kVzBsCm7QWtOxpWFhjtBbX +ikbKpz/J37DpE1c5njXmNWzXvvKjWqfue5xJQZiJh5sZaD9O0pYL+5JP1fIl74y2lVcsptVa ILrRlTdDaT7Yiht9mZNO5TOeifTXnNmBRj/xTEIK6fih7z/5jBLru/jgqr9Y9XTaSSpu4wlPh DJ1bsF04u9ngeFEyxT+/vrKkDB4Y47uBlWrkLKFx4ozz064eiCRvclc9h3t+giH1T4Sy2qdmr RUC52vgLJW/G8jmvu48V66df5g0AXdVWZkUqmh+5pJKM+cvBe3b8YuHhauPTpytHi6S4zzXTg cRJtrNlmm1txxJHV2MN57eZd5++uCSci4AP5wLYmfNibwoYI0SPbJg+4sQB4jHjXfrnFoEEoH Ctxh8TFbFj8JpEII6/e4lUKlDSqeEb0AzaK43W2+7lF1dUxuIa3dkahiQQvINSh+aCZ+FsZ30 D+qoxK3vnzzxUTWSe7Bwgv68yrdtgazQkULpm+ikz+q3iDgDyhsFW95fDKo4qfzRHhtqwOD4G YMOHVMM51pFYZ0BFQXguLMJI43qcVKAfBGwC6nOfH1nqJzYsOoZbQrEAsD8J7fnlndOXVdw9B l8mRNCxGzwskEaPvENJ6gt8ym0K0EGVZJPm1kR5Bv8uAfcKsAq1I8TqASWbep5U9ecPhryHn6 EeuNp5Qj0i0xk6C70ClQj8he6uB14aQhH7LpTfN0uJi7Yo5gXRFglXYTo/GkzOm6f9UjB8x0+ qBFixptdR06Fzws2H0zmDTbwDQNWGE+zeuzR5u+weZkmsebA+Isp65KU9UyTRgtzAapLo1ghV USQYHPvklJDlDUoeHwNxmp0dL3GepFaq6jdzu5KgqXr+6zHoxbtehwOSi6R4gSksAIdLwj15+ DOC/q1Dc3b6Vl0UJHld4yG0U1xeGDZjihet/Y6aGN1mhUurn5wAIRmElfPrkTi6e9N7QeYyQm 2Az+iak32qDd+DJLsj/nDSL7J4mV099mj9XCFM6ujmi7+GVXUIZBiT3NyKM9vRT4dm+P6mClH ZN20W5CDCBPnczMTMYdx7c+IAW7QygXz8YNeemItuAMcyYWwb4rAm8V+hVzKcI+lo0uVZxnEF LKq00nR9PI6Nq9TdJZLXKfCE9A/5yZW9ebzVul6U1PzfIVZbuFbDPhDlxoMyW3oYoxXrEMhqE /NXIDGpb5mx7PITORtvSJdAS2cqPUWaKjw9wNy/zeL3EyWS7rYkso+s+hhk/sHg6NMdgBmsrd crF+Q2ZXY9k1I8O3r9l0g3NdgHRePBJzt09NyFQ== X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 41706 Cc: 41706@debbugs.gnu.org, post+ebugs@guelker.eu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: > > This is the sentence that misled the OP I think. Could we be more > > precise and tell that the key is actually the cons cell (BEG . END) > > denoting these strings? > > Patches welcome. Something like this (maybe enhanced using better English): --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=subr.patch Content-Transfer-Encoding: quoted-printable diff --git a/lisp/sort.el b/lisp/sort.el index de0e1b9519..a87f33eaee 100644 =2D-- a/lisp/sort.el +++ b/lisp/sort.el @@ -67,11 +67,12 @@ sort-subr ENDRECFUN is called with point within the record. It should move point to the end of the record. -STARTKEYFUN moves from the start of the record to the start of the key. -It may return either a non-nil value to be used as the key, or -else the key is the substring between the values of point after -STARTKEYFUN and ENDKEYFUN are called. If STARTKEYFUN is nil, the key -starts at the beginning of the record. +STARTKEYFUN moves from the start of the record to the start of +the key. It may return either a non-nil value to be used as the +key, or else the key is a cons (BEG . END) designating the +substring of the record between the values of point after +STARTKEYFUN and ENDKEYFUN are called. If STARTKEYFUN is nil, the +key starts at the beginning of the record. ENDKEYFUN moves from the start of the sort key to the end of the sort key= . ENDKEYFUN may be nil if STARTKEYFUN returns a value or if it would be the --=-=-= Content-Type: text/plain Then the doc should already list all possible key formats AFAIU. BTW, what about the suggestion to support collation order out of the box? Thanks, Michael. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 10 15:08:47 2020 Received: (at 41706) by debbugs.gnu.org; 10 Jun 2020 19:08:47 +0000 Received: from localhost ([127.0.0.1]:35384 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jj65f-0000np-7U for submit@debbugs.gnu.org; Wed, 10 Jun 2020 15:08:47 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49700) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jj65d-0000nc-DG for 41706@debbugs.gnu.org; Wed, 10 Jun 2020 15:08:45 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:47029) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jj65W-0006ji-KZ; Wed, 10 Jun 2020 15:08:39 -0400 Received: from [176.228.60.248] (port=4123 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jj65V-000642-Uf; Wed, 10 Jun 2020 15:08:38 -0400 Date: Wed, 10 Jun 2020 22:08:21 +0300 Message-Id: <83k10e68nu.fsf@gnu.org> From: Eli Zaretskii To: Michael Heerdegen In-Reply-To: <874kriiw6l.fsf@web.de> (message from Michael Heerdegen on Wed, 10 Jun 2020 20:59:30 +0200) Subject: Re: bug#41706: 26.1; sort-subr predicate cannot be set successfully References: <20200604110922.GA9116@atlantis> <87pnafxc7e.fsf@web.de> <20200604190526.GA14104@atlantis> <83d06dc3po.fsf@gnu.org> <87h7vpg85k.fsf@web.de> <83a71hbuvo.fsf@gnu.org> <874kriiw6l.fsf@web.de> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41706 Cc: 41706@debbugs.gnu.org, post+ebugs@guelker.eu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Michael Heerdegen > Cc: post+ebugs@guelker.eu, 41706@debbugs.gnu.org > Date: Wed, 10 Jun 2020 20:59:30 +0200 > > +STARTKEYFUN moves from the start of the record to the start of > +the key. It may return either a non-nil value to be used as the > +key, or else the key is a cons (BEG . END) designating the > +substring of the record between the values of point after > +STARTKEYFUN and ENDKEYFUN are called. If STARTKEYFUN is nil, the > +key starts at the beginning of the record. That's a beginning, thanks. But it needs more work, IMO: . the cons cell case hints on a possible return value of STARTKEYFUN, AFAIU, but the text doesn't say so . the case of STARTKEYFUN being nil is another use case for what PREDICATE must cope with, and the text should say so . the text about ENDKEYFUN should also be augmented, IMO . the description of PREDICATE should reference this text in some useful way > BTW, what about the suggestion to support collation order out of the > box? What collation would you like to support, and in what form? From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 11 08:55:26 2020 Received: (at 41706) by debbugs.gnu.org; 11 Jun 2020 12:55:26 +0000 Received: from localhost ([127.0.0.1]:36273 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjMjt-00012T-Il for submit@debbugs.gnu.org; Thu, 11 Jun 2020 08:55:26 -0400 Received: from mout.web.de ([212.227.15.4]:54057) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjMjr-00012B-81 for 41706@debbugs.gnu.org; Thu, 11 Jun 2020 08:55:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1591880115; bh=BXaTL/+kLpqCfyrSqAfLh87Bzuwh3biy0QRoRmKanDs=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=TksBQqd74zUZUYm++UrqrKRbloXc5Rz/JK3GNwSf6P9CCEysDRY9qaFAPXafFDuNT cQF+qYsN5viKvSiOLNoemNDY7GN6fCskPdsWF2Opdjfv6CWdRpztD4jAVCctKWSgSQ PGNxQNsZEeM6JWGu5V5pzY0zhpMJ6VtWW0D7s/QM= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from drachen.dragon ([94.217.119.187]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1Mv3US-1ism7H1fbk-00qwjs; Thu, 11 Jun 2020 14:55:15 +0200 From: Michael Heerdegen To: Eli Zaretskii Subject: Re: bug#41706: 26.1; sort-subr predicate cannot be set successfully References: <20200604110922.GA9116@atlantis> <87pnafxc7e.fsf@web.de> <20200604190526.GA14104@atlantis> <83d06dc3po.fsf@gnu.org> <87h7vpg85k.fsf@web.de> <83a71hbuvo.fsf@gnu.org> <874kriiw6l.fsf@web.de> <83k10e68nu.fsf@gnu.org> Date: Thu, 11 Jun 2020 14:55:14 +0200 In-Reply-To: <83k10e68nu.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 10 Jun 2020 22:08:21 +0300") Message-ID: <87tuzhpxsd.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Provags-ID: V03:K1:nDV+qooVQcWwwiq4m3RlUABq4m0Kx9wvnJE21f27okg+lDt5oXV G677sJ69S+OoTIWX0FuxQLcyB/R+FWdGo/9fVEahB454vRbeC8XE95/kL6VtIiE/V1gUB/B R9SWYHyZ6ankqClQWbnw/Vypgr2pbwdEVVWwfBkk41kZz3RY+u2Q7r5oLO15+E+P7vO7D3T rNSLb1lm5vFv2I0I4I2zA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:Hgf+b1ho0GY=:si9hI995ueLIf+ujKijHgu JwSfDMQigU6ocHDKYL9mkRpJ7tWWEC6D07iRlsOoeWhaKPuRlkcBa4RClWlkbwRY7JdOihOYF ljJ7YhJnA7ejwi79wCgimlvJIFI/X/xG3bGZ9uY3OhRW5jVH4Wg/4Lu2Z3CGeDPVxzp9ggTw7 6hSfAiPhN6veuvRLciMiWUEdfPfH+M85DHSOIQQOxa9lp5hOFMCdEGmoR5MM0T42KkO6OtrAi f7XFPSB9sK2xPOnz6WYyT3yEV2m5bQvsVzqdz2kfekaEuc5Isv/iU3qh6JWJCrMgchU/TjipS Y7YEMWIRxUnmEszWRBNP1bjFjaqUWLoRbeDtWL8zOMpknzk6QRcC8mp/s7180nQOsjt3VgJX+ qfJu8RDIEEM1EAczDo1IugiLPuFsaBIdQ3oMzcnV7tJ6NWPh82X1wFOX2lnBkvzQThl7XG31E P8iDbBTx72b046IbF3S4of7msKwAuE1mkXWw45RNBjXNNz6FyiDP7/thR+DGYXHP2TI5kzmme 2aNTdvM5JuToXVw02Mwg5PPN8FARK/f4uJEHNnCtiWckjyGeIU1gFyRTk6J9neIN6PQh/8z0g P26iZXH9E2lEjmgfHPNvdATZtHdZwcFzJbqtbQxaDGCOaEsVAE9WxyR7l6wAMwKutP24cr0M7 Vcb2mGRZKdnnJy9T/9v+2sIbxBpbjBKBGf0N7q939gAt0L01/kUP8D/dDh67I3/ylDShHi/3W 8588q7jf7L/96X5B/TVsA89LNurOq11ViNRiWMSLFotUToEdBFMIqOpoHcAoXnVKBxMkz0r7M CiI/m5OTV44zUGi/thoC8yTsgsbJl/cisIKq3Yb7ESG2GXD32C9zccL37Ipx5HATeY8chBGex 7Pu0y4sCyZ3t/39WclX9J95ppAhwIs7oZDa+3WluK2jMYS/IirlJL/wtYUpKrA36URPhZhSHV RHM+YaRkLFYINUwORqqDiSUzcWzyiRCSQIuy438QoV3ny/SFL0EPtHCPiSuv4f701KluwvIPi tb/s0T5NPzxP38/TDHwT+cUa7PlnR17xCiF3mDRkMgPuaZJmqVLIbAhtJY7WTH4W1f6cGsqoc ckVGoaG27i8vT0RSND+uQnMzJMhfGJ/12nVyJyMkALVNCGKdpd1A3HFxFneJsUpwSYe9aZXKO uWmbI+fg21BEDG2D/7gp6l7ZUuh95i5ll8a8sBVJWvyXSicQNqv9WFG8htg23bQd/mfLc51G5 tcm743bffya/Pi0sm X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 41706 Cc: 41706@debbugs.gnu.org, post+ebugs@guelker.eu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: > That's a beginning, thanks. But it needs more work, IMO: > > . the cons cell case hints on a possible return value of STARTKEYFUN, > AFAIU, but the text doesn't say so > . the case of STARTKEYFUN being nil is another use case for what > PREDICATE must cope with, and the text should say so > . the text about ENDKEYFUN should also be augmented, IMO > . the description of PREDICATE should reference this text in some > useful way I must admit I found the doc sufficient for all of these. Actually, reading the implementation might be simpler than describing it: #+begin_src emacs-lisp (setq key (catch 'key (or (and startkeyfun (funcall startkeyfun)) ;; If key was not returned as value, ;; move to end of key and get key from the buffer. (let ((start (point))) (funcall (or endkeyfun (prog1 endrecfun (setq done t)))) (cons start (point)))))) #+end_src What the doc is missing to mention is the `catch' - `sort-regexp-fields' uses this feature for example. Here is an attempt (not including the `catch' feature), anyway: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=sort-subr.patch diff --git a/lisp/sort.el b/lisp/sort.el index de0e1b9519..e22f062dbd 100644 --- a/lisp/sort.el +++ b/lisp/sort.el @@ -80,7 +80,15 @@ sort-subr PREDICATE, if non-nil, is the predicate function for comparing keys; it is called with two arguments, the keys to compare, and should return non-nil if the first key should sort before the -second key. If PREDICATE is nil, comparison is done with `<' if +second key. The key values PREDICATE is called with are the +either the return values of STARTKEYFUN when that function is +specified and returns a non-nil value. In any other case the keys +are cons cells of the form (BEG . END), where BEG is the value of +point after calling STARTKEYFUN when given, else after calling +ENDRECFUN, and END is the value of point after calling ENDKEYFUN when +given, and after calling ENDRECFUN else. + +If PREDICATE is nil, comparison is done with `<' if the keys are numbers, with `compare-buffer-substrings' if the keys are cons cells (the car and cdr of each cons cell are taken as start and end positions), and with `string<' otherwise." --=-=-= Content-Type: text/plain What I also would like to add to the docstring of this function, and of that of `sort', is that the PREDICATE must be transitive and antisymmetric - mentioning only in the manual is not enough IMHO. > > BTW, what about the suggestion to support collation order out of the > > box? > > What collation would you like to support, and in what form? I don't know much about this stuff. The canonical way from my ignorant point of view would be that `compare-buffer-substrings' would not only respect `case-fold-search' but also some other variable which would tell how the behavior should be w.r.t. collation. Michael. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 11 09:40:29 2020 Received: (at 41706) by debbugs.gnu.org; 11 Jun 2020 13:40:29 +0000 Received: from localhost ([127.0.0.1]:36362 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjNRU-0002IK-Nt for submit@debbugs.gnu.org; Thu, 11 Jun 2020 09:40:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36372) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjNRS-0002I3-Kq for 41706@debbugs.gnu.org; Thu, 11 Jun 2020 09:40:26 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:33886) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjNRM-0005sI-Ai; Thu, 11 Jun 2020 09:40:20 -0400 Received: from [176.228.60.248] (port=4398 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jjNRK-0004Uy-Dy; Thu, 11 Jun 2020 09:40:19 -0400 Date: Thu, 11 Jun 2020 16:39:59 +0300 Message-Id: <838sgt67rk.fsf@gnu.org> From: Eli Zaretskii To: Michael Heerdegen In-Reply-To: <87tuzhpxsd.fsf@web.de> (message from Michael Heerdegen on Thu, 11 Jun 2020 14:55:14 +0200) Subject: Re: bug#41706: 26.1; sort-subr predicate cannot be set successfully References: <20200604110922.GA9116@atlantis> <87pnafxc7e.fsf@web.de> <20200604190526.GA14104@atlantis> <83d06dc3po.fsf@gnu.org> <87h7vpg85k.fsf@web.de> <83a71hbuvo.fsf@gnu.org> <874kriiw6l.fsf@web.de> <83k10e68nu.fsf@gnu.org> <87tuzhpxsd.fsf@web.de> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41706 Cc: 41706@debbugs.gnu.org, post+ebugs@guelker.eu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Michael Heerdegen > Cc: post+ebugs@guelker.eu, 41706@debbugs.gnu.org > Date: Thu, 11 Jun 2020 14:55:14 +0200 > > > . the cons cell case hints on a possible return value of STARTKEYFUN, > > AFAIU, but the text doesn't say so > > . the case of STARTKEYFUN being nil is another use case for what > > PREDICATE must cope with, and the text should say so > > . the text about ENDKEYFUN should also be augmented, IMO > > . the description of PREDICATE should reference this text in some > > useful way > > I must admit I found the doc sufficient for all of these. Actually, > reading the implementation might be simpler than describing it: It is? if so, that's a clear sign that the description "needs work", IME. > --- a/lisp/sort.el > +++ b/lisp/sort.el > @@ -80,7 +80,15 @@ sort-subr > PREDICATE, if non-nil, is the predicate function for comparing > keys; it is called with two arguments, the keys to compare, and > should return non-nil if the first key should sort before the > -second key. If PREDICATE is nil, comparison is done with `<' if > +second key. The key values PREDICATE is called with are the > +either the return values of STARTKEYFUN when that function is > +specified and returns a non-nil value. The last sentence is incomplete and/or needs some fixing, AFAICT. > In any other case the keys > +are cons cells of the form (BEG . END), where BEG is the value of > +point after calling STARTKEYFUN when given, else after calling > +ENDRECFUN, and END is the value of point after calling ENDKEYFUN when > +given, and after calling ENDRECFUN else. This seems to contradict the following part, which seems to say that the key arguments are not always cons cells: > +If PREDICATE is nil, comparison is done with `<' if > the keys are numbers, with `compare-buffer-substrings' if the > keys are cons cells (the car and cdr of each cons cell are taken > as start and end positions), and with `string<' otherwise." Am I missing something? > What I also would like to add to the docstring of this function, and of > that of `sort', is that the PREDICATE must be transitive and > antisymmetric - mentioning only in the manual is not enough IMHO. Fine with me, provided that you explain what those two attributes mean. > > > BTW, what about the suggestion to support collation order out of the > > > box? > > > > What collation would you like to support, and in what form? > > I don't know much about this stuff. The canonical way from my ignorant > point of view would be that `compare-buffer-substrings' would not only > respect `case-fold-search' but also some other variable which would tell > how the behavior should be w.r.t. collation. The main problem with collation is that it's locale-specific, and different C libraries implement collation for the same locale in slightly different ways. The result is that the sorted text may not be the same even if you do that on two systems in the same locale. How would you suggest to solve this issue? From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 11 09:59:49 2020 Received: (at 41706) by debbugs.gnu.org; 11 Jun 2020 13:59:49 +0000 Received: from localhost ([127.0.0.1]:37615 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjNkD-00039p-1O for submit@debbugs.gnu.org; Thu, 11 Jun 2020 09:59:49 -0400 Received: from mout.web.de ([217.72.192.78]:39385) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjNkB-00039c-AH for 41706@debbugs.gnu.org; Thu, 11 Jun 2020 09:59:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1591883980; bh=2acCui4RdAcw6+PicD1kBahznAUAy+9UlhTXlS/pFDg=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=MM8cdRmzJ2z6DSEKFZPWTGjFD0D37/k33SQ+Y6aq7lcNP7oZcJjIlt4xlv0v8xRhJ NAn4XrG0jXuKYv4xnZM8N9q+woU3vUStwspP5ZquvRzr+hbw3dNL8YQ1lSTSEQayUA ekdPQuxb+1/RLMW+BVQYx7WJtZsDTfe3vOz/wb/8= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from drachen.dragon ([94.217.119.187]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MHEbq-1jevm82QSG-00DMaX; Thu, 11 Jun 2020 15:59:40 +0200 From: Michael Heerdegen To: Eli Zaretskii Subject: Re: bug#41706: 26.1; sort-subr predicate cannot be set successfully References: <20200604110922.GA9116@atlantis> <87pnafxc7e.fsf@web.de> <20200604190526.GA14104@atlantis> <83d06dc3po.fsf@gnu.org> <87h7vpg85k.fsf@web.de> <83a71hbuvo.fsf@gnu.org> <874kriiw6l.fsf@web.de> <83k10e68nu.fsf@gnu.org> <87tuzhpxsd.fsf@web.de> <838sgt67rk.fsf@gnu.org> Date: Thu, 11 Jun 2020 15:59:39 +0200 In-Reply-To: <838sgt67rk.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 11 Jun 2020 16:39:59 +0300") Message-ID: <87pna5put0.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:7G1KLpy4gH8X+oPMR+nW2B+UApfPeKYLvDEiX5ewe8GR9AZ/NyY +MhD7TmvF+o3UCcr++jrapn6tC5+z81nnc19UG3zys1MmbxYOPqq0hlqq1AvFxjA5orIKGP NrXPg6e95n7EtM8v3bm2KrRIMs+Jtp9pgh4etB0b4DUPWrCO+N6pB2+v+pjZOz+ixmzDrsZ 99LEuAnZ+siMCQIy13N5Q== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:sqMDV+PkABA=:jY4H7ZfatBzSbNFT78KKtT DjTPQBJJj1QEbdJ4N4qHmTSeE+vTxsHEUPZJOR3pOaBFVcBj6CdkNN0R48Y+HEIZGWfDrFTQm WnupXxW2PxKssbdTKQrk96pgOhPt2T3/N/axjJTlVKKH+ykccAQRzhCToR+/qAmuwtPULwfMu W9c8nn7UdI0ld15bsSWY04kpOlceYeF7n79GxvJxpB4AYv6V8kH9gRELsC17BzgzOL0QXv+pS c6DidHHFiRHP2GERIMztW9cKOUhzRDuzqXGyW5g0OXsUxjG+K1WRqGz6NveywtbK/3vhtiWz3 IZ5xh/Tj+vHqXvv3K667X+pjpGt0sWhV4me8wu7nWhJjQoeOwOOmyVf1c2gcEQtTh6tmTjPKd ZpIEMEFbliQD6jSdcrOkd5YzBnjN7eofelXrVjDFWJVjBFqETxVn0q1HGLtM2sWDT/gmDZ6mC maqm7a/XxRQhnoNdR111+qdh8N38YRxNfsnROVNDERSG4YvgFnHxb54G3S/Hrf5Sknq5f64Sm Cf2PneZu/tBBRj6ECX43mkU6fUT11glG0clr/yUafkK8zSdhCe7p5GDFi2O0p1TYlOjjdRK/I b7FwM7PIn2v4QR2ttX3ImJIuqdOr2f45mPqsDvaFqiVWJXRDkf8dRX0H+XousPWqfPrvq1ulk 6ZWJ95a6V9n2nZFbxxDNQfjKP9bwK7gz3mnpgxx+c3O4Xew3Qu2Kdf+/R/PEsdw9MDcOVLdJx cBbFXZkhT41Z0Az00kCYc56pZf4kfkP/py3dJK3fbu74H8aS0Hrwi9RfNKy6hnDt6iYUZW/fW k7gZbOPTlxs8VqSZ6P4hv2rL9AZwv6PyPwm0bMypY2ZLME5FrVH1XF6XF2tq2XYctob5b6xzp oQxHNXUCOA4DIPXHeMKjGGw9A689Vx6gvQ4mdIrb39FYV9LorUgF7iy7BEVvm8eye/Df77OJN U/KNXkcfN3qD2GLOdwy3lP8tmonxdogelothOrzcPSzsj29L6VCaMLNJRpjCW8dR7A9BoBeiR 7ZQnWMROwIaa182bUGXDLRsE22a3FkdYPqUCzcw7YpLnJ0WFhzjh4PIJCQh9xinNfw7IQSm9q Rb5I46AgjTZ/7DzoO4sWRqKwvzMtdOg2eSBl7x+xEuFPuzuuQYdat6BTCHIM3dYB5TcS71Xom cGqCC0R1WEn/OTu6eNJ34YCeQs6tANd+jyqsfHt6aFhdOT+p/MWc9faFIkKB/907gGuslYboE IsB/vnR27nvkXMSvF X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 41706 Cc: 41706@debbugs.gnu.org, post+ebugs@guelker.eu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Eli Zaretskii writes: > > +second key. The key values PREDICATE is called with are the > > +either the return values of STARTKEYFUN when that function is > > +specified and returns a non-nil value. > > The last sentence is incomplete and/or needs some fixing, AFAICT. If you mean something else than in you subsequent comment, please elaborate. > > In any other case the keys > > +are cons cells of the form (BEG . END), where BEG is the value of > > +point after calling STARTKEYFUN when given, else after calling > > +ENDRECFUN, and END is the value of point after calling ENDKEYFUN when > > +given, and after calling ENDRECFUN else. > > This seems to contradict the following part, which seems to say that > the key arguments are not always cons cells: > > > +If PREDICATE is nil, comparison is done with `<' if > > the keys are numbers, with `compare-buffer-substrings' if the > > keys are cons cells (the car and cdr of each cons cell are taken > > as start and end positions), and with `string<' otherwise." > > Am I missing something? Not really. AFAIU the only case where this applies is when STARTKEYFUN is specified and returns values of this type - else `sort-build-lists' always generates conses. The different defaults of PREDICATE depending on some types of STARTKEYFUN seem to be predefined just for convenience. > > What I also would like to add to the docstring of this function, and of > > that of `sort', is that the PREDICATE must be transitive and > > antisymmetric - mentioning only in the manual is not enough IMHO. > > Fine with me, provided that you explain what those two attributes > mean. Is it enough to relegate to the manual? > The main problem with collation is that it's locale-specific, and > different C libraries implement collation for the same locale in > slightly different ways. The result is that the sorted text may not > be the same even if you do that on two systems in the same locale. > How would you suggest to solve this issue? I have no clue. Is this a general requirement? For `sort-subr' I think the requirement is not so much absolute reproducibility (sorry if that word doesn't exist) but that it is able to sort lexicographically in a reasonably sensible way. Michael. From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 11 12:36:32 2020 Received: (at 41706) by debbugs.gnu.org; 11 Jun 2020 16:36:32 +0000 Received: from localhost ([127.0.0.1]:37895 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjQBs-0001MR-2z for submit@debbugs.gnu.org; Thu, 11 Jun 2020 12:36:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32944) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjQBp-0001MC-St for 41706@debbugs.gnu.org; Thu, 11 Jun 2020 12:36:30 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:37447) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjQBj-00015F-Pv; Thu, 11 Jun 2020 12:36:23 -0400 Received: from [176.228.60.248] (port=3264 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jjQBj-0002o9-88; Thu, 11 Jun 2020 12:36:23 -0400 Date: Thu, 11 Jun 2020 19:36:09 +0300 Message-Id: <834krh5zly.fsf@gnu.org> From: Eli Zaretskii To: Michael Heerdegen In-Reply-To: <87pna5put0.fsf@web.de> (message from Michael Heerdegen on Thu, 11 Jun 2020 15:59:39 +0200) Subject: Re: bug#41706: 26.1; sort-subr predicate cannot be set successfully References: <20200604110922.GA9116@atlantis> <87pnafxc7e.fsf@web.de> <20200604190526.GA14104@atlantis> <83d06dc3po.fsf@gnu.org> <87h7vpg85k.fsf@web.de> <83a71hbuvo.fsf@gnu.org> <874kriiw6l.fsf@web.de> <83k10e68nu.fsf@gnu.org> <87tuzhpxsd.fsf@web.de> <838sgt67rk.fsf@gnu.org> <87pna5put0.fsf@web.de> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41706 Cc: 41706@debbugs.gnu.org, post+ebugs@guelker.eu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Michael Heerdegen > Cc: post+ebugs@guelker.eu, 41706@debbugs.gnu.org > Date: Thu, 11 Jun 2020 15:59:39 +0200 > > Eli Zaretskii writes: > > > > +second key. The key values PREDICATE is called with are the > > > +either the return values of STARTKEYFUN when that function is > > > +specified and returns a non-nil value. > > > > The last sentence is incomplete and/or needs some fixing, AFAICT. > > If you mean something else than in you subsequent comment, please > elaborate. I meant that a sentence which says "either ..." is expected to say "or ..." at some later point, and also that "are the either the return values" doesn't sound correct English to me. > > > In any other case the keys > > > +are cons cells of the form (BEG . END), where BEG is the value of > > > +point after calling STARTKEYFUN when given, else after calling > > > +ENDRECFUN, and END is the value of point after calling ENDKEYFUN when > > > +given, and after calling ENDRECFUN else. > > > > This seems to contradict the following part, which seems to say that > > the key arguments are not always cons cells: > > > > > +If PREDICATE is nil, comparison is done with `<' if > > > the keys are numbers, with `compare-buffer-substrings' if the > > > keys are cons cells (the car and cdr of each cons cell are taken > > > as start and end positions), and with `string<' otherwise." > > > > Am I missing something? > > Not really. AFAIU the only case where this applies is when STARTKEYFUN > is specified and returns values of this type - else `sort-build-lists' > always generates conses. I think this should be stated in the doc string, not implied. > > > What I also would like to add to the docstring of this function, and of > > > that of `sort', is that the PREDICATE must be transitive and > > > antisymmetric - mentioning only in the manual is not enough IMHO. > > > > Fine with me, provided that you explain what those two attributes > > mean. > > Is it enough to relegate to the manual? Not IMO. > > The main problem with collation is that it's locale-specific, and > > different C libraries implement collation for the same locale in > > slightly different ways. The result is that the sorted text may not > > be the same even if you do that on two systems in the same locale. > > How would you suggest to solve this issue? > > I have no clue. Is this a general requirement? It doesn't have to be a requirement, but if it isn't, then what is the utility of an API that yields different results in different environments? What is/are the use case(s) you have in mind? > For `sort-subr' I think > the requirement is not so much absolute reproducibility (sorry if that > word doesn't exist) but that it is able to sort lexicographically in a > reasonably sensible way. My point is that lexicographical sorting is locale dependent, and some people might be surprised by seeing a sort after A, but before B. However, if this is clearly documented, I guess it's up to the Lisp programs that call such an API to deal with the consequences. Bonus points for allowing the caller to specify the locale, like string-collate-lessp does.