Improve the translation of notequal
[maxima.git] / archive / info / fix-maxima.el
blobe2e1431223d9f6d579e409b98f22b1ec9a11c827
1 ;(find-file "/softs/maxima/doc/DOC")
2 ;(goto-char 15644)
4 (setq chaps
5 '(("Lists")
6 ("Differentiation")
7 ("Integration")
8 ("Polynomials")
9 ("Simplification")
10 ("Expressions")
11 ("Function Definition")
12 ("Input and Output")
13 ("Program Flow")
14 ("Plotting")
15 ("NonCommutative")
16 ("Floating Point")
17 ("Numerical")
18 ("Trigonometric")
19 ("Equations")
20 ("Arrays and Tables")
21 ("Series")
23 ("Symmetries")
24 ("Groups")
25 ("Operators")
26 ("Constants")
27 ("Special Functions")
28 ("Command Line")
29 ("Contexts")
30 ("Matrices and Linear Algebra")
31 ("Runtime Environment")
32 ("Miscellaneous Options")
33 ("Rules and Patterns")
34 ("Number Theory")
35 ("Help")
36 ("Differential Equations")
37 ("xrefs")
38 ("Statistics")
39 ("Limits")
40 ("Logarithms")
41 ("Debugging")
42 ("Affine")
43 ("Tensor")
44 ("Ctensor")
45 ("None")
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)
56 (other-window 1)
57 (find-file
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)
62 (progn
63 (search-forward "@chapter")
64 (forward-line 1)
65 (insert "@c end concepts "tem "\n")))))
66 (goto-char (point-max))
67 (cond ((< (point) 5)
68 (insert "@node "tem "\n"
69 "@chapter "tem "\n"
70 "@c end concepts "tem "\n"
71 )))
72 (cond ((equal type "section")
73 (goto-char (point-min))
74 (search-forward "@c end concepts" )
75 (beginning-of-line)
76 (insert "\n")
77 (forward-line -1)
83 (defun do-maxima-texi()
84 (interactive)
85 (find-file "maxima.texi")
86 (goto-char (point-min))
87 (search-forward "@c includes")
88 (delete-region (point) (progn (search-forward "end includes")
89 (point)))
90 (insert "\n")
91 (let ((tem chaps))
92 (while tem
93 (insert "\n@include " (name-of-file (car (car tem))) ".texi\n")
94 (setq tem (cdr tem)))
95 (insert "\n@c end includes\n"))
96 (save-buffer)
100 (defvar begin-expr nil)
101 (defvar end-expr nil)
103 (defun rest-of-it ()
104 (save-excursion
105 (buffer-substring (point)
106 (progn (search-forward "\x1f\n" nil t)
107 (forward-char -2)
108 (setq end-expr (point))))))
109 (defvar doc-buffer nil)
111 (defvar first-time nil)
112 (defun doit()
113 (interactive)
114 (setq doc-buffer (current-buffer))
115 (let ((completion-ignore-case t))
116 (while (search-forward "\x1f\n")
117 (setq begin-expr (point))
118 ; (sit-for 0 2)
119 (recenter 1)
120 ; (sit-for 1 2)
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)
127 (point))))
128 (description (rest-of-it)))
129 (progn
130 (get-chapter (concat "Fun: " fun " args: " args ": "))
131 (insert "@defun " fun " " args "\n" description
132 "\n@end defun\n"))))
133 ((looking-at "[A-Z0-9_a-z%]+ default:")
134 (let* ((var (buffer-substring (point)
135 (progn (forward-sexp 1)
136 (point))))
137 (description (rest-of-it)))
138 (progn
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)
146 (point))))
147 (description (rest-of-it))
148 (cat "")
150 (let* ((com (completing-read
151 (concat "@ command for `"var"': ")
152 '(("defun")
153 ("defvar")
154 ("defopt")
155 ("deffn")
156 ("defmac")
157 ("defvr")
158 ("decl")
159 ("property")
161 ("section")
163 nil t
166 (progn
167 (get-chapter "chap: " com)
168 (cond ((equal com "deffn")
169 (cond ((equal chapter-selected "Operators")
170 (setq cat " operator" ))))
171 ((equal com "decl")
172 (setq com "defvr")
173 (setq cat " declaration"))
174 ((equal com "property")
175 (setq com "defvr")
176 (setq cat " property"))
179 (cond ((and (equal cat "")
180 (member com '("deffn" "defvr")))
181 (let ((tem(completing-read
182 (concat com " type:")
183 '(("operator")
184 ("constant")
185 ("keyword")
186 ("special operator")
187 ("special symbol")
188 ("declaration")
191 nil t
193 (cond ((string-match " " tem)
194 (setq tem (concat "{" tem "}"))))
195 (setq cat
196 (concat " " tem))
198 (insert "@" com cat
199 " "var"\n" description)
200 (or (member com '("section"))
201 (insert "\n@end " com"\n"))))))
204 (other-window 1)
205 (switch-to-buffer doc-buffer)
206 (goto-char end-expr)
207 ; (sit-for 1)
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 ()
219 (interactive)
220 (cond ((re-search-forward "\n@def" nil t)
221 (save-excursion
222 (forward-line -1)
223 (cond ((not (looking-at "@node"))
224 (progn (forward-line 1)
225 (beginning-of-line)
226 (insert "@node\n")))))
227 (forward-line 1)
228 ;(y-or-n-p "ok? ")
232 (global-set-key "\M-]" 'example-region)
233 (defvar after (make-marker))
234 (defun example-region ()
235 (interactive)
236 (goto-char (region-end))
237 (insert "@end example\n")
238 (set-marker after (point))
239 (goto-char (region-beginning))
240 (insert "@example\n")
241 (goto-char after)
242 (set-marker after nil)
247 (defun check-example()
248 (forward-line 1)
249 (let ((end (- (point-max) 5))
250 (in-example nil))
251 (while (and (< (point) end))
252 (cond ((looking-at "@example")
253 (setq in-example t))
254 (in-example
255 (if (looking-at "@end example")
256 (setq in-example nil)))
257 ((looking-at " ")
258 (barf))
259 (t nil))
260 (forward-line 1)
261 (beginning-of-line))))
268 (defun my-add-example ()
269 (interactive)
270 (let (beg)
271 (cond ((re-search-forward "\n(C[0-9]" nil t)
272 (beginning-of-line)
273 (setq beg (point))
274 (forward-line -1)
275 (cond ((not (looking-at "@example"))
276 (goto-char beg)
277 (insert "@example\n")
278 (search-forward "@end" nil t)
279 (re-search-backward "\n([CD]" nil t)
280 (forward-line 2)
281 (while (looking-at "[ \t\n]")
282 (forward-line 1))
283 (insert "\n@end example\n")
285 (t (forward-line 2))
287 ;(recenter 1)
288 (barf)
289 ;(y-or-n-p "next")
290 ))))
294 (defun my-fix-node ()
295 (interactive)
296 (cond ((re-search-forward "\n@node" nil t)
297 (save-excursion
298 (cond ((looking-at "[ \t]*\n")
299 (let ((pt (point))
300 beg end
302 (forward-sexp 2)
303 (setq end (point))
304 (forward-sexp -1)
305 (setq item (buffer-substring (point) end))
306 (goto-char pt)
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"))))
333 ( beginning-of-line)
334 (insert "@unnumberedsec phony\n")
335 (forward-line 2)
336 )))
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)
343 (do-all-files 'foo)
344 (defun foo ()
345 (cond ((search-forward "\n@node " nil t)
346 (cond ((save-excursion (forward-line 1)
347 (looking-at "@c @unnumber"))
348 (beginning-of-line)
349 (insert "@c ")))
350 (forward-line 1)
356 (defun insert-section-definitions ()
357 (interactive)
358 (cond ((search-forward "@chapter " nil t )
359 (let ((chap (buffer-substring (point) (progn (end-of-line) (point)))))
360 (forward-line 1)
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")
365 (forward-line 1)
366 (insert "@node Definitions for " chap "\n@section Definitions for "
367 chap "\n")
368 nil))))
377 ;(setq texinfo-section-types-regexp "section\\|unnumberedsec\\|heading")
379 ;(setq texinfo-subsection-level-regexp "subsection\\|unnumberedsubsec\\|subheading\\|appendixsubsec")
381 (defun my-operate-continue ()
382 (interactive)
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)
394 (message "Done")
398 (defun try ()
399 (re-search-forward "(C[0-9]" nil t)
400 (beginning-of-line)
401 (switch-to-buffer (current-buffer))
402 (recenter 1)
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)
407 (forward-line 1)
408 (insert "@end example\n"))))
409 ;(y-or-n-p "continue? ")
412 ;(setq tags-loop-scan '(fix-defun))
414 (defun fix-defun ()
415 (interactive)
416 (cond ((search-forward "@defun" nil t)
417 (switch-to-buffer (current-buffer))
418 (recenter 1)
419 (forward-sexp 1)
420 (cond ((looking-at "[ ]*\n(")
421 (kill-line) (insert " ")
422 (forward-sexp 1)
423 (insert "\n")
424 (while (looking-at "[ ---]")(delete-char 1))
426 ;(barf)
432 (defun fix-defun ()
433 (interactive)
434 (cond ((search-forward "@defun" nil t)
435 (switch-to-buffer (current-buffer))
436 (recenter 1)
437 (forward-sexp 1)
438 (cond ((looking-at "[ ]*\n(")
439 ;(barf)
440 (kill-line) (insert " ")
441 (forward-sexp 1)
442 (insert "\n")
443 (while (looking-at "[ ---]")(delete-char 1))
444 ;(barf)
447 (t nil)))
449 (defun fix-defun ()
450 (interactive)
451 (cond ((search-forward "@defun" nil t)
452 (switch-to-buffer (current-buffer))
453 (recenter 1)
454 (forward-sexp 1)
455 (cond ((looking-at "[ ]*\n ")
456 (barf)
457 (kill-line) (insert " ")
458 (forward-sexp 1)
459 (insert "\n")
460 (while (looking-at "[ ---]")(delete-char 1))
461 ;(barf)
463 t)))