diff options
| author | Juanma Barranquero | 2012-06-08 14:24:27 +0200 |
|---|---|---|
| committer | Juanma Barranquero | 2012-06-08 14:24:27 +0200 |
| commit | 595ef4ad76fb75db4a0adb2baf117ef6d68a2e41 (patch) | |
| tree | 571bb89e42772977374dfa0ef34c9a9fc347e1d7 /lisp/textmodes | |
| parent | d4a8f5c1bd2034a964b3b34ed1eb9cc1c40911e7 (diff) | |
| download | emacs-595ef4ad76fb75db4a0adb2baf117ef6d68a2e41.tar.gz 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/textmodes')
| -rw-r--r-- | lisp/textmodes/texinfmt.el | 24 |
1 files changed, 23 insertions, 1 deletions
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." | |||
| 2958 | ("ky" . texinfo-format-kindex))) | 2958 | ("ky" . texinfo-format-kindex))) |
| 2959 | 2959 | ||
| 2960 | 2960 | ||
| 2961 | ;;; Sort and index | ||
| 2962 | |||
| 2963 | ;; Sort an index which is in the current buffer between START and END. | ||
| 2964 | (defun texinfo-sort-region (start end) | ||
| 2965 | (require 'sort) | ||
| 2966 | (save-restriction | ||
| 2967 | (narrow-to-region start end) | ||
| 2968 | (goto-char (point-min)) | ||
| 2969 | (sort-subr nil 'forward-line 'end-of-line 'texinfo-sort-startkeyfun))) | ||
| 2970 | |||
| 2971 | ;; Subroutine for sorting an index. | ||
| 2972 | ;; At start of a line, return a string to sort the line under. | ||
| 2973 | (defun texinfo-sort-startkeyfun () | ||
| 2974 | (let ((line (buffer-substring-no-properties (point) (line-end-position)))) | ||
| 2975 | ;; Canonicalize whitespace and eliminate funny chars. | ||
| 2976 | (while (string-match "[ \t][ \t]+\\|[^a-z0-9 ]+" line) | ||
| 2977 | (setq line (concat (substring line 0 (match-beginning 0)) | ||
| 2978 | " " | ||
| 2979 | (substring line (match-end 0))))) | ||
| 2980 | line)) | ||
| 2981 | |||
| 2982 | |||
| 2961 | ;;; @printindex | 2983 | ;;; @printindex |
| 2962 | 2984 | ||
| 2963 | (put 'printindex 'texinfo-format 'texinfo-format-printindex) | 2985 | (put 'printindex 'texinfo-format 'texinfo-format-printindex) |
| @@ -2974,7 +2996,7 @@ Default is to leave paragraph indentation as is." | |||
| 2974 | (insert "\n* Menu:\n\n") | 2996 | (insert "\n* Menu:\n\n") |
| 2975 | (setq opoint (point)) | 2997 | (setq opoint (point)) |
| 2976 | (texinfo-print-index nil indexelts) | 2998 | (texinfo-print-index nil indexelts) |
| 2977 | (shell-command-on-region opoint (point) "sort -fd" 1))) | 2999 | (texinfo-sort-region opoint (point)))) |
| 2978 | 3000 | ||
| 2979 | (defun texinfo-print-index (file indexelts) | 3001 | (defun texinfo-print-index (file indexelts) |
| 2980 | (while indexelts | 3002 | (while indexelts |