Mercurial > emacs
comparison lisp/calc/calc-lang.el @ 90099:fa9654493afb
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-10
Merge from emacs--cvs-trunk--0
Patches applied:
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-59
- miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-68
Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Wed, 02 Feb 2005 01:54:00 +0000 |
parents | f2ebccfa87d4 502b609847e8 |
children | 72cf6261961e |
comparison
equal
deleted
inserted
replaced
90098:59a447f7a6ba | 90099:fa9654493afb |
---|---|
34 ;;; Alternate entry/display languages. | 34 ;;; Alternate entry/display languages. |
35 | 35 |
36 (defun calc-set-language (lang &optional option no-refresh) | 36 (defun calc-set-language (lang &optional option no-refresh) |
37 (setq math-expr-opers (or (get lang 'math-oper-table) math-standard-opers) | 37 (setq math-expr-opers (or (get lang 'math-oper-table) math-standard-opers) |
38 math-expr-function-mapping (get lang 'math-function-table) | 38 math-expr-function-mapping (get lang 'math-function-table) |
39 math-expr-special-function-mapping (get lang 'math-special-function-table) | |
39 math-expr-variable-mapping (get lang 'math-variable-table) | 40 math-expr-variable-mapping (get lang 'math-variable-table) |
40 calc-language-input-filter (get lang 'math-input-filter) | 41 calc-language-input-filter (get lang 'math-input-filter) |
41 calc-language-output-filter (get lang 'math-output-filter) | 42 calc-language-output-filter (get lang 'math-output-filter) |
42 calc-vector-brackets (or (get lang 'math-vector-brackets) "[]") | 43 calc-vector-brackets (or (get lang 'math-vector-brackets) "[]") |
43 calc-complex-format (get lang 'math-complex-format) | 44 calc-complex-format (get lang 'math-complex-format) |
293 (message (if (and n (/= n 0)) | 294 (message (if (and n (/= n 0)) |
294 (if (> n 0) | 295 (if (> n 0) |
295 "TeX language mode with \\hbox{func}(\\hbox{var})" | 296 "TeX language mode with \\hbox{func}(\\hbox{var})" |
296 "TeX language mode with \\func{\\hbox{var}}") | 297 "TeX language mode with \\func{\\hbox{var}}") |
297 "TeX language mode")))) | 298 "TeX language mode")))) |
299 | |
300 (defun calc-latex-language (n) | |
301 (interactive "P") | |
302 (calc-wrapper | |
303 (and n (setq n (prefix-numeric-value n))) | |
304 (calc-set-language 'latex n) | |
305 (cond ((not n) | |
306 (message "LaTeX language mode")) | |
307 ((= n 0) | |
308 (message "LaTeX language mode with multiline matrices")) | |
309 ((= n 1) | |
310 (message "LaTeX language mode with \\text{func}(\\text{var})")) | |
311 ((> n 1) | |
312 (message | |
313 "LaTeX language mode with \\text{func}(\\text{var}) and multiline matrices")) | |
314 ((= n -1) | |
315 (message "LaTeX language mode with \\func(\\text{var})")) | |
316 ((< n -1) | |
317 (message | |
318 "LaTeX language mode with \\func(\\text{var}) and multiline matrices"))))) | |
298 | 319 |
299 (put 'tex 'math-oper-table | 320 (put 'tex 'math-oper-table |
300 '( ( "u+" ident -1 1000 ) | 321 '( ( "u+" ident -1 1000 ) |
301 ( "u-" neg -1 1000 ) | 322 ( "u-" neg -1 1000 ) |
302 ( "\\hat" calcFunc-hat -1 950 ) | 323 ( "\\hat" calcFunc-hat -1 950 ) |
404 (setq str (concat (substring str 0 (1+ (match-beginning 0))) | 425 (setq str (concat (substring str 0 (1+ (match-beginning 0))) |
405 (substring str (1- (match-end 0)))))) | 426 (substring str (1- (match-end 0)))))) |
406 str) | 427 str) |
407 (put 'tex 'math-input-filter 'math-tex-input-filter) | 428 (put 'tex 'math-input-filter 'math-tex-input-filter) |
408 | 429 |
430 (put 'latex 'math-oper-table | |
431 (append (get 'tex 'math-oper-table) | |
432 '(( "\\Hat" calcFunc-Hat -1 950 ) | |
433 ( "\\Check" calcFunc-Check -1 950 ) | |
434 ( "\\Tilde" calcFunc-Tilde -1 950 ) | |
435 ( "\\Acute" calcFunc-Acute -1 950 ) | |
436 ( "\\Grave" calcFunc-Grave -1 950 ) | |
437 ( "\\Dot" calcFunc-Dot -1 950 ) | |
438 ( "\\Ddot" calcFunc-Dotdot -1 950 ) | |
439 ( "\\Breve" calcFunc-Breve -1 950 ) | |
440 ( "\\Bar" calcFunc-Bar -1 950 ) | |
441 ( "\\Vec" calcFunc-VEC -1 950 ) | |
442 ( "\\dddot" calcFunc-dddot -1 950 ) | |
443 ( "\\ddddot" calcFunc-ddddot -1 950 ) | |
444 ( "\div" / 170 171 ) | |
445 ( "\\le" calcFunc-leq 160 161 ) | |
446 ( "\\leqq" calcFunc-leq 160 161 ) | |
447 ( "\\leqsland" calcFunc-leq 160 161 ) | |
448 ( "\\ge" calcFunc-geq 160 161 ) | |
449 ( "\\geqq" calcFunc-geq 160 161 ) | |
450 ( "\\geqslant" calcFunc-geq 160 161 ) | |
451 ( "=" calcFunc-eq 160 161 ) | |
452 ( "\\neq" calcFunc-neq 160 161 ) | |
453 ( "\\ne" calcFunc-neq 160 161 ) | |
454 ( "\\lnot" calcFunc-lnot -1 121 ) | |
455 ( "\\land" calcFunc-land 110 111 ) | |
456 ( "\\lor" calcFunc-lor 100 101 ) | |
457 ( "?" (math-read-if) 91 90 ) | |
458 ( "!!!" calcFunc-pnot -1 85 ) | |
459 ( "&&&" calcFunc-pand 80 81 ) | |
460 ( "|||" calcFunc-por 75 76 ) | |
461 ( "\\gets" calcFunc-assign 51 50 ) | |
462 ( ":=" calcFunc-assign 51 50 ) | |
463 ( "::" calcFunc-condition 45 46 ) | |
464 ( "\\to" calcFunc-evalto 40 41 ) | |
465 ( "\\to" calcFunc-evalto 40 -1 ) | |
466 ( "=>" calcFunc-evalto 40 41 ) | |
467 ( "=>" calcFunc-evalto 40 -1 )))) | |
468 | |
469 (put 'latex 'math-function-table | |
470 (append | |
471 (get 'tex 'math-function-table) | |
472 '(( \\frac . (math-latex-parse-frac /)) | |
473 ( \\tfrac . (math-latex-parse-frac /)) | |
474 ( \\dfrac . (math-latex-parse-frac /)) | |
475 ( \\binom . (math-latex-parse-frac calcFunc-choose)) | |
476 ( \\tbinom . (math-latex-parse-frac calcFunc-choose)) | |
477 ( \\dbinom . (math-latex-parse-frac calcFunc-choose)) | |
478 ( \\phi . calcFunc-totient ) | |
479 ( \\mu . calcFunc-moebius )))) | |
480 | |
481 (put 'latex 'math-special-function-table | |
482 '((/ . (math-latex-print-frac "\\frac")) | |
483 (calcFunc-choose . (math-latex-print-frac "\\binom")))) | |
484 | |
485 (put 'latex 'math-variable-table | |
486 (get 'tex 'math-variable-table)) | |
487 | |
488 (put 'latex 'math-complex-format 'i) | |
489 | |
490 (defun math-latex-parse-frac (f val) | |
491 (let (numer denom) | |
492 (setq args (math-read-expr-list)) | |
493 (math-read-token) | |
494 (setq margs (math-read-factor)) | |
495 (list (nth 2 f) (car args) margs))) | |
496 | |
497 (defun math-latex-print-frac (a fn) | |
498 (list 'horiz (nth 1 fn) "{" (math-compose-expr (nth 1 a) -1) | |
499 "}{" | |
500 (math-compose-expr (nth 2 a) -1) | |
501 "}")) | |
502 | |
503 (put 'latex 'math-input-filter 'math-tex-input-filter) | |
409 | 504 |
410 (defun calc-eqn-language (n) | 505 (defun calc-eqn-language (n) |
411 (interactive "P") | 506 (interactive "P") |
412 (calc-wrapper | 507 (calc-wrapper |
413 (calc-set-language 'eqn) | 508 (calc-set-language 'eqn) |