diff options
Diffstat (limited to 'lisp/calc')
-rw-r--r-- | lisp/calc/calc-units.el | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lisp/calc/calc-units.el b/lisp/calc/calc-units.el index 26a644a29ba..05950864a52 100644 --- a/lisp/calc/calc-units.el +++ b/lisp/calc/calc-units.el @@ -904,10 +904,12 @@ If COMP or STD is non-nil, put that in the units table instead." (and (consp expr) (if (eq (car expr) 'var) (math-check-unit-name expr) - (and (or sub-exprs - (memq (car expr) '(* / ^))) - (or (math-units-in-expr-p (nth 1 expr) sub-exprs) - (math-units-in-expr-p (nth 2 expr) sub-exprs)))))) + (if (eq (car expr) 'neg) + (math-units-in-expr-p (nth 1 expr) sub-exprs) + (and (or sub-exprs + (memq (car expr) '(* / ^))) + (or (math-units-in-expr-p (nth 1 expr) sub-exprs) + (math-units-in-expr-p (nth 2 expr) sub-exprs))))))) (defun math-only-units-in-expr-p (expr) (and (consp expr) @@ -924,6 +926,8 @@ If COMP or STD is non-nil, put that in the units table instead." (cond ((math-scalarp expr) nil) ((eq (car expr) 'var) (math-check-unit-name expr)) + ((eq (car expr) 'neg) + (math-single-units-in-expr-p (nth 1 expr))) ((eq (car expr) '*) (let ((u1 (math-single-units-in-expr-p (nth 1 expr))) (u2 (math-single-units-in-expr-p (nth 2 expr)))) @@ -1079,6 +1083,8 @@ If COMP or STD is non-nil, put that in the units table instead." ((eq (car-safe expr) '/) (or (math-find-compatible-unit-rec (nth 1 expr) pow) (math-find-compatible-unit-rec (nth 2 expr) (- pow)))) + ((eq (car-safe expr) 'neg) + (math-find-compatible-unit-rec (nth 1 expr) pow)) ((and (eq (car-safe expr) '^) (integerp (nth 2 expr))) (math-find-compatible-unit-rec (nth 1 expr) (* pow (nth 2 expr)))) @@ -1497,6 +1503,8 @@ If COMP or STD is non-nil, put that in the units table instead." ((memq (car-safe expr) '(* /)) (cons (car expr) (mapcar 'math-extract-units (cdr expr)))) + ((eq (car-safe expr) 'neg) + (math-extract-units (nth 1 expr))) ((eq (car-safe expr) '^) (list '^ (math-extract-units (nth 1 expr)) (nth 2 expr))) ((math-check-unit-name expr) expr) |