Function: math-compose-integ

math-compose-integ is a byte-compiled function defined in calccomp.el.gz.

Signature

(math-compose-integ A PREC)

Source Code

;; Defined in /usr/src/emacs/lisp/calc/calccomp.el.gz
(defun math-compose-integ (a prec)
  (and (memq (length a) '(3 5))
       (eq (car-safe (nth 2 a)) 'var)
       (let* ((parens (and (>= prec 196) (/= prec 1000)))
	      (var (math-compose-expr (nth 2 a) 0))
	      (over (and (eq (car-safe (nth 2 a)) 'var)
			 (or (and (eq (car-safe (nth 1 a)) '/)
				  (math-numberp (nth 1 (nth 1 a))))
			     (and (eq (car-safe (nth 1 a)) '^)
				  (math-looks-negp (nth 2 (nth 1 a)))))))
	      (expr (math-compose-expr (if over
					   (math-mul (nth 1 a)
						     (math-build-var-name
						      (format
						       "d%s"
						       (nth 1 (nth 2 a)))))
					 (nth 1 a)) 185))
	      (low (and (nth 3 a)
                        (let ((calc-language 'flat))
                          (math-compose-expr (nth 3 a) 0))))
	      (high (and (nth 4 a)
                         (let ((calc-language 'flat))
                           (math-compose-expr (nth 4 a) 0))))
              ;; Check if we have Unicode integral top/bottom parts.
              (fancy (and (char-displayable-p ?⌠)
                          (char-displayable-p ?⌡)))
              ;; If we do, find the most suitable middle part.
              (fancy-stem (cond ((not fancy))
                                ;; U+23AE INTEGRAL EXTENSION
                                ((char-displayable-p ?⎮) "⎮ ")
                                ;; U+2502 BOX DRAWINGS LIGHT VERTICAL
                                ((char-displayable-p ?│) "│ ")
                                ;; U+007C VERTICAL LINE
                                (t "| "))))
         (let ((comp
                (list 'horiz
                      (append (list 'vcent (if fancy
                                               (if high 2 1)
                                             (if high 3 2)))
                              (and high (list (if fancy
                                                  (list 'horiz high " ")
                                                (list 'horiz "  " high))))
                              (if fancy
                                  (list "⌠ " fancy-stem "⌡ ")
                                '("  /"
                                  " | "
                                  " | "
                                  " | "
                                  "/  "))
                              (and low (list (if fancy
                                                 (list 'horiz low " ")
                                               (list 'horiz low "  ")))))
                      expr
                      (if over
                          ""
                        (list 'horiz " d" var)))))
           (if parens
               (math--comp-round-bracket comp)
             comp)))))