From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.bugs Subject: bug#11640: 24.1.50; texinfo-format-printindex fails on Windows with Windows's sort Date: Thu, 7 Jun 2012 13:04:48 +0200 Message-ID: References: <20120606165632.760632C803A@msa105.auone-net.jp> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1339067166 17526 80.91.229.3 (7 Jun 2012 11:06:06 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 7 Jun 2012 11:06:06 +0000 (UTC) Cc: 11640@debbugs.gnu.org To: Kazuhiro Ito Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jun 07 13:06:04 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ScaXS-0003Bo-E9 for geb-bug-gnu-emacs@m.gmane.org; Thu, 07 Jun 2012 13:06:02 +0200 Original-Received: from localhost ([::1]:46074 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ScaXS-0003iJ-6k for geb-bug-gnu-emacs@m.gmane.org; Thu, 07 Jun 2012 07:06:02 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:58020) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ScaXL-0003gv-KD for bug-gnu-emacs@gnu.org; Thu, 07 Jun 2012 07:05:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ScaXF-0007Y3-Ac for bug-gnu-emacs@gnu.org; Thu, 07 Jun 2012 07:05:55 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:51836) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ScaXF-0007Xp-4e for bug-gnu-emacs@gnu.org; Thu, 07 Jun 2012 07:05:49 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1ScaZO-0002rZ-3C for bug-gnu-emacs@gnu.org; Thu, 07 Jun 2012 07:08:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juanma Barranquero Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 07 Jun 2012 11:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11640 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11640-submit@debbugs.gnu.org id=B11640.133906727210989 (code B ref 11640); Thu, 07 Jun 2012 11:08:02 +0000 Original-Received: (at 11640) by debbugs.gnu.org; 7 Jun 2012 11:07:52 +0000 Original-Received: from localhost ([127.0.0.1]:33149 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1ScaZD-0002rB-4D for submit@debbugs.gnu.org; Thu, 07 Jun 2012 07:07:51 -0400 Original-Received: from mail-pz0-f44.google.com ([209.85.210.44]:49797) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1ScaZA-0002qz-M6 for 11640@debbugs.gnu.org; Thu, 07 Jun 2012 07:07:49 -0400 Original-Received: by dacx6 with SMTP id x6so684220dac.3 for <11640@debbugs.gnu.org>; Thu, 07 Jun 2012 04:05:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=+BG9CDR83mzu87V2107t+RJ9g1a89De5F5K5aSNlULM=; b=dpmAyK30seV01fN2ZY6hbHLpMeNVAESoMoKBnhflHku+sEgZTCvvmGChAObFMJoDTe 6V+Yul3XZfGciWIrag3JJTzPQeu6eJXFGrr0Jsj9WqqEhRaxtmQKoY7/6HpcICR6+BDv d05Y/pWoAuX/zXiYTp5qJHi25UmTA32Ef6ugT/uyQjyJM8gynl6PXp5+w6PZ9Mc5Uwfq thy1VVtqov2XlCDUKRYZurXSYrVZerAGiTBiHiPFiTsR11jK7XydR9M6B35DPAujTbCj dc2r5u853mTNzh4ZQ0znfw+uh+fDOu06+cNnII8BabBrU81m+BB0IbTwiDeZSR5QmuSx IvYA== Original-Received: by 10.68.189.198 with SMTP id gk6mr7538833pbc.102.1339067128517; Thu, 07 Jun 2012 04:05:28 -0700 (PDT) Original-Received: by 10.142.164.7 with HTTP; Thu, 7 Jun 2012 04:04:48 -0700 (PDT) In-Reply-To: <20120606165632.760632C803A@msa105.auone-net.jp> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:60756 Archived-At: On Wed, Jun 6, 2012 at 6:56 PM, Kazuhiro Ito wrote: > To avoid this problem, Emacs22 does not call sort program on Windows. > But this workaround seems to have been dropped when VMS support > have been removed (*1). > > (*1) http://bzr.savannah.gnu.org/lh/emacs/trunk/revision/89810 Does the following patch work for you? =C2=A0 =C2=A0 Juanma =3D=3D=3D modified file 'lisp/textmodes/texinfmt.el' --- lisp/textmodes/texinfmt.el 2012-04-09 13:05:48 +0000 +++ lisp/textmodes/texinfmt.el 2012-06-07 11:02:59 +0000 @@ -2958,6 +2958,29 @@ ("ky" . texinfo-format-kindex))) =0C +;;; Sort and index (for MS-DOS and Windows) + +;; Sort an index which is in the current buffer between START and END. +;; Used on Microsoft OSes, which have a non-POSIX `sort'. +(defun texinfo-sort-region (start end) + (require 'sort) + (save-restriction + (narrow-to-region start end) + (goto-char (point-min)) + (sort-subr nil 'forward-line 'end-of-line 'texinfo-sort-startkeyfun))) + +;; Subroutine for sorting an index. +;; At start of a line, return a string to sort the line under. +(defun texinfo-sort-startkeyfun () + (let ((line (buffer-substring-no-properties (point) (line-end-position))= )) + ;; Canonicalize whitespace and eliminate funny chars. + (while (string-match "[ \t][ \t]+\\|[^a-z0-9 ]+" line) + (setq line (concat (substring line 0 (match-beginning 0)) + " " + (substring line (match-end 0))))) + line)) + +=0C ;;; @printindex (put 'printindex 'texinfo-format 'texinfo-format-printindex) @@ -2974,7 +2997,9 @@ (insert "\n* Menu:\n\n") (setq opoint (point)) (texinfo-print-index nil indexelts) - (shell-command-on-region opoint (point) "sort -fd" 1))) + (if (memq system-type '(windows-nt ms-dos)) + (texinfo-sort-region opoint (point)) + (shell-command-on-region opoint (point) "sort -fd" 1)))) (defun texinfo-print-index (file indexelts) (while indexelts