Function: math-read-preprocess-string
math-read-preprocess-string is an autoloaded and byte-compiled
function defined in calc-aent.el.gz.
Signature
(math-read-preprocess-string STR)
Documentation
Replace some substrings of STR by Calc equivalents.
Source Code
;; Defined in /usr/src/emacs/lisp/calc/calc-aent.el.gz
;;;###autoload
(defun math-read-preprocess-string (str)
"Replace some substrings of STR by Calc equivalents."
(unless (and (eq (nth 1 math--read-preprocess-re-cache)
math-read-replacement-list)
(eq (nth 2 math--read-preprocess-re-cache)
math-read-superscripts)
(eq (nth 3 math--read-preprocess-re-cache)
math-read-subscripts))
;; Cache invalid, recompute.
(setq math--read-preprocess-re-cache
(list (rx-to-string
`(or (or (+ (in ,math-read-superscripts))
(group (+ (in ,math-read-subscripts))))
(group (or ,@(mapcar #'car math-read-replacement-list))))
t)
math-read-replacement-list
math-read-superscripts
math-read-subscripts)))
(replace-regexp-in-string
(nth 0 math--read-preprocess-re-cache)
(lambda (s)
(if (match-beginning 2)
(cadr (assoc s math-read-replacement-list)) ; not super/subscript
(concat (if (match-beginning 1) "_" "^")
"("
(mapconcat (lambda (c)
(cadr (assoc (char-to-string c)
math-read-replacement-list)))
s)
")")))
str t))