GNU bug report logs -
#11640
24.1.50; texinfo-format-printindex fails on Windows with Windows's sort
Previous Next
Reported by: Kazuhiro Ito <kzhr <at> d1.dion.ne.jp>
Date: Wed, 6 Jun 2012 17:00:03 UTC
Severity: normal
Found in version 24.1.50
Done: Juanma Barranquero <lekktu <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #23 received at 11640 <at> debbugs.gnu.org (full text, mbox):
On Thu, Jun 7, 2012 at 6:23 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> Seriously, I find it hard to believe that performance matters in this
> case, especially since texinfmt.el is no longer the main recommended
> way of producing Info from Texinfo, which is why it doesn't get
> updated with the latest features of the Texinfo language.
I'm perfectly willing to believe you. As I said, I don't know why was
it done otherwise.
> Stefan, Chong, any objections to sorting the indices in Lisp in this
> case?
The patch is even simpler.
2012-06-07 Juanma Barranquero <lekktu <at> gmail.com>
* textmodes/texinfmt.el: Use internal sort (partial revert of revno:89810).
(texinfo-sort-region, texinfo-sort-startkeyfun): Restore functions.
(texinfo-format-printindex): Use `texinfo-sort-region' instead of
calling external sort utility.
=== modified file 'lisp/textmodes/texinfmt.el'
--- lisp/textmodes/texinfmt.el 2012-04-09 13:05:48 +0000
+++ lisp/textmodes/texinfmt.el 2012-06-07 18:38:56 +0000
@@ -2958,6 +2958,28 @@
("ky" . texinfo-format-kindex)))
+;;; Sort and index
+
+;; Sort an index which is in the current buffer between START and END.
+(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))
+
+
;;; @printindex
(put 'printindex 'texinfo-format 'texinfo-format-printindex)
@@ -2974,7 +2996,7 @@
(insert "\n* Menu:\n\n")
(setq opoint (point))
(texinfo-print-index nil indexelts)
- (shell-command-on-region opoint (point) "sort -fd" 1)))
+ (texinfo-sort-region opoint (point))))
(defun texinfo-print-index (file indexelts)
(while indexelts
This bug report was last modified 12 years and 344 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.