Annotation of 43BSD/contrib/emacs/lisp/texinfo.el, revision 1.1.1.1

1.1       root        1: ;; Convert texinfo files to info files.
                      2: ;; Copyright (C) 1985 Richard M. Stallman.
                      3: 
                      4: ;; This file is part of GNU Emacs.
                      5: 
                      6: ;; GNU Emacs is distributed in the hope that it will be useful,
                      7: ;; but WITHOUT ANY WARRANTY.  No author or distributor
                      8: ;; accepts responsibility to anyone for the consequences of using it
                      9: ;; or for whether it serves any particular purpose or works at all,
                     10: ;; unless he says so in writing.  Refer to the GNU Emacs General Public
                     11: ;; License for full details.
                     12: 
                     13: ;; Everyone is granted permission to copy, modify and redistribute
                     14: ;; GNU Emacs, but only under the conditions described in the
                     15: ;; GNU Emacs General Public License.   A copy of this license is
                     16: ;; supposed to have been given to you along with GNU Emacs so you
                     17: ;; can know your rights and responsibilities.  It should be in a
                     18: ;; file named COPYING.  Among other things, the copyright notice
                     19: ;; and this notice must be preserved on all copies.
                     20: 
                     21: 
                     22: (defvar texinfo-mode-syntax-table nil)
                     23: 
                     24: (defvar texinfo-format-syntax-table nil)
                     25: 
                     26: (defvar texinfo-vindex)
                     27: (defvar texinfo-findex)
                     28: (defvar texinfo-cindex)
                     29: (defvar texinfo-pindex)
                     30: (defvar texinfo-tindex)
                     31: (defvar texinfo-kindex)
                     32: 
                     33: (let ((st (syntax-table)))
                     34:   (unwind-protect
                     35:    (progn
                     36:     (setq texinfo-mode-syntax-table (make-syntax-table))
                     37:     (set-syntax-table texinfo-mode-syntax-table)
                     38:     (modify-syntax-entry ?\" " ")
                     39:     (modify-syntax-entry ?\\ " ")
                     40:     (modify-syntax-entry ?@ "\\")
                     41:     (modify-syntax-entry ?\^q "\\")
                     42:     (modify-syntax-entry ?\[ "(]")
                     43:     (modify-syntax-entry ?\] ")[")
                     44:     (modify-syntax-entry ?{ "(}")
                     45:     (modify-syntax-entry ?} "){")
                     46:     (modify-syntax-entry ?\' "w")
                     47:     (setq texinfo-format-syntax-table (copy-sequence texinfo-mode-syntax-table))
                     48:     (set-syntax-table texinfo-format-syntax-table)
                     49:     (modify-syntax-entry ?\' ".")
                     50:     (modify-syntax-entry ?\[ ".")
                     51:     (modify-syntax-entry ?\] ".")
                     52:     (modify-syntax-entry ?\( ".")
                     53:     (modify-syntax-entry ?\) "."))
                     54:    (set-syntax-table st)))
                     55: 
                     56: (defun texinfo-mode ()
                     57:   "Major mode for editing texinfo files.
                     58: These are files that are input for TEX and also to be turned
                     59: into Info files by M-x texinfo-format-buffer.
                     60: These files must be written in a very restricted and
                     61: modified version of TEX input format.
                     62: 
                     63: As for editing commands, like text-mode except for syntax table,
                     64: which is set up so expression commands skip texinfo bracket groups."
                     65:   (interactive)
                     66:   (text-mode)
                     67:   (setq mode-name "Texinfo")
                     68:   (setq major-mode 'texinfo-mode)
                     69:   (set-syntax-table texinfo-mode-syntax-table)
                     70:   (make-local-variable 'require-final-newline)
                     71:   (setq require-final-newline t)
                     72:   (make-local-variable 'paragraph-separate)
                     73:   (setq paragraph-separate (concat "^\b\\|^@[a-z]*[ \n]\\|" paragraph-separate))
                     74:   (make-local-variable 'paragraph-start)
                     75:   (setq paragraph-start (concat "^\b\\|^@[a-z]*[ \n]\\|" paragraph-start))
                     76:   (make-local-variable 'fill-column)
                     77:   (setq fill-column 75)
                     78:   (run-hooks 'text-mode-hook 'texinfo-mode-hook))
                     79: 
                     80: (defun texinfo-format-buffer ()
                     81:   "Process the current buffer as texinfo code, into an Info file.
                     82: The Info file output is generated in a buffer
                     83: visiting the Info file names specified in the @setfilename command."
                     84:   (interactive)
                     85:   (let (texinfo-format-filename
                     86:        texinfo-example-start
                     87:        texinfo-command-start
                     88:        texinfo-command-end
                     89:        texinfo-command-name
                     90:        texinfo-last-node
                     91:        texinfo-vindex
                     92:        texinfo-findex
                     93:        texinfo-cindex
                     94:        texinfo-pindex
                     95:        texinfo-tindex
                     96:        texinfo-kindex
                     97:        texinfo-stack
                     98:        outfile
                     99:        (fill-column fill-column)
                    100:        (input-buffer (current-buffer)))
                    101:     (save-excursion
                    102:       (goto-char (point-min))
                    103:       (search-forward "@setfilename")
                    104:       (setq texinfo-command-end (point))
                    105:       (setq outfile (texinfo-parse-line-arg)))
                    106:     (find-file outfile)
                    107:     (message "Formatting Info file...")
                    108:     (texinfo-mode)
                    109:     (set-syntax-table texinfo-format-syntax-table)
                    110:     (erase-buffer)
                    111:     (insert-buffer-substring input-buffer)
                    112:     (goto-char (point-min))
                    113:     (search-forward "@setfilename")
                    114:     (beginning-of-line)
                    115:     (delete-region (point-min) (point))
                    116:     (while (search-forward "``" nil t)
                    117:       (replace-match "\""))
                    118:     (goto-char (point-min))
                    119:     (while (search-forward "''" nil t)
                    120:       (replace-match "\""))
                    121:     (goto-char (point-min))
                    122:     (while (search-forward "@" nil t)
                    123:       ;; If the @ is preceded by an odd number of ^Q's, do nothing,
                    124:       (if (and (eq (char-after (- (point) 2)) ?\^Q)
                    125:               (save-excursion
                    126:                 (forward-char -1)
                    127:                 (let ((opoint (point)))
                    128:                   (skip-chars-backward "\^Q")
                    129:                   (= (logand 1 (- opoint (point))) 1))))
                    130:          nil
                    131:        (if (looking-at "[@{}'` *]")
                    132:            (if (= (following-char) ?*)
                    133:                (delete-region (1- (point)) (1+ (point)))
                    134:              (delete-char -1)
                    135:              (forward-char 1))
                    136:          (setq texinfo-command-start (1- (point)))
                    137:          (if (= (char-syntax (following-char)) ?w)
                    138:              (forward-word 1)
                    139:            (forward-char 1))
                    140:          (setq texinfo-command-end (point))
                    141:          (setq texinfo-command-name
                    142:                (intern (buffer-substring (1+ texinfo-command-start)
                    143:                                          texinfo-command-end)))
                    144:          (let ((cmd (get texinfo-command-name 'texinfo-format)))
                    145:            (if cmd (funcall cmd)
                    146:              (texinfo-unsupported))))))
                    147:     (cond (texinfo-stack
                    148:           (goto-char (nth 2 (car texinfo-stack)))
                    149:           (error "Unterminated @%s" (car (car texinfo-stack)))))
                    150:     (goto-char (point-min))
                    151:     (while (search-forward "\^q" nil t)
                    152:       (delete-char -1)
                    153:       (forward-char 1))
                    154:     (goto-char (point-min))
                    155:     (message "Formatting Info file...done.  Now save it.")))
                    156: 
                    157: (put 'begin 'texinfo-format 'texinfo-format-begin)
                    158: (defun texinfo-format-begin ()
                    159:   (texinfo-format-begin-end 'texinfo-format))
                    160: 
                    161: (put 'end 'texinfo-format 'texinfo-format-end)
                    162: (defun texinfo-format-end ()
                    163:   (texinfo-format-begin-end 'texinfo-end))
                    164: 
                    165: (defun texinfo-format-begin-end (prop)
                    166:   (setq texinfo-command-name (intern (texinfo-parse-line-arg)))
                    167:   (setq cmd (get texinfo-command-name prop))
                    168:   (if cmd (funcall cmd)
                    169:     (texinfo-unsupported)))
                    170: 
                    171: (defun texinfo-parse-line-arg ()
                    172:   (goto-char texinfo-command-end)
                    173:   (let ((start (point)))
                    174:     (cond ((looking-at " ")
                    175:           (skip-chars-forward " ")
                    176:           (setq start (point))
                    177:           (end-of-line)
                    178:           (setq texinfo-command-end (1+ (point))))
                    179:          ((looking-at "{")
                    180:           (setq start (1+ (point)))
                    181:           (forward-list 1)
                    182:           (setq texinfo-command-end (point))
                    183:           (forward-char -1))
                    184:          (t
                    185:           (error "Invalid texinfo command arg format")))
                    186:     (prog1 (buffer-substring start (point))
                    187:           (if (eolp) (forward-char 1)))))
                    188: 
                    189: (defun texinfo-parse-arg-discard ()
                    190:   (prog1 (texinfo-parse-line-arg)
                    191:         (texinfo-discard-command)))
                    192: 
                    193: (defun texinfo-discard-command ()
                    194:   (delete-region texinfo-command-start texinfo-command-end))
                    195: 
                    196: (defun texinfo-format-parse-line-args ()
                    197:   (let ((start (1- (point)))
                    198:        next beg end
                    199:        args)
                    200:     (skip-chars-forward " ")
                    201:     (while (not (eolp))
                    202:       (setq beg (point))
                    203:       (re-search-forward "[\n,]")
                    204:       (setq next (point))
                    205:       (if (bolp) (setq next (1- next)))
                    206:       (forward-char -1)
                    207:       (skip-chars-backward " ")
                    208:       (setq end (point))
                    209:       (setq args (cons (if (> end beg) (buffer-substring beg end))
                    210:                       args))
                    211:       (goto-char next)
                    212:       (skip-chars-forward " "))
                    213:     (if (eolp) (forward-char 1))
                    214:     (setq texinfo-command-end (point))
                    215:     (nreverse args)))
                    216: 
                    217: (defun texinfo-format-parse-args ()
                    218:   (let ((start (1- (point)))
                    219:        next beg end
                    220:        args)
                    221:     (search-forward "{")
                    222:     (while (/= (preceding-char) ?\})
                    223:       (skip-chars-forward " \t\n")
                    224:       (setq beg (point))
                    225:       (re-search-forward "[},]")
                    226:       (setq next (point))
                    227:       (forward-char -1)
                    228:       (skip-chars-backward " \t\n")
                    229:       (setq end (point))
                    230:       (cond ((< beg end)
                    231:             (goto-char beg)
                    232:             (while (search-forward "\n" end t)
                    233:               (replace-match " "))))
                    234:       (setq args (cons (if (> end beg) (buffer-substring beg end))
                    235:                       args))
                    236:       (goto-char next))
                    237:     (if (eolp) (forward-char 1))
                    238:     (setq texinfo-command-end (point))
                    239:     (nreverse args)))
                    240: 
                    241: (put 'setfilename 'texinfo-format 'texinfo-format-setfilename)
                    242: (defun texinfo-format-setfilename ()
                    243:   (let ((arg (texinfo-parse-arg-discard)))
                    244:     (setq texinfo-format-filename (file-name-nondirectory arg))
                    245:     (insert "Info file "
                    246:            texinfo-format-filename
                    247:            ", produced by texinfo-format-buffer   -*-Text-*-\nfrom "
                    248:            (if (buffer-file-name input-buffer)
                    249:                (concat "file "
                    250:                        (file-name-nondirectory (buffer-file-name input-buffer)))
                    251:              (concat "buffer " (buffer-name input-buffer)))
                    252:            ?\n)))
                    253: 
                    254: (put 'node 'texinfo-format 'texinfo-format-node)
                    255: (defun texinfo-format-node ()
                    256:   (let* ((args (texinfo-format-parse-line-args))
                    257:         (name (nth 0 args))
                    258:         (next (nth 1 args))
                    259:         (prev (nth 2 args))
                    260:         (up (nth 3 args)))
                    261:     (texinfo-discard-command)
                    262:     (setq texinfo-last-node name)
                    263:     (or (bolp)
                    264:        (insert ?\n))
                    265:     (insert "\^_\nFile: " texinfo-format-filename
                    266:            "  Node: " name)
                    267:     (if prev
                    268:        (insert ", Prev: " prev))
                    269:     (if up
                    270:        (insert ", Up: " up))
                    271:     (if next
                    272:        (insert ", Next: " next))
                    273:     (insert ?\n)))
                    274: 
                    275: (put 'menu 'texinfo-format 'texinfo-format-menu)
                    276: (defun texinfo-format-menu ()
                    277:   (texinfo-discard-line)
                    278:   (insert "* Menu:\n\n"))
                    279: 
                    280: (put 'menu 'texinfo-end 'texinfo-discard-command)
                    281: (defun texinfo-discard-line ()
                    282:   (goto-char texinfo-command-end)
                    283:   (or (eolp)
                    284:       (error "Extraneous text at end of command line."))
                    285:   (goto-char texinfo-command-start)
                    286:   (or (bolp)
                    287:       (error "Extraneous text at beginning of command line."))
                    288:   (delete-region (point) (progn (forward-line 1) (point))))
                    289: 
                    290: ; @xref {NODE, FNAME, NAME, FILE, DOCUMENT}
                    291: ; -> *Note FNAME: (FILE)NODE
                    292: ;   If FILE is missing,
                    293: ;    *Note FNAME: NODE
                    294: ;   If FNAME is empty and NAME is present
                    295: ;    *Note NAME: Node
                    296: ;   If both NAME and FNAME are missing
                    297: ;    *Note NODE::
                    298: ;   texinfo ignores the DOCUMENT argument.
                    299: ; -> See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
                    300: ;   If FILE is specified, (FILE)NODE is used for xrefs.
                    301: ;   If fifth argument DOCUMENT is specified, produces
                    302: ;    See section <xref to NODE> [NAME, else NODE], page <xref to NODE>
                    303: ;    of DOCUMENT
                    304: (put 'xref 'texinfo-format 'texinfo-format-xref)
                    305: (defun texinfo-format-xref ()
                    306:   (let ((args (texinfo-format-parse-args)))
                    307:     (texinfo-discard-command)
                    308:     (insert "*Note ")
                    309:     (let ((fname (or (nth 1 args) (nth 2 args))))
                    310:       (if (null (or fname (nth 3 args)))
                    311:          (insert (car args) "::")
                    312:        (insert (or fname (car args)) ": ")
                    313:        (if (nth 3 args)
                    314:            (insert "(" (nth 3 args) ")"))
                    315:        (insert (car args))))))
                    316: 
                    317: (put 'pxref 'texinfo-format 'texinfo-format-pxref)
                    318: (defun texinfo-format-pxref ()
                    319:   (texinfo-format-xref)
                    320:   (or (save-excursion
                    321:        (forward-char -2)
                    322:        (looking-at "::"))
                    323:       (insert ".")))
                    324: 
                    325: ;@inforef{NODE, FNAME, FILE}
                    326: ;Like @xref{NODE, FNAME,,FILE} in texinfo.
                    327: ;In Tex, generates "See Info file FILE, node NODE"
                    328: (put 'inforef 'texinfo-format 'texinfo-format-inforef)
                    329: (defun texinfo-format-inforef ()
                    330:   (let ((args (texinfo-format-parse-args)))
                    331:     (texinfo-discard-command)
                    332:     (insert "*Note " (nth 1 args) ": (" (nth 2 args) ")" (car args))))
                    333: 
                    334: (put 'ichapter 'texinfo-format 'texinfo-format-chapter)
                    335: (put 'chapter 'texinfo-format 'texinfo-format-chapter)
                    336: (put 'iappendix 'texinfo-format 'texinfo-format-chapter)
                    337: (put 'appendix 'texinfo-format 'texinfo-format-chapter)
                    338: (put 'iunnumbered 'texinfo-format 'texinfo-format-chapter)
                    339: (put 'unnumbered 'texinfo-format 'texinfo-format-chapter)
                    340: (defun texinfo-format-chapter ()
                    341:   (texinfo-format-chapter-1 ?*))
                    342: 
                    343: (put 'isection 'texinfo-format 'texinfo-format-section)
                    344: (put 'section 'texinfo-format 'texinfo-format-section)
                    345: (put 'iappendixsection 'texinfo-format 'texinfo-format-section)
                    346: (put 'appendixsection 'texinfo-format 'texinfo-format-section)
                    347: (put 'iappendixsec 'texinfo-format 'texinfo-format-section)
                    348: (put 'appendixsec 'texinfo-format 'texinfo-format-section)
                    349: (put 'iunnumberedsec 'texinfo-format 'texinfo-format-section)
                    350: (put 'unnumberedsec 'texinfo-format 'texinfo-format-section)
                    351: (defun texinfo-format-section ()
                    352:   (texinfo-format-chapter-1 ?=))
                    353: 
                    354: (put 'isubsection 'texinfo-format 'texinfo-format-subsection)
                    355: (put 'subsection 'texinfo-format 'texinfo-format-subsection)
                    356: (put 'iappendixsubsec 'texinfo-format 'texinfo-format-subsection)
                    357: (put 'appendixsubsec 'texinfo-format 'texinfo-format-subsection)
                    358: (put 'iunnumberedsubsec 'texinfo-format 'texinfo-format-subsection)
                    359: (put 'unnumberedsubsec 'texinfo-format 'texinfo-format-subsection)
                    360: (defun texinfo-format-subsection ()
                    361:   (texinfo-format-chapter-1 ?-))
                    362: 
                    363: (put 'isubsubsection 'texinfo-format 'texinfo-format-subsubsection)
                    364: (put 'subsubsection 'texinfo-format 'texinfo-format-subsubsection)
                    365: (put 'iappendixsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
                    366: (put 'appendixsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
                    367: (put 'iunnumberedsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
                    368: (put 'unnumberedsubsubsec 'texinfo-format 'texinfo-format-subsubsection)
                    369: (defun texinfo-format-subsubsection ()
                    370:   (texinfo-format-chapter-1 ?.))
                    371: 
                    372: (defun texinfo-format-chapter-1 (belowchar)
                    373:   (let ((arg (texinfo-parse-arg-discard)))
                    374:     (insert ?\n arg ?\n "@SectionPAD " belowchar ?\n)
                    375:     (forward-line -2)))
                    376: 
                    377: (put 'SectionPAD 'texinfo-format 'texinfo-format-sectionpad)
                    378: (defun texinfo-format-sectionpad ()
                    379:   (let ((str (texinfo-parse-arg-discard)))
                    380:     (forward-char -1)
                    381:     (let ((column (current-column)))
                    382:       (forward-char 1)
                    383:       (while (> column 0)
                    384:        (insert str)
                    385:        (setq column (1- column))))
                    386:     (insert ?\n)))
                    387: 
                    388: (put '\. 'texinfo-format 'texinfo-format-\.)
                    389: (defun texinfo-format-\. ()
                    390:   (texinfo-discard-command)
                    391:   (insert "."))
                    392: 
                    393: (put '\: 'texinfo-format 'texinfo-format-\:)
                    394: (defun texinfo-format-\: ()
                    395:   (texinfo-discard-command))
                    396: 
                    397: ;; @itemize pushes (itemize "COMMANDS" STARTPOS) on texinfo-stack.
                    398: ;; @enumerate pushes (enumerate 0 STARTPOS).
                    399: ;; @item dispatches to the texinfo-item prop of the first elt of the list.
                    400: ;; For itemize, this puts in and rescans the COMMANDS.
                    401: ;; For enumerate, this increments the number and puts it in.
                    402: ;; In either case, it puts a Backspace at the front of the line
                    403: ;; which marks it not to be indented later.
                    404: ;; All other lines get indented by 5 when the @end is reached.
                    405: 
                    406: (defun texinfo-push-stack (check arg)
                    407:   (setq texinfo-stack
                    408:        (cons (list check arg texinfo-command-start)
                    409:              texinfo-stack)))
                    410: 
                    411: (defun texinfo-pop-stack (check)
                    412:   (if (null texinfo-stack)
                    413:       (error "Unmatched @end %s" check))
                    414:   (if (not (eq (car (car texinfo-stack)) check))
                    415:       (error "@end %s matches @%s"
                    416:             check (car (car texinfo-stack))))
                    417:   (prog1 (cdr (car texinfo-stack))
                    418:         (setq texinfo-stack (cdr texinfo-stack))))
                    419: 
                    420: (put 'itemize 'texinfo-format 'texinfo-itemize)
                    421: (defun texinfo-itemize ()
                    422:   (texinfo-push-stack 'itemize (texinfo-parse-arg-discard))
                    423:   (setq fill-column (- fill-column 5)))
                    424: 
                    425: (put 'itemize 'texinfo-end 'texinfo-end-itemize)
                    426: (defun texinfo-end-itemize ()
                    427:   (setq fill-column (+ fill-column 5))
                    428:   (texinfo-discard-command)
                    429:   (let ((stacktop
                    430:         (texinfo-pop-stack 'itemize)))
                    431:     (texinfo-do-itemize (nth 1 stacktop))))
                    432: 
                    433: (put 'enumerate 'texinfo-format 'texinfo-enumerate)
                    434: (defun texinfo-enumerate ()
                    435:   (texinfo-push-stack 'enumerate 0)
                    436:   (setq fill-column (- fill-column 5))
                    437:   (texinfo-discard-line))
                    438: 
                    439: (put 'enumerate 'texinfo-end 'texinfo-end-enumerate)
                    440: (defun texinfo-end-enumerate ()
                    441:   (setq fill-column (+ fill-column 5))
                    442:   (texinfo-discard-command)
                    443:   (let ((stacktop
                    444:         (texinfo-pop-stack 'enumerate)))
                    445:     (texinfo-do-itemize (nth 1 stacktop))))
                    446: 
                    447: (put 'table 'texinfo-format 'texinfo-table)
                    448: (defun texinfo-table ()
                    449:   (texinfo-push-stack 'table (texinfo-parse-arg-discard))
                    450:   (setq fill-column (- fill-column 5)))
                    451: 
                    452: (put 'ftable 'texinfo-format 'texinfo-ftable)
                    453: (defun texinfo-ftable ()
                    454:   (texinfo-push-stack 'table "@code")
                    455:   (setq fill-column (- fill-column 5))
                    456:   (texinfo-discard-line))
                    457: 
                    458: (put 'description 'texinfo-format 'texinfo-description)
                    459: (defun texinfo-description ()
                    460:   (texinfo-push-stack 'table "@asis")
                    461:   (setq fill-column (- fill-column 5))
                    462:   (texinfo-discard-line))
                    463: 
                    464: (put 'table 'texinfo-end 'texinfo-end-table)
                    465: (put 'ftable 'texinfo-end 'texinfo-end-table)
                    466: (put 'description 'texinfo-end 'texinfo-end-table)
                    467: (defun texinfo-end-table ()
                    468:   (setq fill-column (+ fill-column 5))
                    469:   (texinfo-discard-command)
                    470:   (let ((stacktop
                    471:         (texinfo-pop-stack 'table)))
                    472:     (texinfo-do-itemize (nth 1 stacktop))))
                    473: 
                    474: ;; At the @end, indent all the lines within the construct
                    475: ;; except those marked with backspace.  FROM says where
                    476: ;; construct started.
                    477: (defun texinfo-do-itemize (from)
                    478:   (save-excursion
                    479:    (while (progn (forward-line -1)
                    480:                 (>= (point) from))
                    481:      (if (= (following-char) ?\b)
                    482:         (save-excursion
                    483:           (delete-char 1)
                    484:           (end-of-line)
                    485:           (delete-char 6))
                    486:        (save-excursion (insert "     "))))))
                    487: 
                    488: (put 'item 'texinfo-format 'texinfo-item)
                    489: (put 'itemx 'texinfo-format 'texinfo-item)
                    490: (defun texinfo-item ()
                    491:   (funcall (get (car (car texinfo-stack)) 'texinfo-item)))
                    492: 
                    493: (put 'itemize 'texinfo-item 'texinfo-itemize-item)
                    494: (defun texinfo-itemize-item ()
                    495:   (texinfo-discard-line)
                    496:   (insert "\b   " (nth 1 (car texinfo-stack)) " \n")
                    497:   (forward-line -1))
                    498: 
                    499: (put 'enumerate 'texinfo-item 'texinfo-enumerate-item)
                    500: (defun texinfo-enumerate-item ()
                    501:   (texinfo-discard-line)
                    502:   (let ((next (1+ (car (cdr (car texinfo-stack))))))
                    503:     (setcar (cdr (car texinfo-stack)) next)
                    504:     (insert ?\b (format "%3d. " next) ?\n))
                    505:   (forward-line -1))
                    506: 
                    507: (put 'table 'texinfo-item 'texinfo-table-item)
                    508: (defun texinfo-table-item ()
                    509:   (let ((arg (texinfo-parse-arg-discard))
                    510:        (itemfont (car (cdr (car texinfo-stack)))))
                    511:     (insert ?\b itemfont ?\{ arg "}\n     \n"))
                    512:   (forward-line -2))
                    513: 
                    514: (put 'ifinfo 'texinfo-format 'texinfo-discard-command)
                    515: (put 'ifinfo 'texinfo-end 'texinfo-discard-command)
                    516: 
                    517: (put 'iftex 'texinfo-format 'texinfo-format-iftex)
                    518: (defun texinfo-format-iftex ()
                    519:   (delete-region texinfo-command-start
                    520:                 (progn (re-search-forward "@end iftex\n")
                    521:                        (point))))
                    522: 
                    523: (put 'titlepage 'texinfo-format 'texinfo-format-titlepage)
                    524: (defun texinfo-format-titlepage ()
                    525:   (delete-region texinfo-command-start
                    526:                 (progn (search-forward "@end titlepage\n")
                    527:                        (point))))
                    528: 
                    529: (put 'endtitlepage 'texinfo-format 'texinfo-discard-line)
                    530: 
                    531: (put 'ignore 'texinfo-format 'texinfo-format-ignore)
                    532: (defun texinfo-format-ignore ()
                    533:   (delete-region texinfo-command-start
                    534:                 (progn (search-forward "@end ignore\n")
                    535:                        (point))))
                    536: 
                    537: (put 'endignore 'texinfo-format 'texinfo-discard-line)
                    538: 
                    539: (put 'var 'texinfo-format 'texinfo-format-var)
                    540: (put 'heading 'texinfo-format 'texinfo-format-var)
                    541: (defun texinfo-format-var ()
                    542:   (insert (upcase (texinfo-parse-arg-discard)))
                    543:   (goto-char texinfo-command-start))
                    544: 
                    545: (put 'asis 'texinfo-format 'texinfo-format-noop)
                    546: (put 'b 'texinfo-format 'texinfo-format-noop)
                    547: (put 't 'texinfo-format 'texinfo-format-noop)
                    548: (put 'i 'texinfo-format 'texinfo-format-noop)
                    549: (put 'key 'texinfo-format 'texinfo-format-noop)
                    550: (put 'w 'texinfo-format 'texinfo-format-noop)
                    551: (defun texinfo-format-noop ()
                    552:   (insert (texinfo-parse-arg-discard))
                    553:   (goto-char texinfo-command-start))
                    554: 
                    555: (put 'code 'texinfo-format 'texinfo-format-code)
                    556: (put 'samp 'texinfo-format 'texinfo-format-code)
                    557: (put 'file 'texinfo-format 'texinfo-format-code)
                    558: (put 'kbd 'texinfo-format 'texinfo-format-code)
                    559: (defun texinfo-format-code ()
                    560:   (insert "`" (texinfo-parse-arg-discard) "'")
                    561:   (goto-char texinfo-command-start))
                    562: 
                    563: (put 'defn 'texinfo-format 'texinfo-format-defn)
                    564: (put 'dfn 'texinfo-format 'texinfo-format-defn)
                    565: (defun texinfo-format-defn ()
                    566:   (insert "\"" (texinfo-parse-arg-discard) "\"")
                    567:   (goto-char texinfo-command-start))
                    568: 
                    569: (put 'bullet 'texinfo-format 'texinfo-format-bullet)
                    570: (defun texinfo-format-bullet ()
                    571:   (texinfo-discard-command)
                    572:   (insert "*"))
                    573: 
                    574: (put 'smallexample 'texinfo-format 'texinfo-format-example)
                    575: (put 'example 'texinfo-format 'texinfo-format-example)
                    576: (put 'quotation 'texinfo-format 'texinfo-format-example)
                    577: (put 'lisp 'texinfo-format 'texinfo-format-example)
                    578: (put 'display 'texinfo-format 'texinfo-format-example)
                    579: (put 'format 'texinfo-format 'texinfo-format-example)
                    580: (put 'flushleft 'texinfo-format 'texinfo-format-example)
                    581: (defun texinfo-format-example ()
                    582:   (texinfo-push-stack 'example nil)
                    583:   (setq fill-column (- fill-column 5))
                    584:   (texinfo-discard-line))
                    585: 
                    586: (put 'smallexample 'texinfo-end 'texinfo-end-example)
                    587: (put 'example 'texinfo-end 'texinfo-end-example)
                    588: (put 'quotation 'texinfo-end 'texinfo-end-example)
                    589: (put 'lisp 'texinfo-end 'texinfo-end-example)
                    590: (put 'display 'texinfo-end 'texinfo-end-example)
                    591: (put 'format 'texinfo-end 'texinfo-end-example)
                    592: (put 'flushleft 'texinfo-end 'texinfo-end-example)
                    593: (defun texinfo-end-example ()
                    594:   (setq fill-column (+ fill-column 5))
                    595:   (texinfo-discard-command)
                    596:   (let ((stacktop
                    597:         (texinfo-pop-stack 'example)))
                    598:     (texinfo-do-itemize (nth 1 stacktop))))
                    599: 
                    600: 
                    601: (put 'exdent 'texinfo-format 'texinfo-format-exdent)
                    602: (defun texinfo-format-exdent ()
                    603:   (texinfo-discard-command)
                    604:   (delete-region (point)
                    605:                 (progn
                    606:                  (skip-chars-forward " ")
                    607:                  (point)))
                    608:   (insert ?\b)
                    609:   ;; Cancel out the deletion that texinfo-do-itemize
                    610:   ;; is going to do at the end of this line.
                    611:   (save-excursion
                    612:     (end-of-line)
                    613:     (insert "\n     ")))
                    614: 
                    615: (put 'ctrl 'texinfo-format 'texinfo-format-ctrl)
                    616: (defun texinfo-format-ctrl ()
                    617:   (let ((str (texinfo-parse-arg-discard)))
                    618:     (insert (logand 31 (aref str 0)))))
                    619: 
                    620: (put 'TeX 'texinfo-format 'texinfo-format-TeX)
                    621: (defun texinfo-format-TeX ()
                    622:   (texinfo-parse-arg-discard)
                    623:   (insert "TeX"))
                    624: 
                    625: (put 'copyright 'texinfo-format 'texinfo-format-copyright)
                    626: (defun texinfo-format-copyright ()
                    627:   (texinfo-parse-arg-discard)
                    628:   (insert "(C)"))
                    629: 
                    630: (put 'dots 'texinfo-format 'texinfo-format-dots)
                    631: (defun texinfo-format-dots ()
                    632:   (texinfo-parse-arg-discard)
                    633:   (insert "..."))
                    634: 
                    635: (put 'refill 'texinfo-format 'texinfo-format-refill)
                    636: (defun texinfo-format-refill ()
                    637:   (texinfo-discard-command)
                    638:   (fill-paragraph nil))
                    639: 
                    640: ;; Index generation
                    641: 
                    642: (put 'vindex 'texinfo-format 'texinfo-format-vindex)
                    643: (defun texinfo-format-vindex ()
                    644:   (texinfo-index 'texinfo-vindex))
                    645: 
                    646: (put 'cindex 'texinfo-format 'texinfo-format-cindex)
                    647: (defun texinfo-format-cindex ()
                    648:   (texinfo-index 'texinfo-cindex))
                    649: 
                    650: (put 'findex 'texinfo-format 'texinfo-format-findex)
                    651: (defun texinfo-format-findex ()
                    652:   (texinfo-index 'texinfo-findex))
                    653: 
                    654: (put 'pindex 'texinfo-format 'texinfo-format-pindex)
                    655: (defun texinfo-format-pindex ()
                    656:   (texinfo-index 'texinfo-pindex))
                    657: 
                    658: (put 'tindex 'texinfo-format 'texinfo-format-tindex)
                    659: (defun texinfo-format-tindex ()
                    660:   (texinfo-index 'texinfo-tindex))
                    661: 
                    662: (put 'kindex 'texinfo-format 'texinfo-format-kindex)
                    663: (defun texinfo-format-kindex ()
                    664:   (texinfo-index 'texinfo-kindex))
                    665: 
                    666: (defun texinfo-index (indexvar)
                    667:   (set indexvar
                    668:        (cons (list (texinfo-parse-arg-discard) texinfo-last-node)
                    669:             (symbol-value indexvar))))
                    670: 
                    671: (defconst texinfo-indexvar-alist
                    672:   '(("cp" . texinfo-cindex)
                    673:     ("fn" . texinfo-findex)
                    674:     ("vr" . texinfo-vindex)
                    675:     ("tp" . texinfo-tindex)
                    676:     ("pg" . texinfo-pindex)
                    677:     ("ky" . texinfo-kindex)))
                    678: 
                    679: (put 'printindex 'texinfo-format 'texinfo-format-printindex)
                    680: (defun texinfo-format-printindex ()
                    681:   (let ((indexelts (symbol-value
                    682:                    (cdr (assoc (texinfo-parse-arg-discard)
                    683:                                texinfo-indexvar-alist))))
                    684:        opoint)
                    685:     (insert "\n* Menu:\n\n")
                    686:     (setq opoint (point))
                    687:     (while indexelts
                    688:       (insert "* " (car (car indexelts)) ": " (nth 1 (car indexelts)) ".\n")
                    689:       (setq indexelts (cdr indexelts)))
                    690:     (shell-command-on-region opoint (point) "sort -f" 1)))
                    691: 
                    692: ;; Lots of bolio constructs do nothing in texinfo.
                    693: 
                    694: (put 'page 'texinfo-format 'texinfo-discard-line-with-args)
                    695: (put 'c 'texinfo-format 'texinfo-discard-line-with-args)
                    696: (put 'comment 'texinfo-format 'texinfo-discard-line-with-args)
                    697: (put 'setchapternewpage 'texinfo-format 'texinfo-discard-line-with-args)
                    698: (put 'contents 'texinfo-format 'texinfo-discard-line-with-args)
                    699: (put 'summarycontents 'texinfo-format 'texinfo-discard-line-with-args)
                    700: (put 'nopara 'texinfo-format 'texinfo-discard-line-with-args)
                    701: (put 'noindent 'texinfo-format 'texinfo-discard-line-with-args)
                    702: (put 'setx 'texinfo-format 'texinfo-discard-line-with-args)
                    703: (put 'setq 'texinfo-format 'texinfo-discard-line-with-args)
                    704: (put 'settitle 'texinfo-format 'texinfo-discard-line-with-args)
                    705: (put 'defindex 'texinfo-format 'texinfo-discard-line-with-args)
                    706: (put 'synindex 'texinfo-format 'texinfo-discard-line-with-args)
                    707: (put 'hsize 'texinfo-format 'texinfo-discard-line-with-args)
                    708: (put 'parindent 'texinfo-format 'texinfo-discard-line-with-args)
                    709: (put 'lispnarrowing 'texinfo-format 'texinfo-discard-line-with-args)
                    710: (put 'itemindent 'texinfo-format 'texinfo-discard-line-with-args)
                    711: (put 'headings 'texinfo-format 'texinfo-discard-line-with-args)
                    712: (put 'group 'texinfo-format 'texinfo-discard-line-with-args)
                    713: (put 'group 'texinfo-end 'texinfo-discard-line-with-args)
                    714: (put 'bye 'texinfo-format 'texinfo-discard-line)
                    715: 
                    716: (defun texinfo-discard-line-with-args ()
                    717:   (goto-char texinfo-command-start)
                    718:   (delete-region (point) (progn (forward-line 1) (point))))
                    719: 
                    720: ;; Some cannot be handled
                    721: 
                    722: (defun texinfo-unsupported ()
                    723:   (error "%s is not handled by texinfo"
                    724:         (buffer-substring texinfo-command-start texinfo-command-end)))

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.