1 ;(find-file "/softs/maxima/doc/DOC")
11 ("Function Definition")
30 ("Matrices and Linear Algebra")
31 ("Runtime Environment")
32 ("Miscellaneous Options")
33 ("Rules and Patterns")
36 ("Differential Equations")
48 (defvar chapter-selected nil
)
49 (defvar doc-dir
"/home/wfs/max-doc")
50 (defun name-of-file (tem) (substring tem
0 (string-match " " tem
)))
51 (defun get-chapter (prompt &optional type
)
52 (let ((tem (completing-read prompt chaps nil t
)))
53 (setq chapter-selected tem
)
54 (switch-to-buffer doc-buffer
)
55 (goto-char begin-expr
)
58 (concat doc-dir
"/" (name-of-file tem
) ".texi"))
59 (goto-char (point-min))
60 (cond ((> (point-max) 5)
61 (or (search-forward "@c end concepts" nil t
)
63 (search-forward "@chapter")
65 (insert "@c end concepts "tem
"\n")))))
66 (goto-char (point-max))
68 (insert "@node "tem
"\n"
70 "@c end concepts "tem
"\n"
72 (cond ((equal type
"section")
73 (goto-char (point-min))
74 (search-forward "@c end concepts" )
83 (defun do-maxima-texi()
85 (find-file "maxima.texi")
86 (goto-char (point-min))
87 (search-forward "@c includes")
88 (delete-region (point) (progn (search-forward "end includes")
93 (insert "\n@include " (name-of-file (car (car tem
))) ".texi\n")
95 (insert "\n@c end includes\n"))
100 (defvar begin-expr nil
)
101 (defvar end-expr nil
)
105 (buffer-substring (point)
106 (progn (search-forward "\x1f\n" nil t
)
108 (setq end-expr
(point))))))
109 (defvar doc-buffer nil
)
111 (defvar first-time nil
)
114 (setq doc-buffer
(current-buffer))
115 (let ((completion-ignore-case t
))
116 (while (search-forward "\x1f\n")
117 (setq begin-expr
(point))
122 (cond ((looking-at "[A-Z0-9_a-z%]+(")
123 (let* ((fun (buffer-substring (point) (- (match-end 0) 1)))
124 (arg-begin (- (match-end 0) 1))
125 (args (buffer-substring arg-begin
126 (progn (forward-sexp 1)
128 (description (rest-of-it)))
130 (get-chapter (concat "Fun: " fun
" args: " args
": "))
131 (insert "@defun " fun
" " args
"\n" description
133 ((looking-at "[A-Z0-9_a-z%]+ default:")
134 (let* ((var (buffer-substring (point)
135 (progn (forward-sexp 1)
137 (description (rest-of-it)))
139 (get-chapter (concat "Var: " var
": "))
140 (insert "@defvar " var
"\n" description
141 "\n@end defvar\n"))))
144 (let* ((var (buffer-substring (point)
145 (progn (forward-sexp 1)
147 (description (rest-of-it))
150 (let* ((com (completing-read
151 (concat "@ command for `"var
"': ")
167 (get-chapter "chap: " com
)
168 (cond ((equal com
"deffn")
169 (cond ((equal chapter-selected
"Operators")
170 (setq cat
" operator" ))))
173 (setq cat
" declaration"))
174 ((equal com
"property")
176 (setq cat
" property"))
179 (cond ((and (equal cat
"")
180 (member com
'("deffn" "defvr")))
181 (let ((tem(completing-read
182 (concat com
" type:")
193 (cond ((string-match " " tem
)
194 (setq tem
(concat "{" tem
"}"))))
199 " "var
"\n" description
)
200 (or (member com
'("section"))
201 (insert "\n@end " com
"\n"))))))
205 (switch-to-buffer doc-buffer
)
208 (write-region (format "(setq end-expr %d)" end-expr
)
209 nil
(concat doc-dir
"/pos.el"))
212 ;(setq tags-loop-operate '(fix-defun))
213 ;(setq tags-loop-scan '(fix-defun))
214 ;(setq tags-loop-scan '(progn (save-excursion (search-forward "@defun" nil t))))
215 (setq tags-loop-scan
't
)
218 (defun my-add-node ()
220 (cond ((re-search-forward "\n@def" nil t
)
223 (cond ((not (looking-at "@node"))
224 (progn (forward-line 1)
226 (insert "@node\n")))))
232 (global-set-key "\M-]" 'example-region
)
233 (defvar after
(make-marker))
234 (defun example-region ()
236 (goto-char (region-end))
237 (insert "@end example\n")
238 (set-marker after
(point))
239 (goto-char (region-beginning))
240 (insert "@example\n")
242 (set-marker after nil
)
247 (defun check-example()
249 (let ((end (- (point-max) 5))
251 (while (and (< (point) end
))
252 (cond ((looking-at "@example")
255 (if (looking-at "@end example")
256 (setq in-example nil
)))
261 (beginning-of-line))))
268 (defun my-add-example ()
271 (cond ((re-search-forward "\n(C[0-9]" nil t
)
275 (cond ((not (looking-at "@example"))
277 (insert "@example\n")
278 (search-forward "@end" nil t
)
279 (re-search-backward "\n([CD]" nil t
)
281 (while (looking-at "[ \t\n]")
283 (insert "\n@end example\n")
294 (defun my-fix-node ()
296 (cond ((re-search-forward "\n@node" nil t
)
298 (cond ((looking-at "[ \t]*\n")
305 (setq item
(buffer-substring (point) end
))
307 (insert " " item
)))))
313 (defvar my-operate-remaining-files nil
)
314 (defvar my-operate-current-file nil
)
315 (defvar my-operate-function nil
)
318 (defun my-operate-setup (lis func
)
319 "func returns nil when done with this file"
320 (setq my-operate-current-file nil
)
321 (setq my-operate-function func
)
322 (setq my-operate-on-remaining-files lis
))
324 (defun do-all-files (func)
325 (my-operate-setup (directory-files "/home/wfs/max-doc/" t
".*[.]texi$" ) func
))
328 (global-set-key "\M-[" 'my-operate-continue
)
330 (do-all-files '(lambda () (while (and (search-forward "@def" nil t
)
331 (not (save-excursion (forward-line -
1)
332 (looking-at "@unnum"))))
334 (insert "@unnumberedsec phony\n")
338 ;(do-all-files 'my-add-node)
339 ;(do-all-files 'my-fix-node)
340 ;(do-all-files 'my-add-example)
341 ;(texinfo-multiple-files-update "maxima.texi" t t)
342 ;(do-all-files 'insert-section-definitions)
345 (cond ((search-forward "\n@node " nil t
)
346 (cond ((save-excursion (forward-line 1)
347 (looking-at "@c @unnumber"))
356 (defun insert-section-definitions ()
358 (cond ((search-forward "@chapter " nil t
)
359 (let ((chap (buffer-substring (point) (progn (end-of-line) (point)))))
361 (cond ((not (looking-at "@c end concepts"))
362 (insert "@node Introduction to " chap
363 "\n@section Introduction to " chap
"\n")))
364 (search-forward "@c end concepts")
366 (insert "@node Definitions for " chap
"\n@section Definitions for "
377 ;(setq texinfo-section-types-regexp "section\\|unnumberedsec\\|heading")
379 ;(setq texinfo-subsection-level-regexp "subsection\\|unnumberedsubsec\\|subheading\\|appendixsubsec")
381 (defun my-operate-continue ()
383 (while my-operate-on-remaining-files
384 (cond (my-operate-current-file)
385 (t (setq my-operate-current-file
(car my-operate-on-remaining-files
)
386 my-operate-on-remaining-files
(cdr my-operate-on-remaining-files
))
387 (find-file my-operate-current-file
) (goto-char (point-min))))
388 (find-file my-operate-current-file
)
389 (message (format "operating on %s" my-operate-current-file
))
390 (while (funcall my-operate-function
))
392 (setq my-operate-current-file nil
)
399 (re-search-forward "(C[0-9]" nil t
)
401 (switch-to-buffer (current-buffer))
403 (cond ((y-or-n-p "Do this one?")
404 (insert "@example\n")
405 (progn (search-forward "@" nil t
)
406 (re-search-backward "([CD][0-9]" nil t
)
408 (insert "@end example\n"))))
409 ;(y-or-n-p "continue? ")
412 ;(setq tags-loop-scan '(fix-defun))
416 (cond ((search-forward "@defun" nil t
)
417 (switch-to-buffer (current-buffer))
420 (cond ((looking-at "[ ]*\n(")
421 (kill-line) (insert " ")
424 (while (looking-at "[ ---]")(delete-char 1))
434 (cond ((search-forward "@defun" nil t
)
435 (switch-to-buffer (current-buffer))
438 (cond ((looking-at "[ ]*\n(")
440 (kill-line) (insert " ")
443 (while (looking-at "[ ---]")(delete-char 1))
451 (cond ((search-forward "@defun" nil t
)
452 (switch-to-buffer (current-buffer))
455 (cond ((looking-at "[ ]*\n ")
457 (kill-line) (insert " ")
460 (while (looking-at "[ ---]")(delete-char 1))