Complete temperature units in calc-convert-temperature

* lisp/calc/calc-units.el (calc-convert-temperature): Complete with
temperature units in math-standard-units.
This commit is contained in:
Mark Oteiza 2016-03-03 17:56:44 +00:00
parent dbb02bfadc
commit 66d2717888

View file

@ -565,7 +565,12 @@ If COMP or STD is non-nil, put that in the units table instead."
(defun calc-convert-temperature (&optional old-units new-units) (defun calc-convert-temperature (&optional old-units new-units)
(interactive) (interactive)
(calc-slow-wrapper (calc-slow-wrapper
(let ((expr (calc-top-n 1)) (let ((tempunits (delq nil
(mapcar
(lambda (x)
(if (nth 3 x) (car x)))
math-standard-units)))
(expr (calc-top-n 1))
(uold nil) (uold nil)
(uoldname nil) (uoldname nil)
unew unew
@ -580,15 +585,16 @@ If COMP or STD is non-nil, put that in the units table instead."
(car units))))) (car units)))))
(error "Not a pure temperature expression")) (error "Not a pure temperature expression"))
(math-read-expr (math-read-expr
(setq uoldname (read-string (setq uoldname (completing-read
"Old temperature units: "))))))) "Old temperature units: "
tempunits)))))))
(when (eq (car-safe uold) 'error) (when (eq (car-safe uold) 'error)
(error "Bad format in units expression: %s" (nth 2 uold))) (error "Bad format in units expression: %s" (nth 2 uold)))
(or (math-units-in-expr-p expr nil) (or (math-units-in-expr-p expr nil)
(setq expr (math-mul expr uold))) (setq expr (math-mul expr uold)))
(setq defunits (math-get-default-units expr)) (setq defunits (math-get-default-units expr))
(setq unew (or new-units (setq unew (or new-units
(read-string (completing-read
(concat (concat
(if uoldname (if uoldname
(concat "Old temperature units: " (concat "Old temperature units: "
@ -599,7 +605,8 @@ If COMP or STD is non-nil, put that in the units table instead."
(concat " (default " (concat " (default "
defunits defunits
"): ") "): ")
": "))))) ": "))
tempunits)))
(setq unew (math-read-expr (if (string= unew "") defunits unew))) (setq unew (math-read-expr (if (string= unew "") defunits unew)))
(when (eq (car-safe unew) 'error) (when (eq (car-safe unew) 'error)
(error "Bad format in units expression: %s" (nth 2 unew))) (error "Bad format in units expression: %s" (nth 2 unew)))