ptexinfmt.el (texinfo-format-syntax-table): Modify character syntax of " and \ to...
[elisp/wanderlust.git] / utils / ptexinfmt.el
1 ;;; ptexinfmt.el --- portable Texinfo formatter  -*- lexical-binding: t -*-
2
3 ;; Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993,
4 ;;               1994, 1995, 1996, 1997 Free Software Foundation, Inc.
5 ;; Copyright (C) 1999 Yoshiki Hayashi <yoshiki@xemacs.org>
6 ;; Copyright (C) 2000 TAKAHASHI Kaoru <kaoru@kaisei.org>
7
8 ;; Author: TAKAHASHI Kaoru <kaoru@kaisei.org>
9 ;;      Yoshiki Hayashi <yoshiki@xemacs.org>
10 ;;      Katsumi Yamaoka <yamaoka@jpl.org>
11 ;; Maintainer: TAKAHASHI Kaoru <kaoru@kaisei.org>
12 ;; Created: 7 Jul 2000
13 ;; Keywords: maint, tex, docs, emulation, compatibility
14
15 ;; This program is free software; you can redistribute it and/or
16 ;; modify it under the terms of the GNU General Public License as
17 ;; published by the Free Software Foundation; either version 2, or (at
18 ;; your option) any later version.
19
20 ;; This program is distributed in the hope that it will be useful, but
21 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23 ;; General Public License for more details.
24
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
27 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
28 ;; Boston, MA 02110-1301, USA.
29
30 ;;; Commentary:
31
32 ;; Original code: Yoshiki Hayashi <yoshiki@xemacs.org>
33 ;;      makeinfo.el (gnujdoc project)
34
35 ;; Support texinfmt.el 2.32 or later.
36
37 ;; Modified by Yamaoka not to use APEL functions.
38
39 ;; Unimplemented command:
40 ;;  @abbr{ABBREVIATION}
41 ;;  @float ... @end float, @caption{TEXT}, @shortcaption{TEXT}, @listoffloats
42 ;;  @deftypecv[x]
43 ;;  @headitem
44 ;;  @comma{}
45 ;;  @quotation (optional arguments)
46 ;;  @acronym{ACRONYM[, MEANING]} (optional argument)
47 ;;  @dofirstparagraphindent
48 ;;  @indent
49 ;;  @verbatiminclude FILENAME
50 ;;  @\
51 ;;  @definfoenclose phoo,//,\\
52 ;;  @deftypeivar CLASS DATA-TYPE VARIABLE-NAME
53 ;;  @deftypeop CATEGORY CLASS DATA-TYPE NAME ARGUMENTS...
54 ;;  @allowcodebreaks false
55 ;;  @thischapternum
56 ;;  @quotedblleft @quotedblright
57 ;;  @quoteleft @quoteright  @quotedblbase @quotesinglbase
58 ;;  @guillemetleft @guillemetright @guilsinglleft @guilsinglright.
59 ;;  @clicksequence, @click, @clickstyle, @arrow
60
61 ;;; Code:
62
63 (require 'texinfmt)
64
65 ;; Work around a problem that double-quotes at bol disappear:
66 ;; @dfn{FOO} => FOO", ``BAR'' => BAR", \BAZ/ => BAZ/
67 (modify-syntax-entry ?\" "w" texinfo-format-syntax-table)
68 (modify-syntax-entry ?\\ "w" texinfo-format-syntax-table)
69
70 ;;; Broken
71 (defvar ptexinfmt-disable-broken-notice-flag t
72   "If non-nil disable notice, when call `ptexinfmt-broken-facility'.
73 This is last argument in `ptexinfmt-broken-facility'.")
74
75 (put 'ptexinfmt-broken-facility 'lisp-indent-function 'defun)
76 (defmacro ptexinfmt-broken-facility (facility docstring assertion
77                                               &optional _dummy)
78   "Declare a symbol FACILITY is broken if ASSERTION is nil.
79 DOCSTRING will be printed if ASSERTION is nil and
80 `ptexinfmt-disable-broken-notice-flag' is nil."
81   `(let ((facility ',facility)
82          (docstring ,docstring)
83          (assertion (eval ',assertion)))
84      (put facility 'broken (not assertion))
85      (if assertion
86          nil
87        (put facility 'broken-docstring docstring)
88        (if ptexinfmt-disable-broken-notice-flag
89            nil
90          (message "BROKEN FACILITY DETECTED: %s" docstring)))))
91
92 (put 'ptexinfmt-defun-if-broken 'lisp-indent-function 'defun)
93 (defmacro ptexinfmt-defun-if-broken (&rest args)
94   "Redefine a function just like `defun' if it is considered broken."
95   (let ((name (list 'quote (car args))))
96     (setq args (cdr args))
97     `(prog1
98          ,name
99        (if (get ,name 'broken)
100            (defalias ,name
101              (function (lambda ,@args)))))))
102
103 (put 'ptexinfmt-defun-if-void 'lisp-indent-function 'defun)
104 (defmacro ptexinfmt-defun-if-void (&rest args)
105   "Define a function just like `defun' unless it is already defined."
106   (let ((name (list 'quote (car args))))
107     (setq args (cdr args))
108     `(prog1
109          ,name
110        (if (fboundp ,name)
111            nil
112          (defalias ,name
113            (function (lambda ,@args)))))))
114
115 (put 'ptexinfmt-defvar-if-void 'lisp-indent-function 'defun)
116 (defmacro ptexinfmt-defvar-if-void (&rest args)
117   "Define a variable just like `defvar' unless it is already defined."
118   (let ((name (car args)))
119     (setq args (cdr args))
120     `(prog1
121          (defvar ,name)
122        (if (boundp ',name)
123            nil
124          (defvar ,name ,@args)))))
125
126 ;; sort -fd
127 (ptexinfmt-broken-facility texinfo-format-printindex
128   "Can't sort on Mule for Windows."
129   (if (and (memq system-type '(windows-nt ms-dos))
130 ;;; I don't know version threshold.
131 ;;;        (string< texinfmt-version "2.37 of 24 May 1997")
132            (boundp 'MULE) (not (featurep 'meadow))) ; Mule for Windows
133       nil
134     t))
135
136 ;; @var{METASYNTACTIC-VARIABLE}
137 (defvar texinfo-enclosure-list)
138 (defvar texinfo-alias-list)
139 (ptexinfmt-broken-facility texinfo-format-var
140   "Don't perse @var argument."
141   (condition-case nil
142       (with-temp-buffer
143         (let (texinfo-enclosure-list texinfo-alias-list)
144           (texinfo-mode)
145           (insert "@var{@asis{foo}}\n")
146           (texinfo-format-expand-region (point-min) (point-max))
147           t))
148     (error nil)))
149
150 ;; @xref{NODE-NAME[, CROSS-REFERENCE-NAME, TITLE-OR-TOPIC,
151 ;;     INFO-FILE-NAME, PRINTED-MANUAL-TITLE]}.
152 (ptexinfmt-broken-facility texinfo-format-xref
153   "Can't format @xref, 1st argument is empty."
154   (condition-case nil
155       (with-temp-buffer
156         (let (texinfo-enclosure-list texinfo-alias-list)
157           (texinfo-mode)
158           (insert "@xref{, xref, , file}\n")
159           (texinfo-format-expand-region (point-min) (point-max))
160           t))
161     (error nil)))
162
163 ;; @uref{URL[, TEXT][, REPLACEMENT]}
164 (ptexinfmt-broken-facility texinfo-format-uref
165   "Parse twice @uref argument."
166   (condition-case nil
167       (with-temp-buffer
168         (let (texinfo-enclosure-list texinfo-alias-list)
169           (texinfo-mode)
170           (insert "@uref{mailto:foo@@noncommand.example.com}\n")
171           (texinfo-format-expand-region (point-min) (point-max))
172           t))
173     (error nil)))
174
175 ;; @multitable
176 (ptexinfmt-broken-facility texinfo-multitable-widths
177   "`texinfo-multitable-widths' unsupport wide-char."
178   (if (fboundp 'texinfo-multitable-widths)
179       (with-temp-buffer
180         (let ((str (string (make-char 'japanese-jisx0208 73 125)
181                            (make-char 'japanese-jisx0208 57 45)
182                            (make-char 'japanese-jisx0208 74 56)
183                            (make-char 'japanese-jisx0208 59 122))))
184           (texinfo-mode)
185           (insert (format " {%s}\n" str))
186           (goto-char (point-min))
187           (if (= (car (texinfo-multitable-widths)) (length str))
188               t
189             nil)))
190     ;; function definition is void
191     nil))
192
193 (ptexinfmt-broken-facility texinfo-multitable-item
194   "`texinfo-multitable-item' unsupport wide-char."
195   (not (get 'texinfo-multitable-widths 'broken)))
196
197
198 ;;; Hardcopy and HTML (discard)
199 ;; html
200 (put 'documentlanguage 'texinfo-format 'texinfo-discard-line-with-args)
201 (put 'documentencoding 'texinfo-format 'texinfo-discard-line-with-args)
202 (put 'documentdescription 'texinfo-format 'texinfo-discard-line-with-args)
203
204 ;; size
205 (put 'smallbook 'texinfo-format 'texinfo-discard-line)
206 (put 'letterpaper 'texinfo-format 'texinfo-discard-line)
207 (put 'afourpaper 'texinfo-format 'texinfo-discard-line)
208 (put 'afourlatex 'texinfo-format 'texinfo-discard-line)
209 (put 'afourwide 'texinfo-format 'texinfo-discard-line)
210 (put 'afivepaper 'texinfo-format 'texinfo-discard-line)
211 (put 'pagesizes 'texinfo-format 'texinfo-discard-line-with-args)
212 (put 'fonttextsize 'texinfo-format 'texinfo-discard-line-with-args)
213
214 ;; style
215 (put 'setchapternewpage 'texinfo-format 'texinfo-discard-line-with-args)
216 (put 'kbdinputstyle 'texinfo-format 'texinfo-discard-line-with-args)
217
218 ;; flags
219 (put 'setcontentsaftertitlepage 'texinfo-format 'texinfo-discard-line)
220 (put 'setshortcontentsaftertitlepage 'texinfo-format 'texinfo-discard-line)
221 (put 'novalidate 'texinfo-format 'texinfo-discard-line-with-args)
222 (put 'frenchspacing 'texinfo-format 'texinfo-discard-line-with-args)
223
224 ;; head & foot
225 (put 'headings 'texinfo-format 'texinfo-discard-line-with-args)
226 (put 'evenfooting 'texinfo-format 'texinfo-discard-line-with-args)
227 (put 'evenheading 'texinfo-format 'texinfo-discard-line-with-args)
228 (put 'oddfooting 'texinfo-format 'texinfo-discard-line-with-args)
229 (put 'oddheading 'texinfo-format 'texinfo-discard-line-with-args)
230 (put 'everyfooting 'texinfo-format 'texinfo-discard-line-with-args)
231 (put 'everyheading 'texinfo-format 'texinfo-discard-line-with-args)
232
233 ;; misc
234 (put 'page 'texinfo-format 'texinfo-discard-line)
235 (put 'hyphenation 'texinfo-format 'texinfo-discard-command-and-arg)
236
237 ;; @slanted{TEXT} (makeinfo 4.8 or later)
238 (put 'slanted 'texinfo-format 'texinfo-format-noop)
239
240 ;; @sansserif{TEXT} (makeinfo 4.8 or later)
241 (put 'sansserif 'texinfo-format 'texinfo-format-noop)
242
243 ;; @tie{} (makeinfo 4.3 or later)
244 (put 'tie 'texinfo-format 'texinfo-format-tie)
245 (ptexinfmt-defun-if-void texinfo-format-tie ()
246   (texinfo-parse-arg-discard)
247   (insert " "))
248
249 \f
250 ;;; Directory File
251 ;; @direcategory DIRPART
252 (put 'dircategory 'texinfo-format 'texinfo-format-dircategory)
253 (ptexinfmt-defun-if-void texinfo-format-dircategory ()
254   (let ((str (texinfo-parse-arg-discard)))
255     (delete-region (point)
256                    (progn
257                      (skip-chars-forward " ")
258                      (point)))
259     (insert "INFO-DIR-SECTION " str "\n")))
260
261 ;; @direntry ... @end direntry
262 (put 'direntry 'texinfo-format 'texinfo-format-direntry)
263 (ptexinfmt-defun-if-void texinfo-format-direntry ()
264   (texinfo-push-stack 'direntry nil)
265   (texinfo-discard-line)
266   (insert "START-INFO-DIR-ENTRY\n"))
267
268 (put 'direntry 'texinfo-end 'texinfo-end-direntry)
269 (ptexinfmt-defun-if-void texinfo-end-direntry ()
270   (texinfo-discard-command)
271   (insert "END-INFO-DIR-ENTRY\n\n")
272   (texinfo-pop-stack 'direntry))
273
274
275 ;;; Block Enclosing
276 ;; @detailmenu ... @end detailmenu
277 (put 'detailmenu 'texinfo-format 'texinfo-discard-line)
278 (put 'detailmenu 'texinfo-end 'texinfo-discard-command)
279
280 ;; @smalldisplay ... @end smalldisplay
281 (put 'smalldisplay 'texinfo-format 'texinfo-format-example)
282 (put 'smalldisplay 'texinfo-end 'texinfo-end-example)
283
284 ;; @smallformat ... @end smallformat
285 (put 'smallformat 'texinfo-format 'texinfo-format-flushleft)
286 (put 'smallformat 'texinfo-end 'texinfo-end-flushleft)
287
288 ;; @cartouche  ... @end cartouche
289 (put 'cartouche 'texinfo-format 'texinfo-discard-line)
290 (put 'cartouche 'texinfo-end 'texinfo-discard-command)
291
292
293 ;;; Conditional
294 ;; @ifnottex ... @end ifnottex (makeinfo 3.11 or later)
295 (put 'ifnottex 'texinfo-format 'texinfo-discard-line)
296 (put 'ifnottex 'texinfo-end 'texinfo-discard-command)
297
298 ;; @ifnothtml ... @end ifnothtml (makeinfo 3.11 or later)
299 (put 'ifnothtml 'texinfo-format 'texinfo-discard-line)
300 (put 'ifnothtml 'texinfo-end 'texinfo-discard-command)
301
302 ;; @ifnotplaintext ... @end ifnotplaintext (makeinfo 4.2 or later)
303 (put 'ifnotplaintext 'texinfo-format 'texinfo-discard-line)
304 (put 'ifnotplaintext 'texinfo-end 'texinfo-discard-command)
305
306 ;; @ifnotdocbook ... @end ifnotdocbook (makeinfo 4.7 or later)
307 (put 'ifnotdocbook 'texinfo-format 'texinfo-discard-line)
308 (put 'ifnotdocbook 'texinfo-end 'texinfo-discard-command)
309
310 ;; @ifnotinfo ... @end ifnotinfo (makeinfo 3.11 or later)
311 (put 'ifnotinfo 'texinfo-format 'texinfo-format-ifnotinfo)
312 (ptexinfmt-defun-if-void texinfo-format-ifnotinfo ()
313   (delete-region texinfo-command-start
314                  (progn (re-search-forward "@end ifnotinfo[ \t]*\n")
315                         (point))))
316
317 ;; @html ... @end html (makeinfo 3.11 or later)
318 (put 'html 'texinfo-format 'texinfo-format-html)
319 (ptexinfmt-defun-if-void texinfo-format-html ()
320   (delete-region texinfo-command-start
321                  (progn (re-search-forward "@end html[ \t]*\n")
322                         (point))))
323
324 ;; @docbook ... @end docbook (makeinfo 4.7 or later)
325 (put 'docbook 'texinfo-format 'texinfo-format-docbook)
326 (ptexinfmt-defun-if-void texinfo-format-docbook ()
327   (delete-region texinfo-command-start
328                  (progn (re-search-forward "@end docbook[ \t]*\n")
329                         (point))))
330
331 ;; @ifhtml ... @end ifhtml (makeinfo 3.8 or later)
332 (put 'ifhtml 'texinfo-format 'texinfo-format-ifhtml)
333 (defun texinfo-format-ifhtml ()
334   (delete-region texinfo-command-start
335                  (progn (re-search-forward "@end ifhtml[ \t]*\n")
336                         (point))))
337
338 ;; @ifplaintext ... @end ifplaintext (makeinfo 4.2 or later)
339 (put 'ifplaintext 'texinfo-format 'texinfo-format-ifplaintext)
340 (ptexinfmt-defun-if-void texinfo-format-ifplaintext ()
341   (delete-region texinfo-command-start
342                  (progn (re-search-forward "@end ifplaintext[ \t]*\n")
343                         (point))))
344
345 ;; @ifdocbook ... @end ifdocbook (makeinfo 4.7 or later)
346 (put 'ifdocbook 'texinfo-format 'texinfo-format-ifdocbook)
347 (ptexinfmt-defun-if-void texinfo-format-ifdocbook ()
348   (delete-region texinfo-command-start
349                  (progn (re-search-forward "@end ifdocbook[ \t]*\n")
350                         (point))))
351
352 \f
353 ;;; Marking
354 ;; @env{ENVIRONMENT-VARIABLE}
355 (put 'env 'texinfo-format 'texinfo-format-code)
356
357 ;; @command{COMMAND-NAME}
358 (put 'command 'texinfo-format 'texinfo-format-code)
359
360 ;; @indicateurl{INDICATEURL}
361 (put 'indicateurl 'texinfo-format 'texinfo-format-code)
362
363 ;; @url{URL[, DISPLAYED-TEXT][, REPLACEMENT}
364 (put 'url 'texinfo-format 'texinfo-format-uref) ; Texinfo 4.7
365
366 ;; @acronym{ACRONYM}
367 (put 'acronym 'texinfo-format 'texinfo-format-var)
368
369 ;; @var{METASYNTACTIC-VARIABLE}
370 (ptexinfmt-defun-if-broken texinfo-format-var ()
371   (let ((arg (texinfo-parse-expanded-arg)))
372     (texinfo-discard-command)
373     (insert (upcase arg))))
374
375 ;; @key{KEY-NAME}
376 (put 'key 'texinfo-format 'texinfo-format-key)
377 (ptexinfmt-defun-if-void texinfo-format-key ()
378   (insert (texinfo-parse-arg-discard))
379   (goto-char texinfo-command-start))
380
381 ;; @email{EMAIL-ADDRESS[, DISPLAYED-TEXT]}
382 (put 'email 'texinfo-format 'texinfo-format-email)
383 (ptexinfmt-defun-if-void texinfo-format-email ()
384   "Format EMAIL-ADDRESS and optional DISPLAYED-TXT.
385 Insert < ... > around EMAIL-ADDRESS."
386   (let ((args (texinfo-format-parse-args)))
387   (texinfo-discard-command)
388     ;; if displayed-text
389     (if (nth 1 args)
390         (insert (nth 1 args) " <" (nth 0 args) ">")
391       (insert "<" (nth 0 args) ">"))))
392
393 ;; @option{OPTION-NAME}
394 (put 'option 'texinfo-format 'texinfo-format-option)
395 (ptexinfmt-defun-if-void texinfo-format-option ()
396   "Insert ` ... ' around arg unless inside a table; in that case, no quotes."
397   ;; `looking-at-backward' not available in v. 18.57, 20.2
398   ;; searched-for character is a control-H
399   (if (not (search-backward "\010"
400                             (save-excursion (beginning-of-line) (point))
401                             t))
402       (insert "`" (texinfo-parse-arg-discard) "'")
403     (insert (texinfo-parse-arg-discard)))
404   (goto-char texinfo-command-start))
405
406 ;; @verb{<char>TEXT<char>}  (makeinfo 4.1 or later)
407 (put 'verb 'texinfo-format 'texinfo-format-verb)
408 (ptexinfmt-defun-if-void texinfo-format-verb ()
409   "Format text between non-quoted unique delimiter characters verbatim.
410 Enclose the verbatim text, including the delimiters, in braces.  Print
411 text exactly as written (but not the delimiters) in a fixed-width.
412
413 For example, @verb\{|@|\} results in @ and
414 @verb\{+@'e?`!`+} results in @'e?`!`."
415
416   (let ((delimiter (buffer-substring-no-properties
417                     (1+ texinfo-command-end) (+ 2 texinfo-command-end))))
418     (unless (looking-at "{")
419       (error "Not found: @verb start brace"))
420     (delete-region texinfo-command-start (+ 2 texinfo-command-end))
421     (search-forward  delimiter))
422   (delete-char -1)
423   (unless (looking-at "}")
424     (error "Not found: @verb end brace"))
425   (delete-char 1))
426
427 \f
428 ;; @LaTeX{}
429 (put 'LaTeX 'texinfo-format 'texinfo-format-LaTeX)
430 (ptexinfmt-defun-if-void texinfo-format-LaTeX ()
431   (texinfo-parse-arg-discard)
432   (insert "LaTeX"))
433
434 ;; @registeredsymbol{}
435 (put 'registeredsymbol 'texinfo-format 'texinfo-format-registeredsymbol)
436 (ptexinfmt-defun-if-void texinfo-format-registeredsymbol ()
437   (texinfo-parse-arg-discard)
438   (insert "(R)"))
439
440 ;;; Accents and Special characters
441 ;; @euro{}      ==>     Euro
442 (put 'euro 'texinfo-format 'texinfo-format-euro)
443 (ptexinfmt-defun-if-void texinfo-format-euro ()
444   (texinfo-parse-arg-discard)
445   (insert "Euro "))
446
447 ;; @pounds{}    ==>     #       Pounds Sterling
448 (put 'pounds 'texinfo-format 'texinfo-format-pounds)
449 (ptexinfmt-defun-if-void texinfo-format-pounds ()
450   (texinfo-parse-arg-discard)
451   (insert "#"))
452
453 ;; @ordf{}      ==>     a       Spanish feminine
454 (put 'ordf 'texinfo-format 'texinfo-format-ordf)
455 (ptexinfmt-defun-if-void texinfo-format-ordf ()
456   (texinfo-parse-arg-discard)
457   (insert "a"))
458
459 ;; @ordm{}      ==>     o       Spanish masculine
460 (put 'ordm 'texinfo-format 'texinfo-format-ordm)
461 (ptexinfmt-defun-if-void texinfo-format-ordm ()
462   (texinfo-parse-arg-discard)
463   (insert "o"))
464
465 ;; @OE{}        ==>     OE      French-OE-ligature
466 (put 'OE 'texinfo-format 'texinfo-format-French-OE-ligature)
467 (ptexinfmt-defun-if-void texinfo-format-French-OE-ligature ()
468   (insert "OE" (texinfo-parse-arg-discard))
469   (goto-char texinfo-command-start))
470
471 ;; @oe{}        ==>     oe
472 (put 'oe 'texinfo-format 'texinfo-format-French-oe-ligature)
473 (ptexinfmt-defun-if-void texinfo-format-French-oe-ligature () ; lower case
474   (insert "oe" (texinfo-parse-arg-discard))
475   (goto-char texinfo-command-start))
476
477 ;; @AA{}        ==>     AA      Scandinavian-A-with-circle
478 (put 'AA 'texinfo-format 'texinfo-format-Scandinavian-A-with-circle)
479 (ptexinfmt-defun-if-void texinfo-format-Scandinavian-A-with-circle ()
480   (insert "AA" (texinfo-parse-arg-discard))
481   (goto-char texinfo-command-start))
482
483 ;; @aa{}        ==>     aa
484 (put 'aa 'texinfo-format 'texinfo-format-Scandinavian-a-with-circle)
485 (ptexinfmt-defun-if-void texinfo-format-Scandinavian-a-with-circle () ; lower case
486   (insert "aa" (texinfo-parse-arg-discard))
487   (goto-char texinfo-command-start))
488
489 ;; @AE{}        ==>     AE      Latin-Scandinavian-AE
490 (put 'AE 'texinfo-format 'texinfo-format-Latin-Scandinavian-AE)
491 (ptexinfmt-defun-if-void texinfo-format-Latin-Scandinavian-AE ()
492   (insert "AE" (texinfo-parse-arg-discard))
493   (goto-char texinfo-command-start))
494
495 ;; @ae{}        ==>     ae
496 (put 'ae 'texinfo-format 'texinfo-format-Latin-Scandinavian-ae)
497 (ptexinfmt-defun-if-void texinfo-format-Latin-Scandinavian-ae () ; lower case
498   (insert "ae" (texinfo-parse-arg-discard))
499   (goto-char texinfo-command-start))
500
501 ;; @ss{}        ==>     ss      German-sharp-S
502 (put 'ss 'texinfo-format 'texinfo-format-German-sharp-S)
503 (ptexinfmt-defun-if-void texinfo-format-German-sharp-S ()
504   (insert "ss" (texinfo-parse-arg-discard))
505   (goto-char texinfo-command-start))
506
507 ;; @questiondown{}      ==>     ?       upside-down-question-mark
508 (put 'questiondown 'texinfo-format 'texinfo-format-upside-down-question-mark)
509 (ptexinfmt-defun-if-void texinfo-format-upside-down-question-mark ()
510   (insert "?" (texinfo-parse-arg-discard))
511   (goto-char texinfo-command-start))
512
513 ;; @exclamdown{}        ==>     !       upside-down-exclamation-mark
514 (put 'exclamdown 'texinfo-format 'texinfo-format-upside-down-exclamation-mark)
515 (ptexinfmt-defun-if-void texinfo-format-upside-down-exclamation-mark ()
516   (insert "!" (texinfo-parse-arg-discard))
517   (goto-char texinfo-command-start))
518
519 ;; @L{}         ==>     L/      Polish suppressed-L (Lslash)
520 (put 'L 'texinfo-format 'texinfo-format-Polish-suppressed-L)
521 (ptexinfmt-defun-if-void texinfo-format-Polish-suppressed-L ()
522   (insert (texinfo-parse-arg-discard) "/L")
523   (goto-char texinfo-command-start))
524
525 ;; @l{}         ==>     l/      Polish suppressed-L (Lslash) (lower case)
526 (put 'l 'texinfo-format 'texinfo-format-Polish-suppressed-l-lower-case)
527 (ptexinfmt-defun-if-void texinfo-format-Polish-suppressed-l-lower-case ()
528   (insert (texinfo-parse-arg-discard) "/l")
529   (goto-char texinfo-command-start))
530
531 ;; @O{}         ==>     O/      Scandinavian O-with-slash
532 (put 'O 'texinfo-format 'texinfo-format-Scandinavian-O-with-slash)
533 (ptexinfmt-defun-if-void texinfo-format-Scandinavian-O-with-slash ()
534   (insert (texinfo-parse-arg-discard) "O/")
535   (goto-char texinfo-command-start))
536
537 ;; @o{}         ==>     o/      Scandinavian O-with-slash (lower case)
538 (put 'o 'texinfo-format 'texinfo-format-Scandinavian-o-with-slash-lower-case)
539 (ptexinfmt-defun-if-void texinfo-format-Scandinavian-o-with-slash-lower-case ()
540   (insert (texinfo-parse-arg-discard) "o/")
541   (goto-char texinfo-command-start))
542
543 ;; @,{c}        ==>     c,      cedilla accent
544 (put '\, 'texinfo-format 'texinfo-format-cedilla-accent)
545 (ptexinfmt-defun-if-void texinfo-format-cedilla-accent ()
546   (insert (texinfo-parse-arg-discard) ",")
547   (goto-char texinfo-command-start))
548
549
550 ;; @dotaccent{o}        ==>     .o      overdot-accent
551 (put 'dotaccent 'texinfo-format 'texinfo-format-overdot-accent)
552 (ptexinfmt-defun-if-void texinfo-format-overdot-accent ()
553   (insert "." (texinfo-parse-arg-discard))
554   (goto-char texinfo-command-start))
555
556 ;; @ubaraccent{o}       ==>     _o      underbar-accent
557 (put 'ubaraccent 'texinfo-format 'texinfo-format-underbar-accent)
558 (ptexinfmt-defun-if-void texinfo-format-underbar-accent ()
559   (insert "_" (texinfo-parse-arg-discard))
560   (goto-char texinfo-command-start))
561
562 ;; @udotaccent{o}       ==>     o-.     underdot-accent
563 (put 'udotaccent 'texinfo-format 'texinfo-format-underdot-accent)
564 (ptexinfmt-defun-if-void texinfo-format-underdot-accent ()
565   (insert (texinfo-parse-arg-discard) "-.")
566   (goto-char texinfo-command-start))
567
568 ;; @H{o}        ==>     ""o     long Hungarian umlaut
569 (put 'H 'texinfo-format 'texinfo-format-long-Hungarian-umlaut)
570 (ptexinfmt-defun-if-void texinfo-format-long-Hungarian-umlaut ()
571   (insert "\"\"" (texinfo-parse-arg-discard))
572   (goto-char texinfo-command-start))
573
574 ;; @ringaccent{o}       ==>     *o      ring accent
575 (put 'ringaccent 'texinfo-format 'texinfo-format-ring-accent)
576 (ptexinfmt-defun-if-void texinfo-format-ring-accent ()
577   (insert "*" (texinfo-parse-arg-discard))
578   (goto-char texinfo-command-start))
579
580 ;; @tieaccent{oo}       ==>     [oo     tie after accent
581 (put 'tieaccent 'texinfo-format 'texinfo-format-tie-after-accent)
582 (ptexinfmt-defun-if-void texinfo-format-tie-after-accent ()
583   (insert "[" (texinfo-parse-arg-discard))
584   (goto-char texinfo-command-start))
585
586 ;; @u{o}        ==>     (o      breve accent
587 (put 'u 'texinfo-format 'texinfo-format-breve-accent)
588 (ptexinfmt-defun-if-void texinfo-format-breve-accent ()
589   (insert "(" (texinfo-parse-arg-discard))
590   (goto-char texinfo-command-start))
591
592 ;; @v{o}        ==>     <o      hacek accent
593 (put 'v 'texinfo-format 'texinfo-format-hacek-accent)
594 (ptexinfmt-defun-if-void texinfo-format-hacek-accent ()
595   (insert "<" (texinfo-parse-arg-discard))
596   (goto-char texinfo-command-start))
597
598 ;; @dotless{i}  ==>     i       dotless i and dotless j
599 (put 'dotless 'texinfo-format 'texinfo-format-dotless)
600 (ptexinfmt-defun-if-void texinfo-format-dotless ()
601   (insert (texinfo-parse-arg-discard))
602   (goto-char texinfo-command-start))
603
604 ;; @.
605 (put '\. 'texinfo-format 'texinfo-format-\.)
606 (ptexinfmt-defun-if-void texinfo-format-\. ()
607   (texinfo-discard-command)
608   (insert "."))
609
610 ;; @:
611 (put '\: 'texinfo-format 'texinfo-format-\:)
612 (ptexinfmt-defun-if-void texinfo-format-\: ()
613   (texinfo-discard-command))
614
615 ;; @-
616 (put '\- 'texinfo-format 'texinfo-format-soft-hyphen)
617 (ptexinfmt-defun-if-void texinfo-format-soft-hyphen ()
618   (texinfo-discard-command))
619
620 ;; @/
621 (put '\/ 'texinfo-format 'texinfo-format-\/)
622 (ptexinfmt-defun-if-void texinfo-format-\/ ()
623   (texinfo-discard-command))
624
625 ;; @textdegree{}
626 (put 'textdegree 'texinfo-format 'texinfo-format-textdegree)
627 (ptexinfmt-defun-if-void texinfo-format-textdegree ()
628   (insert "o" (texinfo-parse-arg-discard))
629   (goto-char texinfo-command-start))
630
631 ;; @geq{}
632 (put 'geq 'texinfo-format 'texinfo-format-geq)
633 (ptexinfmt-defun-if-void texinfo-format-geq ()
634   (insert ">=" (texinfo-parse-arg-discard))
635   (goto-char texinfo-command-start))
636
637 ;; @leq{}
638 (put 'leq 'texinfo-format 'texinfo-format-leq)
639 (ptexinfmt-defun-if-void texinfo-format-leq ()
640   (insert "<=" (texinfo-parse-arg-discard))
641   (goto-char texinfo-command-start))
642
643 \f
644 ;;; Cross References
645 ;; @ref{NODE-NAME, ...}
646 ;; @xref{NODE-NAME, ...}
647 (put 'ref 'texinfo-format 'texinfo-format-xref)
648
649 (ptexinfmt-defun-if-broken texinfo-format-xref ()
650   (let ((args (texinfo-format-parse-args)))
651     (texinfo-discard-command)
652     (insert "*Note ")
653     (let ((fname (or (nth 1 args) (nth 2 args))))
654       (if (null (or fname (nth 3 args)))
655           (insert (nth 0 args) "::")
656         (insert (or fname (nth 0 args)) ": ")
657         (if (nth 3 args)
658             (insert "(" (nth 3 args) ")"))
659         (unless (null (nth 0 args))
660           (insert (nth 0 args)))))))
661
662 ;; @uref{URL [,TEXT] [,REPLACEMENT]}
663 (put 'uref 'texinfo-format 'texinfo-format-uref)
664 (ptexinfmt-defun-if-broken texinfo-format-uref ()
665   "Format URL and optional URL-TITLE.
666 Insert ` ... ' around URL if no URL-TITLE argument;
667 otherwise, insert URL-TITLE followed by URL in parentheses."
668   (let ((args (texinfo-format-parse-args)))
669     (texinfo-discard-command)
670     ;; if url-title
671     (if (nth 1 args)
672         (insert  (nth 1 args) " (" (nth 0 args) ")")
673       (insert "`" (nth 0 args) "'"))))
674
675 ;; @inforef{NODE-NAME, CROSS-REFERENCE-NAME, INFO-FILE-NAME}
676 (put 'inforef 'texinfo-format 'texinfo-format-inforef)
677 (ptexinfmt-defun-if-void texinfo-format-inforef ()
678   (let ((args (texinfo-format-parse-args)))
679     (texinfo-discard-command)
680     (if (nth 1 args)
681         (insert "*Note " (nth 1 args) ": (" (nth 2 args) ")" (car args))
682       (insert "*Note " "(" (nth 2 args) ")" (car args) "::"))))
683
684
685 ;; @anchor{NAME}
686 ;; don't emulation
687 ;; If support @anchor for Mule 2.3, We must fix informat.el and info.el:
688 ;;  - Info-tagify suport @anthor-*-refill.
689 ;;  - info.el support Ref in Tag table.
690 (unless (get 'anchor 'texinfo-format)
691   (put 'anchor 'texinfo-format 'texinfo-discard-command-and-arg))
692
693
694 \f
695 ;;; New command definition
696 ;; @alias NEW=EXISTING
697 (put 'alias 'texinfo-format 'texinfo-alias)
698 (ptexinfmt-defun-if-void texinfo-alias ()
699   (let ((start (1- (point)))
700         args)
701     (skip-chars-forward " ")
702     (save-excursion (end-of-line) (setq texinfo-command-end (point)))
703     (if (not (looking-at "\\([^=]+\\)=\\(.*\\)"))
704         (error "Invalid alias command")
705       (setq texinfo-alias-list
706             (cons
707              (cons
708               (buffer-substring (match-beginning 1) (match-end 1))
709               (buffer-substring (match-beginning 2) (match-end 2)))
710              texinfo-alias-list))
711       (texinfo-discard-command))))
712
713 \f
714 ;;; Indent
715 ;; @exampleindent INDENT  (makeinfo 4.0 or later)
716
717 ;; @paragraphindent INDENT  (makeinfo 4.0 or later)
718 ;; INDENT: asis, 0, n
719
720 ;; @firstparagraphindent WORD   (makeinfo 4.6 or later)
721 ;; WORD: none, insert
722
723
724 \f
725 ;;; Special
726 ;; @image{FILENAME [, WIDTH] [, HEIGHT]}
727 (put 'image 'texinfo-format 'texinfo-format-image)
728 (ptexinfmt-defun-if-void texinfo-format-image ()
729   ;; I don't know makeinfo parse FILENAME.
730   (let ((args (texinfo-format-parse-args))
731         filename)
732     (when (null (nth 0 args))
733       (error "Invalid image command"))
734     (texinfo-discard-command)
735     ;; makeinfo uses FILENAME.txt
736     (setq filename (format "%s.txt" (nth 0 args)))
737     (message "Reading included file: %s" filename)
738     ;; verbatim for Info output
739     (goto-char (+ (point) (cadr (insert-file-contents filename))))
740     (message "Reading included file: %s...done" filename)))
741
742
743 \f
744 ;;; @multitable ... @end multitable
745 (ptexinfmt-defvar-if-void texinfo-extra-inter-column-width 0
746   "*Number of extra spaces between entries (columns) in @multitable.")
747
748 (ptexinfmt-defvar-if-void texinfo-multitable-buffer-name
749   "*multitable-temporary-buffer*")
750 (ptexinfmt-defvar-if-void texinfo-multitable-rectangle-name
751   "texinfo-multitable-temp-")
752
753 ;; These commands are defined in texinfo.tex for printed output.
754 (put 'multitableparskip 'texinfo-format 'texinfo-discard-line-with-args)
755 (put 'multitableparindent 'texinfo-format 'texinfo-discard-line-with-args)
756 (put 'multitablecolmargin 'texinfo-format 'texinfo-discard-line-with-args)
757 (put 'multitablelinespace 'texinfo-format 'texinfo-discard-line-with-args)
758
759 (put 'multitable 'texinfo-format 'texinfo-multitable)
760
761 (ptexinfmt-defun-if-void texinfo-multitable ()
762   "Produce multi-column tables."
763
764 ;; This function pushes information onto the `texinfo-stack'.
765 ;; A stack element consists of:
766 ;;   - type-of-command, i.e., multitable
767 ;;   - the information about column widths, and
768 ;;   - the position of texinfo-command-start.
769 ;; e.g., ('multitable (1 2 3 4) 123)
770 ;; The command line is then deleted.
771   (texinfo-push-stack
772    'multitable
773    ;; push width information on stack
774    (texinfo-multitable-widths))
775   (texinfo-discard-line-with-args))
776
777 (put 'multitable 'texinfo-end 'texinfo-end-multitable)
778 (ptexinfmt-defun-if-void texinfo-end-multitable ()
779   "Discard the @end multitable line and pop the stack of multitable."
780   (texinfo-discard-command)
781   (texinfo-pop-stack 'multitable))
782
783 (ptexinfmt-defun-if-broken texinfo-multitable-widths ()
784   "Return list of widths of each column in a multi-column table."
785   (let (texinfo-multitable-width-list)
786     ;; Fractions format:
787     ;;  @multitable @columnfractions .25 .3 .45
788     ;;
789     ;; Template format:
790     ;;  @multitable {Column 1 template} {Column 2} {Column 3 example}
791     ;; Place point before first argument
792     (skip-chars-forward " \t")
793     (cond
794      ;; Check for common misspelling
795      ((looking-at "@columnfraction ")
796       (error "In @multitable, @columnfractions misspelled"))
797      ;; Case 1: @columnfractions .25 .3 .45
798      ((looking-at "@columnfractions")
799       (forward-word 1)
800       (while (not (eolp))
801         (setq texinfo-multitable-width-list
802               (cons
803                (truncate
804                 (1-
805                  (* fill-column (read (get-buffer (current-buffer))))))
806                texinfo-multitable-width-list))))
807      ;;
808      ;; Case 2: {Column 1 template} {Column 2} {Column 3 example}
809      ((looking-at "{")
810       (let ((start-of-templates (point)))
811         (while (not (eolp))
812           (skip-chars-forward " \t")
813           (let* ((start-of-template (1+ (point)))
814                  (end-of-template
815                   ;; forward-sexp works with braces in Texinfo mode
816                   (progn (forward-sexp 1) (1- (point)))))
817             (setq texinfo-multitable-width-list
818                   (cons (- (progn
819                              (goto-char end-of-template)
820                              (current-column))
821                            (progn
822                              (goto-char start-of-template)
823                              (current-column)))
824                         texinfo-multitable-width-list))
825             ;; Remove carriage return from within a template, if any.
826             ;; This helps those those who want to use more than
827             ;; one line's worth of words in @multitable line.
828             (narrow-to-region start-of-template end-of-template)
829             (goto-char (point-min))
830             (while (search-forward "\n" nil t)
831               (delete-char -1))
832             (goto-char (point-max))
833             (widen)
834             (forward-char 1)))))
835      ;;
836      ;; Case 3: Trouble
837      (t
838       (error "\
839 You probably need to specify column widths for @multitable correctly")))
840     ;; Check whether columns fit on page.
841     (let ((desired-columns
842            (+
843             ;; between column spaces
844             (length texinfo-multitable-width-list)
845             ;; additional between column spaces, if any
846             texinfo-extra-inter-column-width
847             ;; sum of spaces for each entry
848             (apply '+ texinfo-multitable-width-list))))
849       (if (> desired-columns fill-column)
850           (error (format "\
851 Multi-column table width, %d chars, is greater than page width, %d chars."
852                          desired-columns fill-column))))
853     texinfo-multitable-width-list))
854
855 ;; @item  A1  @tab  A2  @tab  A3
856 (ptexinfmt-defun-if-void texinfo-multitable-extract-row ()
857   "Return multitable row, as a string.
858 End of row is beginning of next @item or beginning of @end.
859 Cells within rows are separated by @tab."
860   (skip-chars-forward " \t")
861   (let* ((start (point))
862          (end (progn
863                 (re-search-forward "@item\\|@end")
864                 (match-beginning 0)))
865          (row (progn (goto-char end)
866                      (skip-chars-backward " ")
867                      ;; remove whitespace at end of argument
868                      (delete-region (point) end)
869                      (buffer-substring start (point)))))
870     (delete-region texinfo-command-start end)
871     row))
872
873 (put 'multitable 'texinfo-item 'texinfo-multitable-item)
874 (ptexinfmt-defun-if-void texinfo-multitable-item ()
875   "Format a row within a multicolumn table.
876 Cells in row are separated by @tab.
877 Widths of cells are specified by the arguments in the @multitable line.
878 All cells are made to be the same height.
879 This command is executed when texinfmt sees @item inside @multitable."
880   (let ((original-buffer (current-buffer))
881         (table-widths (reverse (car (cdr (car texinfo-stack)))))
882         (existing-fill-column fill-column)
883         start
884         end
885         (table-column       0)
886         (table-entry-height 0)
887         ;; unformatted row looks like:  A1  @tab  A2  @tab  A3
888         ;; extract-row command deletes the source line in the table.
889         (unformated-row (texinfo-multitable-extract-row)))
890     ;; Use a temporary buffer
891     (set-buffer (get-buffer-create texinfo-multitable-buffer-name))
892     (delete-region (point-min) (point-max))
893     (insert unformated-row)
894     (goto-char (point-min))
895 ;; 1. Check for correct number of @tab in line.
896     (let ((tab-number 1)) ;; one @tab between two columns
897       (while (search-forward "@tab" nil t)
898         (setq tab-number (1+ tab-number)))
899       (if (/= tab-number (length table-widths))
900           (error "Wrong number of @tab's in a @multitable row")))
901     (goto-char (point-min))
902 ;; 2. Format each cell, and copy to a rectangle
903     ;; buffer looks like this:    A1  @tab  A2  @tab  A3
904     ;; Cell #1: format up to @tab
905     ;; Cell #2: format up to @tab
906     ;; Cell #3: format up to eob
907     (while (not (eobp))
908       (setq start (point))
909       (setq end (save-excursion
910                   (if (search-forward "@tab" nil 'move)
911                       ;; Delete the @tab command, including the @-sign
912                       (delete-region
913                        (point)
914                        (progn (forward-word -1) (1- (point)))))
915                   (point)))
916       ;; Set fill-column *wider* than needed to produce inter-column space
917       (setq fill-column (+ 1
918                            texinfo-extra-inter-column-width
919                            (nth table-column table-widths)))
920       (narrow-to-region start end)
921       ;; Remove whitespace before and after entry.
922       (skip-chars-forward " ")
923       (delete-region (point) (save-excursion (beginning-of-line) (point)))
924       (goto-char (point-max))
925       (skip-chars-backward " ")
926       (delete-region (point) (save-excursion (end-of-line) (point)))
927       ;; Temorarily set texinfo-stack to nil so texinfo-format-scan
928       ;; does not see an unterminated @multitable.
929       (let (texinfo-stack) ;; nil
930         (texinfo-format-scan))
931       (let (fill-prefix) ;; no fill prefix
932         (fill-region (point-min) (point-max)))
933       (setq table-entry-height
934             (max table-entry-height (count-lines (point-min) (point-max))))
935 ;; 3. Move point to end of bottom line, and pad that line to fill column.
936       (goto-char (point-min))
937       (forward-line (1- table-entry-height))
938       (let* ((beg (point)) ;; beginning of line
939              ;; add one more space for inter-column spacing
940              (needed-whitespace
941               (1+
942                (- fill-column
943                   (progn
944                     (end-of-line)
945                     (current-column)))))) ;; end of existing line
946         (insert (make-string
947                  (if (> needed-whitespace 0) needed-whitespace 1)
948                  ? )))
949       ;; now, put formatted cell into a rectangle
950       (set (intern (concat texinfo-multitable-rectangle-name
951                            (int-to-string table-column)))
952            (extract-rectangle (point-min) (point)))
953       (delete-region (point-min) (point))
954       (goto-char (point-max))
955       (setq table-column (1+ table-column))
956       (widen))
957 ;; 4. Add extra lines to rectangles so all are of same height
958     (let ((total-number-of-columns table-column)
959           (column-number 0)
960           here)
961       (while (> table-column 0)
962         (let ((this-rectangle (int-to-string table-column)))
963           (while (< (length this-rectangle) table-entry-height)
964             (setq this-rectangle (append this-rectangle '("")))))
965         (setq table-column (1- table-column)))
966 ;; 5. Insert formatted rectangles in original buffer
967       (switch-to-buffer original-buffer)
968       (open-line table-entry-height)
969       (while (< column-number total-number-of-columns)
970         (setq here (point))
971         (insert-rectangle
972          (eval (intern
973                 (concat texinfo-multitable-rectangle-name
974                         (int-to-string column-number)))))
975         (goto-char here)
976         (end-of-line)
977         (setq column-number (1+ column-number))))
978     (kill-buffer texinfo-multitable-buffer-name)
979     (setq fill-column existing-fill-column)))
980
981 \f
982 (ptexinfmt-defun-if-broken texinfo-format-printindex ()
983   (let ((indexelts (symbol-value
984                     (cdr (assoc (texinfo-parse-arg-discard)
985                                 texinfo-indexvar-alist))))
986         opoint)
987     (insert "\n* Menu:\n\n")
988     (setq opoint (point))
989     (texinfo-print-index nil indexelts)
990
991     (if (memq system-type '(vax-vms windows-nt ms-dos))
992         (texinfo-sort-region opoint (point))
993       (shell-command-on-region opoint (point) "sort -fd" 1))))
994
995 \f
996 ;; @copying ... @end copying
997 ;; that Emacs 21.4 and lesser and XEmacs don't support.
998 (if (fboundp 'texinfo-copying)
999     nil
1000   (defvar texinfo-copying-text ""
1001     "Text of the copyright notice and copying permissions.")
1002
1003   (defun texinfo-copying ()
1004     "Copy the copyright notice and copying permissions from the Texinfo file,
1005 as indicated by the @copying ... @end copying command;
1006 insert the text with the @insertcopying command."
1007     (let ((beg (progn (beginning-of-line) (point)))
1008           (end  (progn (re-search-forward "^@end copying[ \t]*\n") (point))))
1009       (setq texinfo-copying-text
1010             (buffer-substring-no-properties
1011              (save-excursion (goto-char beg) (forward-line 1) (point))
1012              (save-excursion (goto-char end) (forward-line -1) (point))))
1013       (delete-region beg end)))
1014
1015   (defun texinfo-insertcopying ()
1016     "Insert the copyright notice and copying permissions from the Texinfo file,
1017 which are indicated by the @copying ... @end copying command."
1018     (insert (concat "\n" texinfo-copying-text)))
1019
1020   (defadvice texinfo-format-scan (before expand-@copying-section activate)
1021     "Extract @copying and replace @insertcopying with it."
1022     (goto-char (point-min))
1023     (when (search-forward "@copying" nil t)
1024       (texinfo-copying))
1025     (while (search-forward "@insertcopying" nil t)
1026       (delete-region (match-beginning 0) (match-end 0))
1027       (texinfo-insertcopying))))
1028
1029 \f
1030 ;; @comma
1031 (if (fboundp 'texinfo-format-comma)
1032     nil
1033   (put 'comma 'texinfo-format 'texinfo-format-comma)
1034   (defun texinfo-format-comma ()
1035     (texinfo-parse-arg-discard)
1036     (insert ",")
1037     (put-text-property (1- (point)) (point) 'ignore t))
1038
1039   ;; Redefine this function so as to work for @comma
1040   (defun texinfo-format-parse-args ()
1041     (let ((start (1- (point)))
1042           next beg end
1043           args)
1044       (search-forward "{")
1045       (save-excursion
1046         (texinfo-format-expand-region
1047          (point)
1048          (save-excursion (up-list 1) (1- (point)))))
1049       ;; The following does not handle cross references of the form:
1050       ;; `@xref{bullet, , @code{@@bullet}@{@}}.' because the
1051       ;; re-search-forward finds the first right brace after the second
1052       ;; comma.
1053       (while (/= (preceding-char) ?\})
1054         (skip-chars-forward " \t\n")
1055         (setq beg (point))
1056 ;;;     (re-search-forward "[},]")
1057         ;; Ignore commas that are derived from @comma{}.
1058         (while (and (re-search-forward "[},]" nil t)
1059                     (get-text-property (match-beginning 0) 'ignore)))
1060 ;;;
1061         (setq next (point))
1062         (forward-char -1)
1063         (skip-chars-backward " \t\n")
1064         (setq end (point))
1065         (cond ((< beg end)
1066                (goto-char beg)
1067                (while (search-forward "\n" end t)
1068                  (replace-match " "))))
1069         (push (if (> end beg) (buffer-substring-no-properties beg end))
1070               args)
1071         (goto-char next))
1072       ;;(if (eolp) (forward-char 1))
1073       (setq texinfo-command-end (point))
1074       (nreverse args))))
1075
1076 (provide 'ptexinfmt)
1077
1078 ;;; ptexinfmt.el ends here