Function: math-format-flat-expr-fancy
math-format-flat-expr-fancy is a byte-compiled function defined in
calc-ext.el.gz.
Signature
(math-format-flat-expr-fancy A PREC)
Source Code
;; Defined in /usr/src/emacs/lisp/calc/calc-ext.el.gz
(defun math-format-flat-expr-fancy (a prec)
(cond
((eq (car a) 'incomplete)
(format "<incomplete %s>" (nth 1 a)))
((eq (car a) 'vec)
(if (or calc-full-trail-vectors (not calc-can-abbrev-vectors)
(< (length a) 7))
(concat "[" (math-format-flat-vector (cdr a) ", "
(if (cdr (cdr a)) 0 1000)) "]")
(concat "["
(math-format-flat-expr (nth 1 a) 0) ", "
(math-format-flat-expr (nth 2 a) 0) ", "
(math-format-flat-expr (nth 3 a) 0) ", ..., "
(math-format-flat-expr (nth (1- (length a)) a) 0) "]")))
((eq (car a) 'intv)
(concat (if (memq (nth 1 a) '(0 1)) "(" "[")
(math-format-flat-expr (nth 2 a) 1000)
" .. "
(math-format-flat-expr (nth 3 a) 1000)
(if (memq (nth 1 a) '(0 2)) ")" "]")))
((eq (car a) 'date)
(concat "<" (math-format-date a) ">"))
((and (eq (car a) 'calcFunc-lambda) (> (length a) 2))
(let ((p (cdr a))
(ap calc-arg-values)
(math-format-hash-args (if (= (length a) 3) 1 t)))
(while (and (cdr p) (equal (car p) (car ap)))
(setq p (cdr p) ap (cdr ap)))
(concat "<"
(if (cdr p)
(concat (math-format-flat-vector
(nreverse (cdr (reverse (cdr a)))) ", " 0)
" : ")
"")
(math-format-flat-expr (nth (1- (length a)) a) 0)
">")))
((eq (car a) 'var)
(or (and math-format-hash-args
(let ((p calc-arg-values) (v 1))
(while (and p (not (equal (car p) a)))
(setq p (and (eq math-format-hash-args t) (cdr p))
v (1+ v)))
(and p
(if (eq math-format-hash-args 1)
"#"
(format "#%d" v)))))
(symbol-name (nth 1 a))))
((and (memq (car a) '(calcFunc-string calcFunc-bstring))
(= (length a) 2)
(math-vectorp (nth 1 a))
(math-vector-is-string (nth 1 a)))
(concat (substring (symbol-name (car a)) 9)
"(" (math-vector-to-string (nth 1 a) t) ")"))
(t
(let ((op (math-assq2 (car a) (math-standard-ops))))
(cond ((and op (= (length a) 3))
(if (> prec (min (nth 2 op) (nth 3 op)))
(concat "(" (math-format-flat-expr a 0) ")")
(let ((lhs (math-format-flat-expr (nth 1 a) (nth 2 op)))
(rhs (math-format-flat-expr (nth 2 a) (nth 3 op))))
(setq op (car op))
(if (or (equal op "^") (equal op "_"))
(if (= (aref lhs 0) ?-)
(setq lhs (concat "(" lhs ")")))
(setq op (concat " " op " ")))
(concat lhs op rhs))))
((eq (car a) 'neg)
(concat "-" (math-format-flat-expr (nth 1 a) 1000)))
(t
(concat (math-remove-dashes
(if (string-match "\\`calcFunc-\\([a-zA-Zα-ωΑ-Ω0-9']+\\)\\'"
(symbol-name (car a)))
(math-match-substring (symbol-name (car a)) 1)
(symbol-name (car a))))
"("
(math-format-flat-vector (cdr a) ", " 0)
")")))))))