summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorJuanma Barranquero <lekktu@gmail.com>2012-06-08 14:24:27 +0200
committerJuanma Barranquero <lekktu@gmail.com>2012-06-08 14:24:27 +0200
commit595ef4ad76fb75db4a0adb2baf117ef6d68a2e41 (patch)
tree571bb89e42772977374dfa0ef34c9a9fc347e1d7 /lisp
parentd4a8f5c1bd2034a964b3b34ed1eb9cc1c40911e7 (diff)
downloademacs-595ef4ad76fb75db4a0adb2baf117ef6d68a2e41.tar.gz
emacs-595ef4ad76fb75db4a0adb2baf117ef6d68a2e41.tar.bz2
emacs-595ef4ad76fb75db4a0adb2baf117ef6d68a2e41.zip
lisp/textmodes/texinfmt.el: Fix bug#11640 (reverts part of 2008-07-31T05:33:56Z!dann@ics.uci.edu).
(texinfo-format-printindex): Use `texinfo-sort-region' in all platforms, instead of calling external sort utility. (texinfo-sort-region, texinfo-sort-startkeyfun): Restore functions.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/textmodes/texinfmt.el24
2 files changed, 30 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2698374ed8a..655dcf184db 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
+2012-06-08 Juanma Barranquero <lekktu@gmail.com>
+
+ * textmodes/texinfmt.el: Fix bug#11640 (reverts part of 2008-07-31T05:33:56Z!dann@ics.uci.edu).
+ (texinfo-format-printindex): Use `texinfo-sort-region' in all platforms,
+ instead of calling external sort utility.
+ (texinfo-sort-region, texinfo-sort-startkeyfun): Restore functions.
+
2012-06-08 Eli Zaretskii <eliz@gnu.org>
* descr-text.el (describe-char): Mention how to insert the
diff --git a/lisp/textmodes/texinfmt.el b/lisp/textmodes/texinfmt.el
index d318a97d377..cb87c1198f9 100644
--- a/lisp/textmodes/texinfmt.el
+++ b/lisp/textmodes/texinfmt.el
@@ -2958,6 +2958,28 @@ Default is to leave paragraph indentation as is."
("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 @@ Default is to leave paragraph indentation as is."
(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