Mercurial > emacs
comparison lisp/calc/calc-aent.el @ 58843:f3d24ef9bf58
(math-read-replacement-list, math-read-superscripts): Move from
calc-ext.el.
(math-read-preprocess-string): Move from calc-ext.el.
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Wed, 08 Dec 2004 06:09:20 +0000 |
parents | 157fd661769f |
children | d572ad446699 fb79180b618d |
comparison
equal
deleted
inserted
replaced
58842:a26862f74305 | 58843:f3d24ef9bf58 |
---|---|
462 (setq calc-digit-value (minibuffer-contents)) | 462 (setq calc-digit-value (minibuffer-contents)) |
463 (exit-minibuffer)) | 463 (exit-minibuffer)) |
464 | 464 |
465 | 465 |
466 ;;; Algebraic expression parsing. [Public] | 466 ;;; Algebraic expression parsing. [Public] |
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) | |
467 | 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 |
471 (defvar math-exp-pos) | 538 (defvar math-exp-pos) |