1 ;;;;if you are in a buffer which has a man page you can try
2 ;; M-x doit, to do an at least partial conversion of tcl tk man pages to
5 ;; file for converting the tcl/tk man pages to texinfo and suitable for gcl/tk
7 ; .br break output line here
8 ; .sp n insert n spacing lines
9 ; .ls n (line spacing) n=1 single, n=2 double space
10 ; .na no alignment of right margin
11 ; .ce n center next n lines
12 ; .ul n underline next n lines
13 ; .sz +n add n to point size
16 ; Request Cause If no Explanation
19 ; .B t no t=n.t.l.* Text is in bold font.
20 ; .BI t no t=n.t.l. Join words, alternating bold
22 ; .BR t no t=n.t.l. Join words, alternating bold
24 ; .DT no .5i 1i... Restore default tabs.
25 ; .HP i yes i=p.i.* Begin paragraph with hanging
26 ; indent. Set prevailing indent to i.
27 ; .I t no t=n.t.l. Text is italic.
28 ; .IB t no t=n.t.l. Join words, alternating italic
31 ; .IP x i yes x="" Same as .TP with tag x.
32 ; .IR t no t=n.t.l. Join words, alternating italic
34 ; .IX t no - Index macro, for Sun internal
36 ; .LP yes - Begin left-aligned paragraph.
37 ; Set prevailing indent to .5i.
38 ; .PD d no d=.4v Set vertical distance between
40 ; .PP yes - Same as .LP.
41 ; .RE yes - End of relative indent.
42 ; Restores prevailing indent.
43 ; .RB t no t=n.t.l. Join words, alternating roman
45 ; .RI t no t=n.t.l. Join words, alternating roman
47 ; .RS i yes i=p.i. Start relative indent,
48 ; increase indent by i. Sets prevailing indent to
49 ; .5i for nested indents.
50 ; .SB t no - Reduce size of text by 1
51 ; point, make text boldface.
52 ; .SH t yes - Section Heading.
53 ; .SM t no t=n.t.l. Reduce size of text by 1
55 ; .SS t yes t=n.t.l. Section Subheading.
57 ; yes - Begin reference page n, of
58 ; section s; d is the date of the most
59 ; recent change. If present, f
60 ; is the left page footer; m is the
61 ; main page (center) header.
62 ; Sets prevailing indent and tabs to .5i.
63 ; .TP i yes i=p.i. Begin indented paragraph, with
64 ; the tag given on the next text
65 ; line. Set prevailing indent
68 ; .TX t p no - Resolve the title abbreviation
69 ; t; join to punctuation mark (or text) p. *
70 ; n.t.l. = next text line; p.i. = prevailing
72 ; .HS name section [date [version]]
73 ; Replacement for .TH in other man pages. See below for valid
76 ; .AP type name in/out [indent]
77 ; Start paragraph describing an argument to a library procedure.
78 ; type is type of argument (int, etc.), in/out is either "in", "out",
79 ; or "in/out" to describe whether procedure reads or modifies arg,
80 ; and indent is equivalent to second arg of .IP (shouldn't ever be
81 ; needed; use .AS below instead)
84 ; Give maximum sizes of arguments for setting tab stops. Type and
85 ; name are examples of largest possible arguments that will be passed
86 ; to .AP later. If args are omitted, default tab stops are used.
89 ; Start box enclosure. From here until next .BE, everything will be
90 ; enclosed in one large box.
93 ; End of box enclosure.
96 ; Begin vertical sidebar, for use in marking newly-changed parts
100 ; End of vertical sidebar.
103 ; Begin an indented unfilled display.
106 ; End of indented unfilled display.
109 (defun do-replace (lis &optional not-in-string
)
110 (let (x case-fold-search
)
112 (setq x
(car lis
)) (setq lis
(cdr lis
))
113 (goto-char (point-min))
114 (message "doing %s " x
)
115 (while (re-search-forward (nth 0 x
) nil t
)
117 (progn (forward-char -
1)
118 (not (in-a-string))))
123 (while (match-beginning i
)
124 (setq ans
(cons (buffer-substring
128 (setq ans
(nreverse ans
))
129 (goto-char (match-beginning 0))
130 (delete-region (match-beginning 0)
132 (apply f ans
)))))))))
140 (goto-char (point-min))
141 (do-replace '(("@" "@@")
145 (goto-char (point-min))
146 (insert "@setfilename foo.info")
152 (".SH \"SEE ALSO\"\n\\([^\n]*\\)" "@xref{\\1}")
154 ("^'[\\]\"[^\n]*\n" "")
155 ("^'[/]\"[^\n]*\n" "")
156 ("^[.]so[^\n]+\n" "")
157 ("[.]HS \\([^ \n]+\\)\\([^\n]*\\)\n"
158 "@node \\1\n@subsection \\1\n")
161 (".nf\nName:\t\\([^\n]*\\)\nClass:\t\\([^\n]*\\)\nCommand-Line Switch:\t\\([^\n]*\\)\n.fi\n" do-keyword
)
162 ("Name:\t\\([^\n]*\\)\nClass:\t\\([^\n]*\\)\nCommand-Line Switch:\t\\([^\n]*\\)\n" do-keyword
)
163 ("Name:\t\\([^\n]*\\)\n" "@*@w{ Name: @code{\\1}}\n")
164 ("Class:\t\\([^\n]*\\)\n" "@*@w{ Class: @code{\\1}}\n")
165 ("Command-Line Switch:\t\\([^\n]*\\)\n" "@*@w{ Keyword: @code{\\1}}\n")
166 ("[\\]-\\([a-z]\\)" ":\\1")
167 ("^[.]nf\n" "@example\n")
168 ("^[.]fi\n" "@end example\n")
169 ("^[.]ta[^\n]*\n" do-ta
)
171 ("[\\]f\\([A-Z]\\)\\([^\\\n]*\\)[\\]f"
173 ("^\\([^\n]+\\)\n[.]br" "@*@w{\\1}@*")
174 ("^[.]SH \\([^\n]*\\)"
176 (insert "@unnumberedsubsec " (capitalize a1
))))
179 ("^[.]BS" "@cartouche")
180 ("^[.]BE" "@end cartouche")
181 ("^[.]sp \\([0-9]\\)" "@sp \\1")
185 ("^[.]DS[^\n]*\n" "\n@example\n")
186 ("^[.]DE[^\n]*\n" "@end example\n\n")
187 ("^[.]DS[^\n]*\n" "\n@example\n")
188 ("^[.]DE[^\n]*\n" "@end example\n\n")
189 ("^[.]RS\n" "") ; relative indent increased..
191 ("^[\\]&\\([^\n]*\\)\n" "@*@w{ \\1}\n")
192 ; ("Command-Line Switch" "Keyword")
193 ("pathName }@b{\\([a-z]\\)" "pathName }@b{:\\1")
195 ("%\\([a-z#]\\)\\([^a-zA-Z0-9%]\\)" "|%\\1|\\2")
196 ("^[.]TP[^\n]*\n" "@item ")
201 (defun do-font (ign a b
)
202 (let ((ch (assoc (aref a
0)
206 (cond (ch (insert (cdr ch
) b
"}\\f")
209 (t (error "unknown leter %s" a
)))))
211 (defun do-keyword (ign name class key
)
212 (insert "@table \n@item @code{"key
"}"
213 "\n@flushright\nName=@code{\""name
"\"} Class=@code{\""class
"\"}\n"
214 "@end flushright\n@sp 1\n")
216 (cond ((re-search-forward "[.]LP\\|[.]BE\\|[.]SH" nil t
)
218 (insert "@end table\n")))))
225 (if (get-buffer "foo.texi")
226 (kill-buffer (get-buffer "foo.texi")))
228 (if (get-buffer "foo.info")
229 (kill-buffer (get-buffer "foo.info")))
234 (write-file "foo.texi")
238 (re-search-forward "\n\\|\\([\\]f[a-zA-Z]\\)" nil t
)
239 (list (match-beginning 0) (match-beginning 1) (match-beginning 2)))
241 (defun list-current-line ()
243 (let (ans at-end
(beg (point)))
246 (re-search-forward "\n\\|\\([\\]f[a-zA-Z]\\)" nil t
)
247 (if (match-beginning 1) (replace-match "")
252 (re-search-forward "[\t\n]" nil t
)
253 (let ((x (buffer-substring beg
(- (point) 1))))
255 (setq ans
(cons x ans
))))
258 (setq at-end
(equal (char-after (- (point) 1)) ?
\n)))
264 items
(vec (make-vector 10 0)) i
(tot 0) surplus
)
265 (while (not (looking-at "[.][LDI]"))
266 (cond ((looking-at "[.]")(forward-line 1))
268 (setq items
(cons (list-current-line) items
))
269 (let ((tem (car items
))
272 (aset vec i
(max (real-length (car tem
)) (aref vec i
)))
274 (setq tem
(cdr tem
)))
276 ; (message "%s" (list beg (point)))
279 (delete-region beg
(point))
283 (setq items
(nreverse items
))
285 (while (< i
(length vec
)) (setq tot
(+ (aref vec i
) tot
)) (setq i
(+ i
1)))
286 (setq surplus
(/ (- 70 tot
) (+ 1 (length (car items
)))))
288 (setq tem
(car items
))
293 (insert (tex-center (car tem
) (+ (aref vec i
) surplus
) 'left
294 (real-length (car tem
))))
295 (setq tem
(cdr tem
)) (setq i
(+ i
1)))
297 (setq items
(cdr items
)))
307 (defun real-length (item)
308 (let* ((n (length item
)) (m (- n
1)) (start 0))
309 (while (setq start
(string-match "[\\]f" item start
))
311 (if (< start m
) (setq start
(+ start
1))))
316 (goto-char (point-min))
317 (while (re-search-forward "^[.]TP" nil t
)
319 (insert "\n@table @asis\n")
321 (re-search-forward "^[.]\\(LP\\|BE\\|SH\\)" nil t
)
323 (insert "@end table\n")
326 (goto-char (point-min))
327 (while (re-search-forward "^[.]nf" nil t
)
328 (forward-line 1) (beginning-of-line)
329 (while (not (looking-at "[.]fi"))
330 (insert "@w{" ) (end-of-line) (insert "}")
331 (forward-line 1) (beginning-of-line))))
333 (defun add-keywords ()
334 (let ((tem tk-control-options
)x lis l y
)
338 (setq x
(symbol-name (car l
)))
339 (setq lis
(car (cdr l
)))
341 (cond ((atom lis
) (setq lis nil
))
342 (t (setq y
(symbol-name (car lis
)))
343 (do-replace (list (list (concat x
" "y
"")
346 (setq lis
(cdr lis
))))))
348 (setq tk-control-options
352 (place pathName
(-anchor -bordermode -height
353 -in -relheight -relwidth
354 -relx -rely -width -x -y
))
356 ;(TKVARS "invalid command name \"tkvars\"")
357 (winfo (atom atomname cells children class containing
358 depth exists fpixels geometry height id
359 interps ismapped name parent pathname pixels
360 reqheight reqwidth rgb rootx rooty screen
361 screencells screendepth screenheight screenmmheight
362 screenmmwidth screenvisual screenwidth toplevel
363 visual vrootheight vrootwidth vrootx vrooty width x y
) )
364 (focus (default none
) )
365 (option (add clear get readfile
))
368 (tkwait ( variable visible window
) )
369 (wm (aspect client command deiconify focusmodel frame geometry grid group iconbitmap iconify iconmask iconname iconposition iconwindow maxsize minsize overrideredirect positionfrom protocol sizefrom state title trace transient withdraw
))
371 (grab (current release set status
))
372 (pack window
(-after, -anchor
, -before
, -expand
, -fill
, -in
, -ipadx
, -ipady
, -padx
, -pady
, -side
) argggg
)
373 (selection (clear get handle own
))
378 (setq tk-widget-options
380 (button (activate configure deactivate flash invoke
))
381 (listbox ( configure curselection delete get insert nearest
382 scan select size xview yview
))
383 (scale ( configure get set
))
384 (canvas ( addtag bbox bind canvasx canvasy configure coords
385 create dchars delete dtag find focus gettags
386 icursor index insert itemconfigure lower move
387 postscript raise scale scan select type xview yview
))
388 (menu ( activate add configure delete disable enable
389 entryconfigure index invoke post unpost yposition
))
390 (scrollbar ( configure get set
))
392 ( activate configure deactivate deselect flash
393 invoke select toggle
))
395 ( activate configure deactivate
))
396 (text ( compare configure debug delete get index insert
397 mark scan tag yview
))
398 (entry ( configure delete get icursor index insert scan select view
))
399 (message ( configure
))
403 ( activate configure deactivate deselect flash invoke select
))
404 (toplevel ( configure
))
407 (setq manual-sections
408 '(after bind button canvas checkbutton destroy entry exit focus foo frame grab label lbSingSel listbox lower menu menubar menubutton message option options pack-old pack place radiobutton raise scale scrollbar selection send text tk tkerror tkvars tkwait toplevel update winfo wm
))
410 ;(setq widgets (sort (mapcar 'car tk-widget-options) 'string-lessp))
411 ;(let ((m manual-sections)(tem widgets)) (while tem (setq manual-sections (delete (car tem) manual-sections))(setq tem (cdr tem))))