Function: calc-convert-temperature

calc-convert-temperature is an autoloaded, interactive and byte-compiled function defined in calc-units.el.gz.

Signature

(calc-convert-temperature &optional OLD-UNITS NEW-UNITS)

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/calc/calc-units.el.gz
(defun calc-convert-temperature (&optional old-units new-units)
  (interactive)
  (calc-slow-wrapper
   (let ((tempunits (delq nil
                          (mapcar
                           (lambda (x)
                             (if (nth 3 x) (car x)))
                           math-standard-units)))
         (expr (calc-top-n 1))
	 (uold nil)
	 (uoldname nil)
	 unew
         defunits)
     (setq uold (or old-units
		    (let ((units (math-single-units-in-expr-p expr)))
		      (if units
			  (if (consp units)
			      (list 'var (car units)
				    (intern (concat "var-"
						    (symbol-name
						     (car units)))))
			    (error "Not a pure temperature expression"))
			(math-read-expr
			 (setq uoldname (completing-read
					 "Old temperature units: "
                                         tempunits)))))))
     (when (eq (car-safe uold) 'error)
       (error "Bad format in units expression: %s" (nth 2 uold)))
     (or (math-units-in-expr-p expr nil)
	 (setq expr (math-mul expr uold)))
     (setq defunits (math-get-default-units expr))
     (setq unew (or new-units
                    (completing-read (format-prompt
                                      (if uoldname
                                          (concat "Old temperature units: "
                                                  uoldname
                                                  ", new units")
                                        "New temperature units")
                                      defunits)
                                     tempunits)))
     (setq unew (math-read-expr (if (string= unew "") defunits unew)))
     (when (eq (car-safe unew) 'error)
       (error "Bad format in units expression: %s" (nth 2 unew)))
     (math-put-default-units unew)
     (let ((ntemp (calc-normalize
                   (math-simplify-units
                    (math-convert-temperature expr uold unew
                                              uoldname)))))
       (if (Math-zerop ntemp)
           (setq ntemp (list '* ntemp unew)))
       (let ((calc-simplify-mode 'none))
         (calc-enter-result 1 "cvtm" ntemp))))))