Function: math-format-stack-value

math-format-stack-value is a byte-compiled function defined in calc.el.gz.

Signature

(math-format-stack-value ENTRY)

Source Code

;; Defined in /usr/src/emacs/lisp/calc/calc.el.gz
;;; Format the number A as a string.  [X N; X Z] [Public]
(defun math-format-stack-value (entry)
  (setq calc-selection-cache-entry calc-selection-cache-default-entry)
  (let* ((a (car entry))
	 (math-comp-selected (nth 2 entry))
	 (c (cond ((null a) "<nil>")
		  ((eq calc-display-raw t) (format "%s" a))
		  ((stringp a) a)
		  ((eq a 'top-of-stack) (propertize "." 'font-lock-face 'bold))
		  (calc-prepared-composition
		   calc-prepared-composition)
		  ((and (Math-scalarp a)
			(memq calc-language '(nil flat unform))
			(null math-comp-selected))
		   (math-format-number a))
		  (t (require 'calc-ext)
		     (math-compose-expr a 0))))
	 (off (math-stack-value-offset c))
	 s w)
    (and math-comp-selected (setq calc-any-selections t))
    (setq w (cdr off)
	  off (car off))
    (when (> off 0)
      (setq c (math-comp-concat (make-string off ?\s) c)))
    (or (equal calc-left-label "")
	(setq c (math-comp-concat (if (eq a 'top-of-stack)
				      (make-string (length calc-left-label) ?\s)
				    calc-left-label)
				  c)))
    (when calc-line-numbering
      (setq c (math-comp-concat (if (eq calc-language 'big)
				    (if math-comp-selected
					'(tag t "1:  ")
				      "1:  ")
				  "    ")
				c)))
    (unless (or (equal calc-right-label "")
		(eq a 'top-of-stack))
      (require 'calc-ext)
      (setq c (list 'horiz c
		    (make-string (max (- w (math-comp-width c)
					 (length calc-right-label)) 0) ?\s)
		    '(break -1)
		    calc-right-label)))
    (setq s (if (stringp c)
		(if calc-display-raw
		    (prin1-to-string c)
		  c)
	      (math-composition-to-string c w)))
    (when calc-language-output-filter
      (setq s (funcall calc-language-output-filter s)))
    (if (eq calc-language 'big)
	(setq s (concat s "\n"))
      (when calc-line-numbering
	(setq s (concat "1:" (substring s 2)))))
    (setcar (cdr entry) (calc-count-lines s))
    s))