Function: math-comp-to-string-flat-term
math-comp-to-string-flat-term is a byte-compiled function defined in
calccomp.el.gz.
Signature
(math-comp-to-string-flat-term C)
Source Code
;; Defined in /usr/src/emacs/lisp/calc/calccomp.el.gz
(defun math-comp-to-string-flat-term (c)
(cond ((not (consp c))
(if math-comp-highlight
(setq c (math-comp-highlight-string c)))
(setq math-comp-word (if (= (length math-comp-word) 0) c
(concat math-comp-word c))
math-comp-pos (+ math-comp-pos (length c))))
((eq (car c) 'horiz)
(while (setq c (cdr c))
(math-comp-to-string-flat-term (car c))))
((eq (car c) 'set)
(if (nth 1 c)
(progn
(setq math-comp-level (1+ math-comp-level))
(if (>= math-comp-level (length math-comp-buf-string))
(setq math-comp-buf-string (vconcat math-comp-buf-string
math-comp-buf-string)
math-comp-buf-margin (vconcat math-comp-buf-margin
math-comp-buf-margin)
math-comp-buf-level (vconcat math-comp-buf-level
math-comp-buf-level)))
(aset math-comp-buf-string math-comp-level "")
(aset math-comp-buf-margin math-comp-level (+ math-comp-pos
(or (nth 2 c) 0)))
(aset math-comp-buf-level math-comp-level (nth 1 c)))))
((eq (car c) 'break)
(if (not calc-line-breaking)
(setq math-comp-buf (concat math-comp-buf math-comp-word)
math-comp-word "")
(let ((i 0) str)
(if (and (> math-comp-pos math-comp-full-width)
(progn
(while (progn
(setq str (aref math-comp-buf-string i))
(and (= (length str) 0) (< i math-comp-level)))
(setq i (1+ i)))
(or (> (length str) 0) (> (length math-comp-buf) 0))))
(let ((prefix "") mrg wid)
(setq mrg (aref math-comp-buf-margin i))
(if (> mrg 12) ; indenting too far, go back to far left
(setq mrg (if calc-line-numbering 5 1)))
(setq wid (+ (length str) math-comp-margin))
(and (> (length str) 0) (= (aref str 0) ? )
(> (length math-comp-buf) 0)
(let ((k (length math-comp-buf)))
(while (not (= (aref math-comp-buf (setq k (1- k))) ?\n)))
(aset math-comp-buf k ? )
(if (and (< (1+ k) (length math-comp-buf))
(= (aref math-comp-buf (1+ k)) ? ))
(progn
(aset math-comp-buf (1+ k) ?\n)
(setq prefix " "))
(setq prefix "\n"))))
(setq math-comp-buf (concat math-comp-buf prefix str "\n"
(make-string mrg ? ))
math-comp-pos (+ math-comp-pos (- mrg wid))
math-comp-margin mrg)
(aset math-comp-buf-string i "")
(while (<= (setq i (1+ i)) math-comp-level)
(if (> (aref math-comp-buf-margin i) wid)
(aset math-comp-buf-margin i
(+ (aref math-comp-buf-margin i)
(- mrg wid))))))))
(if (and (= (nth 1 c) (aref math-comp-buf-level math-comp-level))
(< math-comp-pos (+ (aref math-comp-buf-margin math-comp-level) 2)))
() ; avoid stupid breaks, e.g., "1 +\n really_long_expr"
(let ((str (aref math-comp-buf-string math-comp-level)))
(setq str (if (= (length str) 0)
math-comp-word
(concat str math-comp-word))
math-comp-word "")
(while (< (nth 1 c) (aref math-comp-buf-level math-comp-level))
(setq math-comp-level (1- math-comp-level))
(or (= (length (aref math-comp-buf-string math-comp-level)) 0)
(setq str (concat (aref math-comp-buf-string math-comp-level)
str))))
(aset math-comp-buf-string math-comp-level str)))))
((eq (car c) 'tag)
(cond ((eq (nth 1 c) math-comp-selected)
(let ((math-comp-highlight (not calc-show-selections)))
(math-comp-to-string-flat-term (nth 2 c))))
((eq (nth 1 c) t)
(let ((math-comp-highlight nil))
(math-comp-to-string-flat-term (nth 2 c))))
(t (math-comp-to-string-flat-term (nth 2 c)))))
(t (math-comp-to-string-flat-term (nth 2 c)))))