1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-23 07:19:15 +00:00

(math-read-replacement-list, math-read-superscripts): Move from

calc-ext.el.
(math-read-preprocess-string): Move from calc-ext.el.
This commit is contained in:
Jay Belanger 2004-12-08 06:09:20 +00:00
parent 5ff9dafd88
commit c59d10e073

View File

@ -465,6 +465,73 @@ T means abort and give an error message.")
;;; Algebraic expression parsing. [Public]
(defvar math-read-replacement-list
'(;; Misc symbols
("±" "+/-") ; plus or minus
("×" "*") ; multiplication sign
("÷" ":") ; division sign
("" "-") ; subtraction sign
("" "/") ; division sign
("" "*") ; asterisk multiplication
("" "inf") ; infinity symbol
("" "<=")
("" ">=")
("" "<=")
("" ">=")
;; fractions
("¼" "(1:4)") ; 1/4
("½" "(1:2)") ; 1/2
("¾" "(3:4)") ; 3/4
("" "(1:3)") ; 1/3
("" "(2:3)") ; 2/3
("" "(1:5)") ; 1/5
("" "(2:5)") ; 2/5
("" "(3:5)") ; 3/5
("" "(4:5)") ; 4/5
("" "(1:6)") ; 1/6
("" "(5:6)") ; 5/6
("" "(1:8)") ; 1/8
("" "(3:8)") ; 3/8
("" "(5:8)") ; 5/8
("" "(7:8)") ; 7/8
("" "1:") ; 1/...
;; superscripts
("" "0") ; 0
("¹" "1") ; 1
("²" "2") ; 2
("³" "3") ; 3
("" "4") ; 4
("" "5") ; 5
("" "6") ; 6
("" "7") ; 7
("" "8") ; 8
("" "9") ; 9
("" "+") ; +
("" "-") ; -
("" "(") ; (
("" ")") ; )
("" "n") ; n
("" "i")) ; i
"A list whose elements (old new) indicate replacements to make
in Calc algebraic input.")
(defvar math-read-superscripts
"⁰¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁽⁾ⁿⁱ" ; 0123456789+-()ni
"A string consisting of the superscripts allowed by Calc.")
(defun math-read-preprocess-string (str)
"Replace some substrings of STR by Calc equivalents."
(setq str
(replace-regexp-in-string (concat "[" math-read-superscripts "]+")
"^(\\&)" str))
(let ((rep-list math-read-replacement-list))
(while rep-list
(setq str
(replace-regexp-in-string (nth 0 (car rep-list))
(nth 1 (car rep-list)) str))
(setq rep-list (cdr rep-list))))
str)
;; The next few variables are local to math-read-exprs (and math-read-expr
;; in calc-ext.el), but are set in functions they call.