From: Jay Belanger Date: Sat, 20 Oct 2012 04:14:32 +0000 (-0500) Subject: calc/calc-units.el (math-extract-units): Properly extract powers of units. X-Git-Tag: emacs-24.2.90~211^2~34 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4c9e95500fc913ad934e65c6625114e3f5532078;p=emacs.git calc/calc-units.el (math-extract-units): Properly extract powers of units. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 690aaa70eac..7830f8312da 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-10-20 Jay Belanger + + * calc/calc-units.el (math-extract-units): Properly extract powers + of units. + 2012-10-20 Daniel Colascione * frame.el (make-frame): Set x-display-name as we used to in order diff --git a/lisp/calc/calc-units.el b/lisp/calc/calc-units.el index 39f710f8322..58646ea114c 100644 --- a/lisp/calc/calc-units.el +++ b/lisp/calc/calc-units.el @@ -1481,10 +1481,16 @@ If COMP or STD is non-nil, put that in the units table instead." (mapcar 'math-remove-units (cdr expr)))))) (defun math-extract-units (expr) - (if (memq (car-safe expr) '(* /)) - (cons (car expr) - (mapcar 'math-extract-units (cdr expr))) - (if (math-check-unit-name expr) expr 1))) + (cond + ((memq (car-safe expr) '(* /)) + (cons (car expr) + (mapcar 'math-extract-units (cdr expr)))) + ((and + (eq (car-safe expr) '^) + (math-check-unit-name (nth 1 expr))) + expr) + ((math-check-unit-name expr) expr) + (t 1))) (defun math-build-units-table-buffer (enter-buffer) (if (not (and math-units-table math-units-table-buffer-valid