Mercurial > emacs
comparison lisp/calc/calc-ext.el @ 90066:fb79180b618d
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-78
Merge from emacs--cvs-trunk--0
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-719
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-732
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-733
Update from CVS: man/calc.texi: Fix some TeX definitions.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-734
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-75
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-76
- miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-77
Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Tue, 14 Dec 2004 07:34:55 +0000 |
parents | f2ebccfa87d4 d598b3594142 |
children | cb67264d6096 |
comparison
equal
deleted
inserted
replaced
90065:c26eb15cd14a | 90066:fb79180b618d |
---|---|
2872 | 2872 |
2873 ;;; Expression parsing. | 2873 ;;; Expression parsing. |
2874 | 2874 |
2875 (defvar math-expr-data) | 2875 (defvar math-expr-data) |
2876 | 2876 |
2877 (defvar math-read-replacement-list | |
2878 '(;; Misc symbols | |
2879 ("±" "+/-") ; plus or minus | |
2880 ("×" "*") ; multiplication sign | |
2881 ("÷" ":") ; division sign | |
2882 ("−" "-") ; subtraction sign | |
2883 ("∕" "/") ; division sign | |
2884 ("∗" "*") ; asterisk multiplication | |
2885 ("∞" "inf") ; infinity symbol | |
2886 ("≤" "<=") | |
2887 ("≥" ">=") | |
2888 ("≦" "<=") | |
2889 ("≧" ">=") | |
2890 ;; fractions | |
2891 ("¼" "(1:4)") ; 1/4 | |
2892 ("½" "(1:2)") ; 1/2 | |
2893 ("¾" "(3:4)") ; 3/4 | |
2894 ("⅓" "(1:3)") ; 1/3 | |
2895 ("⅔" "(2:3)") ; 2/3 | |
2896 ("⅕" "(1:5)") ; 1/5 | |
2897 ("⅖" "(2:5)") ; 2/5 | |
2898 ("⅗" "(3:5)") ; 3/5 | |
2899 ("⅘" "(4:5)") ; 4/5 | |
2900 ("⅙" "(1:6)") ; 1/6 | |
2901 ("⅚" "(5:6)") ; 5/6 | |
2902 ("⅛" "(1:8)") ; 1/8 | |
2903 ("⅜" "(3:8)") ; 3/8 | |
2904 ("⅝" "(5:8)") ; 5/8 | |
2905 ("⅞" "(7:8)") ; 7/8 | |
2906 ("⅟" "1:") ; 1/... | |
2907 ;; superscripts | |
2908 ("⁰" "0") ; 0 | |
2909 ("¹" "1") ; 1 | |
2910 ("²" "2") ; 2 | |
2911 ("³" "3") ; 3 | |
2912 ("⁴" "4") ; 4 | |
2913 ("⁵" "5") ; 5 | |
2914 ("⁶" "6") ; 6 | |
2915 ("⁷" "7") ; 7 | |
2916 ("⁸" "8") ; 8 | |
2917 ("⁹" "9") ; 9 | |
2918 ("⁺" "+") ; + | |
2919 ("⁻" "-") ; - | |
2920 ("⁽" "(") ; ( | |
2921 ("⁾" ")") ; ) | |
2922 ("ⁿ" "n") ; n | |
2923 ("ⁱ" "i")) ; i | |
2924 "A list whose elements (old new) indicate replacements to make | |
2925 in Calc algebraic input.") | |
2926 | |
2927 (defvar math-read-superscripts | |
2928 "⁰¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁽⁾ⁿⁱ" ; 0123456789+-()ni | |
2929 "A string consisting of the superscripts allowed by Calc.") | |
2930 | |
2931 (defun math-read-preprocess-string (str) | |
2932 "Replace some substrings of STR by Calc equivalents." | |
2933 (setq str | |
2934 (replace-regexp-in-string (concat "[" math-read-superscripts "]+") | |
2935 "^(\\&)" str)) | |
2936 (let ((rep-list math-read-replacement-list)) | |
2937 (while rep-list | |
2938 (setq str | |
2939 (replace-regexp-in-string (nth 0 (car rep-list)) | |
2940 (nth 1 (car rep-list)) str)) | |
2941 (setq rep-list (cdr rep-list)))) | |
2942 str) | |
2943 | |
2944 (defun math-read-expr (math-exp-str) | 2877 (defun math-read-expr (math-exp-str) |
2945 (let ((math-exp-pos 0) | 2878 (let ((math-exp-pos 0) |
2946 (math-exp-old-pos 0) | 2879 (math-exp-old-pos 0) |
2947 (math-exp-keep-spaces nil) | 2880 (math-exp-keep-spaces nil) |
2948 math-exp-token math-expr-data) | 2881 math-exp-token math-expr-data) |