unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juanma Barranquero <lekktu@gmail.com>
To: Kazuhiro Ito <kzhr@d1.dion.ne.jp>
Cc: 11640@debbugs.gnu.org
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	[thread overview]
Message-ID: <CAAeL0SRx-HMxF7-RsEApiyhvUpVmkWhLKBpjNVLdKG9GBjVNFw@mail.gmail.com> (raw)
In-Reply-To: <20120606165632.760632C803A@msa105.auone-net.jp>

On Wed, Jun 6, 2012 at 6:56 PM, Kazuhiro Ito <kzhr@d1.dion.ne.jp> 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?

    Juanma


=== 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)))

 \f
+;;; 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))
+
+\f
 ;;; @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





  reply	other threads:[~2012-06-07 11:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-06 16:56 bug#11640: 24.1.50; texinfo-format-printindex fails on Windows with Windows's sort Kazuhiro Ito
2012-06-07 11:04 ` Juanma Barranquero [this message]
2012-06-07 11:43   ` Andreas Schwab
2012-06-07 11:49     ` Juanma Barranquero
2012-06-07 16:23       ` Eli Zaretskii
2012-06-07 18:47         ` Juanma Barranquero
2012-06-08  5:45         ` Stefan Monnier
2012-06-08 12:25           ` Juanma Barranquero
2012-06-07 16:24   ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=CAAeL0SRx-HMxF7-RsEApiyhvUpVmkWhLKBpjNVLdKG9GBjVNFw@mail.gmail.com \
    --to=lekktu@gmail.com \
    --cc=11640@debbugs.gnu.org \
    --cc=kzhr@d1.dion.ne.jp \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).