;;; Emacs lisp functions to convert Texinfo files to Info files.
+(or (fboundp 'defgroup)
+ (defmacro defgroup (&rest ignore) nil))
+
+(or (fboundp 'defcustom)
+ (defmacro defcustom (var value doc &rest ignore)
+ `(defvar ,var ,value ,doc)))
+
(defvar texinfmt-version "2.37 of 24 May 1997")
(defun texinfmt-version (&optional here)
(error "Texinfo file needs an `@setfilename FILENAME' line."))
(setq texinfo-command-end (point))
(setq outfile (texinfo-parse-line-arg)))
+
(find-file outfile)
(texinfo-mode)
+ (erase-buffer)
+
+ (message "Formatting Info file: %s" outfile)
+ (setq texinfo-format-filename
+ (file-name-nondirectory (expand-file-name outfile)))
+
(setq fill-column fill-column-for-info)
(set-syntax-table texinfo-format-syntax-table)
- (erase-buffer)
+
(insert-buffer-substring input-buffer)
(message "Converting %s to Info format..." (buffer-name input-buffer))
(insert "\n"))
;; Scan the whole buffer, converting to Info format.
(texinfo-format-scan)
- ;; Return data for indices.
(goto-char (point-min))
+ ;; Insert info about how this file was made.
+ (insert "Info file: "
+ texinfo-format-filename ", -*-Text-*-\n"
+ "produced by `texinfo-format-buffer'\n"
+ ;; Date string removed so that regression testing is easier.
+ ;; "on "
+ ;; (insert (format-time-string "%e %b %Y")) " "
+ "from file"
+ (if (buffer-file-name input-buffer)
+ (concat " `"
+ (file-name-sans-versions
+ (file-name-nondirectory
+ (buffer-file-name input-buffer)))
+ "'")
+ (concat "buffer `" (buffer-name input-buffer) "'"))
+ "\nusing `texinfmt.el' version "
+ texinfmt-version
+ ".\n\n")
+ ;; Return data for indices.
(list outfile
texinfo-vindex texinfo-findex texinfo-cindex
texinfo-pindex texinfo-tindex texinfo-kindex)))
(concat
"^@"
"\\("
+ "direntry\\|"
"example\\|"
"smallexample\\|"
"lisp\\|"
;; specially.
(put 'setfilename 'texinfo-format 'texinfo-format-setfilename)
(defun texinfo-format-setfilename ()
- (let ((arg (texinfo-parse-arg-discard)))
- (message "Formatting Info file: %s" arg)
- (setq texinfo-format-filename
- (file-name-nondirectory (expand-file-name arg)))
- (insert "Info file: "
- texinfo-format-filename ", -*-Text-*-\n"
- "produced by `texinfo-format-buffer'\n"
- ;; Date string removed so that regression testing is easier.
- ;; "on "
- ;; (insert (format-time-string "%e %b %Y")) " "
- "from file"
- (if (buffer-file-name input-buffer)
- (concat " `"
- (file-name-sans-versions
- (file-name-nondirectory
- (buffer-file-name input-buffer)))
- "'")
- (concat "buffer `" (buffer-name input-buffer) "'"))
- "\nusing `texinfmt.el' version "
- texinfmt-version
- ".\n\n")))
+ (texinfo-parse-arg-discard))
\f
;;; @node, @menu, @detailmenu
;;
;; Using the Emacs Lisp formatter, texinfmt.el,
;; the whitespace between columns can be increased by setting
-;; `extra-inter-column-width' to a value greater than 0. By default,
+;; `texinfo-extra-inter-column-width' to a value greater than 0. By default,
;; there is at least one blank space between columns.
;;
;; The Emacs Lisp formatter, texinfmt.el, ignores the following four
;; Note that @tab, the cell separators, are not treated as independent
;; Texinfo commands.
-(defvar extra-inter-column-width 0
-"*Insert NUMBER of additional columns of whitespace between entries of
-a multi-column table.")
+(defvar texinfo-extra-inter-column-width 0
+ "*Number of extra spaces between entries (columns) in @multitable.")
-(defvar multitable-temp-buffer-name "*multitable-temporary-buffer*")
-(defvar multitable-temp-rectangle-name "texinfo-multitable-temp-")
+(defvar texinfo-multitable-buffer-name "*multitable-temporary-buffer*")
+(defvar texinfo-multitable-rectangle-name "texinfo-multitable-temp-")
;; These commands are defined in texinfo.tex for printed output.
(put 'multitableparskip 'texinfo-format 'texinfo-discard-line-with-args)
(put 'multitablelinespace 'texinfo-format 'texinfo-discard-line-with-args)
(put 'multitable 'texinfo-format 'texinfo-multitable)
+
(defun texinfo-multitable ()
"Produce multi-column tables.
Using the Emacs Lisp formatter, texinfmt.el,
the whitespace between columns can be increased by setting
-`extra-inter-column-width' to a value greater than 0. By default,
+`texinfo-extra-inter-column-width' to a value greater than 0. By default,
there is at least one blank space between columns.
The Emacs Lisp formatter, texinfmt.el, ignores the following four
;; between column spaces
(length texinfo-multitable-width-list)
;; additional between column spaces, if any
- extra-inter-column-width
+ texinfo-extra-inter-column-width
;; sum of spaces for each entry
(apply '+ texinfo-multitable-width-list))))
(if (> desired-columns fill-column)
;; extract-row command deletes the source line in the table.
(unformated-row (texinfo-multitable-extract-row)))
;; Use a temporary buffer
- (set-buffer (get-buffer-create multitable-temp-buffer-name))
+ (set-buffer (get-buffer-create texinfo-multitable-buffer-name))
(delete-region (point-min) (point-max))
(insert unformated-row)
(goto-char (point-min))
(point)))
;; Set fill-column *wider* than needed to produce inter-column space
(setq fill-column (+ 1
- extra-inter-column-width
+ texinfo-extra-inter-column-width
(nth table-column table-widths)))
(narrow-to-region start end)
;; Remove whitespace before and after entry.
(if (> needed-whitespace 0) needed-whitespace 1)
? )))
;; now, put formatted cell into a rectangle
- (set (intern (concat multitable-temp-rectangle-name
+ (set (intern (concat texinfo-multitable-rectangle-name
(int-to-string table-column)))
(extract-rectangle (point-min) (point)))
(delete-region (point-min) (point))
(setq here (point))
(insert-rectangle
(eval (intern
- (concat multitable-temp-rectangle-name
+ (concat texinfo-multitable-rectangle-name
(int-to-string column-number)))))
(goto-char here)
(end-of-line)
(setq column-number (1+ column-number))))
- (kill-buffer multitable-temp-buffer-name)
+ (kill-buffer texinfo-multitable-buffer-name)
(setq fill-column existing-fill-column)))
\f
(put 'email 'texinfo-format 'texinfo-format-key)
(put 'key 'texinfo-format 'texinfo-format-key)
+;; I've decided not want to have angle brackets around these -- rms.
(defun texinfo-format-key ()
- (insert "<" (texinfo-parse-arg-discard) ">")
+ (insert (texinfo-parse-arg-discard))
(goto-char texinfo-command-start))
(put 'bullet 'texinfo-format 'texinfo-format-bullet)
(insert "\n ")))
\f
+;; @direntry and @dircategory
+
+(put 'direntry 'texinfo-format 'texinfo-format-direntry)
+(defun texinfo-format-direntry ()
+ (texinfo-push-stack 'direntry nil)
+ (texinfo-discard-line)
+ (insert "START-INFO-DIR-ENTRY\n\n"))
+
+(put 'direntry 'texinfo-end 'texinfo-end-direntry)
+(defun texinfo-end-direntry ()
+ (texinfo-discard-command)
+ (insert "END-INFO-DIR-ENTRY\n\n")
+ (texinfo-pop-stack 'direntry))
+
+(put 'dircategory 'texinfo-format 'texinfo-format-dircategory)
+(defun texinfo-format-dircategory ()
+ (let ((str (texinfo-parse-arg-discard)))
+ (delete-region (point)
+ (progn
+ (skip-chars-forward " ")
+ (point)))
+ (insert "INFO-DIR-SECTION " str "\n")))
+\f
;;; @cartouche
;; The @cartouche command is a noop in Info; in a printed manual,
;; In this case flag is neither set nor cleared.
;; Act as if clear, i.e. do nothing.
()))))
-
\f
;;; @ifeq
(put 'ifeq 'texinfo-format 'texinfo-format-ifeq)
(defun texinfo-format-ifeq ()
- "If ARG1 and ARG2 caselessly string compare to same string, performs COMMAND.
+ "If ARG1 and ARG2 caselessly string compare to same string, perform COMMAND.
Otherwise produces no output.
Thus:
(put 'shorttitlepage 'texinfo-format 'texinfo-discard-line-with-args)
(put 'summarycontents 'texinfo-format 'texinfo-discard-line-with-args)
(put 'input 'texinfo-format 'texinfo-discard-line-with-args)
-(put 'dircategory 'texinfo-format 'texinfo-discard-line-with-args)
\f
;;; Some commands cannot be handled