diff options
| author | Jay Belanger | 2004-12-08 06:09:20 +0000 |
|---|---|---|
| committer | Jay Belanger | 2004-12-08 06:09:20 +0000 |
| commit | c59d10e073eaa01df6fd12204558fb01a01bb259 (patch) | |
| tree | 41d72651a434e17d990fd72261fa4e2a88dd4051 | |
| parent | 5ff9dafd88f7e86faf3b8ec52a912836ff2c31e9 (diff) | |
| download | emacs-c59d10e073eaa01df6fd12204558fb01a01bb259.tar.gz emacs-c59d10e073eaa01df6fd12204558fb01a01bb259.zip | |
(math-read-replacement-list, math-read-superscripts): Move from
calc-ext.el.
(math-read-preprocess-string): Move from calc-ext.el.
| -rw-r--r-- | lisp/calc/calc-aent.el | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/lisp/calc/calc-aent.el b/lisp/calc/calc-aent.el index 4c62e570349..c062a822e89 100644 --- a/lisp/calc/calc-aent.el +++ b/lisp/calc/calc-aent.el | |||
| @@ -465,6 +465,73 @@ T means abort and give an error message.") | |||
| 465 | 465 | ||
| 466 | ;;; Algebraic expression parsing. [Public] | 466 | ;;; Algebraic expression parsing. [Public] |
| 467 | 467 | ||
| 468 | (defvar math-read-replacement-list | ||
| 469 | '(;; Misc symbols | ||
| 470 | ("±" "+/-") ; plus or minus | ||
| 471 | ("×" "*") ; multiplication sign | ||
| 472 | ("÷" ":") ; division sign | ||
| 473 | ("−" "-") ; subtraction sign | ||
| 474 | ("∕" "/") ; division sign | ||
| 475 | ("∗" "*") ; asterisk multiplication | ||
| 476 | ("∞" "inf") ; infinity symbol | ||
| 477 | ("≤" "<=") | ||
| 478 | ("≥" ">=") | ||
| 479 | ("≦" "<=") | ||
| 480 | ("≧" ">=") | ||
| 481 | ;; fractions | ||
| 482 | ("¼" "(1:4)") ; 1/4 | ||
| 483 | ("½" "(1:2)") ; 1/2 | ||
| 484 | ("¾" "(3:4)") ; 3/4 | ||
| 485 | ("⅓" "(1:3)") ; 1/3 | ||
| 486 | ("⅔" "(2:3)") ; 2/3 | ||
| 487 | ("⅕" "(1:5)") ; 1/5 | ||
| 488 | ("⅖" "(2:5)") ; 2/5 | ||
| 489 | ("⅗" "(3:5)") ; 3/5 | ||
| 490 | ("⅘" "(4:5)") ; 4/5 | ||
| 491 | ("⅙" "(1:6)") ; 1/6 | ||
| 492 | ("⅚" "(5:6)") ; 5/6 | ||
| 493 | ("⅛" "(1:8)") ; 1/8 | ||
| 494 | ("⅜" "(3:8)") ; 3/8 | ||
| 495 | ("⅝" "(5:8)") ; 5/8 | ||
| 496 | ("⅞" "(7:8)") ; 7/8 | ||
| 497 | ("⅟" "1:") ; 1/... | ||
| 498 | ;; superscripts | ||
| 499 | ("⁰" "0") ; 0 | ||
| 500 | ("¹" "1") ; 1 | ||
| 501 | ("²" "2") ; 2 | ||
| 502 | ("³" "3") ; 3 | ||
| 503 | ("⁴" "4") ; 4 | ||
| 504 | ("⁵" "5") ; 5 | ||
| 505 | ("⁶" "6") ; 6 | ||
| 506 | ("⁷" "7") ; 7 | ||
| 507 | ("⁸" "8") ; 8 | ||
| 508 | ("⁹" "9") ; 9 | ||
| 509 | ("⁺" "+") ; + | ||
| 510 | ("⁻" "-") ; - | ||
| 511 | ("⁽" "(") ; ( | ||
| 512 | ("⁾" ")") ; ) | ||
| 513 | ("ⁿ" "n") ; n | ||
| 514 | ("ⁱ" "i")) ; i | ||
| 515 | "A list whose elements (old new) indicate replacements to make | ||
| 516 | in Calc algebraic input.") | ||
| 517 | |||
| 518 | (defvar math-read-superscripts | ||
| 519 | "⁰¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁽⁾ⁿⁱ" ; 0123456789+-()ni | ||
| 520 | "A string consisting of the superscripts allowed by Calc.") | ||
| 521 | |||
| 522 | (defun math-read-preprocess-string (str) | ||
| 523 | "Replace some substrings of STR by Calc equivalents." | ||
| 524 | (setq str | ||
| 525 | (replace-regexp-in-string (concat "[" math-read-superscripts "]+") | ||
| 526 | "^(\\&)" str)) | ||
| 527 | (let ((rep-list math-read-replacement-list)) | ||
| 528 | (while rep-list | ||
| 529 | (setq str | ||
| 530 | (replace-regexp-in-string (nth 0 (car rep-list)) | ||
| 531 | (nth 1 (car rep-list)) str)) | ||
| 532 | (setq rep-list (cdr rep-list)))) | ||
| 533 | str) | ||
| 534 | |||
| 468 | ;; The next few variables are local to math-read-exprs (and math-read-expr | 535 | ;; The next few variables are local to math-read-exprs (and math-read-expr |
| 469 | ;; in calc-ext.el), but are set in functions they call. | 536 | ;; in calc-ext.el), but are set in functions they call. |
| 470 | 537 | ||