;;; texinfmt.el --- format Texinfo files into Info files
-;; Copyright (C) 1985-1986, 1988, 1990-1998, 2000-2011
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1985-1986, 1988, 1990-1998, 2000-2015 Free Software
+;; Foundation, Inc.
;; Maintainer: Robert J. Chassell <bug-texinfo@gnu.org>
;; Keywords: maint, tex, docs
(@unnumberedsubsubsec . @unnumberedsubsec)
(@subsubheading . @subheading)
(@appendixsubsubsec . @appendixsubsec))
- "*An alist of next higher levels for chapters, sections, etc...
+ "An alist of next higher levels for chapters, sections, etc...
For example, section to chapter, subsection to section.
Used by `texinfo-raise-lower-sections'.
The keys specify types of section; the values correspond to the next
(@unnumberedsubsubsec . @unnumberedsubsubsec)
(@subsubheading . @subsubheading)
(@appendixsubsubsec . @appendixsubsubsec))
- "*An alist of next lower levels for chapters, sections, etc...
+ "An alist of next lower levels for chapters, sections, etc...
For example, chapter to section, section to subsection.
Used by `texinfo-raise-lower-sections'.
The keys specify types of section; the values correspond to the next
"done. Now save it." "done.")))))
(defvar texinfo-region-buffer-name "*Info Region*"
- "*Name of the temporary buffer used by \\[texinfo-format-region].")
+ "Name of the temporary buffer used by \\[texinfo-format-region].")
(defvar texinfo-pre-format-hook nil
"Hook called before the conversion of the Texinfo file to Info format.
\f
;;; Handle paragraph filling
-;; Keep as concatinated lists for ease of maintenance
+;; Keep as concatenated lists for ease of maintenance
(defvar texinfo-no-refill-regexp
(concat
"var{\\|"
"w{\\|"
"xref{\\|"
- "@-\\|" ; @- is a descretionary hyphen (not an accent) (a noop).
+ "@-\\|" ; @- is a discretionary hyphen (not an accent) (a noop).
texinfo-accent-commands
"\\)"
)
;; Texinfo commands.
(defvar texinfo-extra-inter-column-width 0
- "*Number of extra spaces between entries (columns) in @multitable.")
+ "Number of extra spaces between entries (columns) in @multitable.")
(defvar texinfo-multitable-buffer-name "*multitable-temporary-buffer*")
(defvar texinfo-multitable-rectangle-name "texinfo-multitable-temp-")
(table-entry-height 0)
;; unformatted row looks like: A1 @tab A2 @tab A3
;; extract-row command deletes the source line in the table.
- (unformated-row (texinfo-multitable-extract-row)))
+ (unformatted-row (texinfo-multitable-extract-row)))
;; Use a temporary buffer
(set-buffer (get-buffer-create texinfo-multitable-buffer-name))
(delete-region (point-min) (point-max))
- (insert unformated-row)
+ (insert unformatted-row)
(goto-char (point-min))
;; 1. Check for correct number of @tab in line.
(let ((tab-number 1)) ; one @tab between two columns
(put 'image 'texinfo-format 'texinfo-format-image)
(defun texinfo-format-image ()
- "Insert an image from an an file ending in .txt.
+ "Insert an image from a file ending in .txt.
Use only the FILENAME arg; for Info, ignore the other arguments to @image."
(let ((args (texinfo-format-parse-args))
filename)
("pg" . texinfo-format-pindex)
("ky" . texinfo-format-kindex)))
+\f
+;;; 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))
+
\f
;;; @printindex
(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
;;; @set, @clear, @ifset, @ifclear
;; If a flag is set with @set FLAG, then text between @ifset and @end
-;; ifset is formatted normally, but if the flag is is cleared with
+;; ifset is formatted normally, but if the flag is cleared with
;; @clear FLAG, then the text is not formatted; it is ignored.
;; If a flag is cleared with @clear FLAG, then text between @ifclear
-;; and @end ifclear is formatted normally, but if the flag is is set with
+;; and @end ifclear is formatted normally, but if the flag is set with
;; @set FLAG, then the text is not formatted; it is ignored. @ifclear
;; is the opposite of @ifset.
Must be used only with -batch, and kills Emacs on completion.
Each file will be processed even if an error occurred previously.
For example, invoke
- \"emacs -batch -funcall batch-texinfo-format $docs/ ~/*.texinfo\"."
+ \"emacs -batch -l texinfmt -f batch-texinfo-format $docs/ ~/*.texinfo\"."
(if (not noninteractive)
(error "batch-texinfo-format may only be used -batch"))
(let ((version-control t)