From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tim Landscheidt Newsgroups: gmane.emacs.help Subject: Re: Sorting on compound keys? Date: Thu, 26 May 2011 22:49:04 +0000 Organization: Message-ID: References: <4DDC9A94.3080903@easy-emacs.de> <4DDDF2FA.2050201@easy-emacs.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1306450176 22498 80.91.229.12 (26 May 2011 22:49:36 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 26 May 2011 22:49:36 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri May 27 00:49:29 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QPjMu-0001fH-8Z for geh-help-gnu-emacs@m.gmane.org; Fri, 27 May 2011 00:49:28 +0200 Original-Received: from localhost ([::1]:32909 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPjMt-0003JP-Ue for geh-help-gnu-emacs@m.gmane.org; Thu, 26 May 2011 18:49:27 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:55288) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPjMn-0003AN-F5 for help-gnu-emacs@gnu.org; Thu, 26 May 2011 18:49:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QPjMl-0004Xk-QK for help-gnu-emacs@gnu.org; Thu, 26 May 2011 18:49:21 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:59406) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPjMl-0004Wi-F2 for help-gnu-emacs@gnu.org; Thu, 26 May 2011 18:49:19 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QPjMj-0001a9-BV for help-gnu-emacs@gnu.org; Fri, 27 May 2011 00:49:17 +0200 Original-Received: from g231144211.adsl.alicedsl.de ([92.231.144.211]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 27 May 2011 00:49:17 +0200 Original-Received: from tim by g231144211.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 27 May 2011 00:49:17 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-Lines: 48 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: g231144211.adsl.alicedsl.de Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:2zuxJPy2SQhyCQf/tdfgz4LjIAU= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:81255 Archived-At: Andreas Röhler wrote: >>>> sometimes I want to sort unified diffs of CSV files (sepa- >>>> rated by tabs (here: \t)): >>>> | +A 1\t1\tx >>>> | +A 1\t2\ty >>>> | +B 2\t3\tz >>>> | -A 1\t1\tx >>>> | -B 2\t2\ty >>>> | -B 2\t3\tz >>>> by the second column, then the first column, then "+" vs. >>>> "-". Unfortunately, it seems that sort-regexp-fields doesn't >>>> allow more than one match field as a key. sort-fields >>>> doesn't work either as it requires the fields to be sur- >>>> rounded by white space (no "+" vs. "-") and doesn't allow >>>> white space inside the fields. >>>> Is there any function in vanilla Emacs (23.1.1) that I >>>> missed? I looked at pimping sort-regexp-fields, but it seems >>>> to me that sort-subr would have to be rewritten from scratch >>>> to achieve sorting on compound keys. >>> last time I looked into that feature was missing indeed. >>> However, didn't look for a need of re-write from the >>> scratch, just to extend to existing routine - ie. introduce >>> one or more levels of sorting. >> I remember our discussion in de.comp.editoren :-), but as I >> read sort-subr it is hard-coded that the sort key is one >> literal, continuous part of the buffer as sort-lists is a >> list of buffer positions. > sort-subr takes functions to determine the fields to sort. No, it accepts functions to determine the *boundaries* of the fields that have to be part of the buffer as I have written above. > As for the functions as arguments, maybe have a look at > `ar-th-sort' in thingatpt-utils-base.el > https://code.launchpad.net/s-x-emacs-werkstatt/ How is this useful in this case? Tim