]> code.delx.au - gnu-emacs/commitdiff
Ignore angle mode while simplifying units
authorTino Calancha <tino.calancha@gmail.com>
Mon, 11 Jul 2016 15:38:14 +0000 (00:38 +0900)
committerTino Calancha <tino.calancha@gmail.com>
Mon, 11 Jul 2016 15:38:14 +0000 (00:38 +0900)
* lisp/calc/calc-forms.el (math-to-hms, math-from-hms):
Ignore value of 'calc-angle-mode' when 'math-simplifying-units'
is non-nil (Bug#23889).
* lisp/calc/calc-math.el (math-to-radians, math-from-radians)
(math-from-radians-2, math-to-radians-2): Idem.

lisp/calc/calc-forms.el
lisp/calc/calc-math.el

index c94b89d6b1031c25aeb56213b5a93ce592ff9b1e..153b90429eae977ae26c591f59dcf28e6e1ad93c 100644 (file)
         (list 'calcFunc-hms a))
        ((math-negp a)
         (math-neg (math-to-hms (math-neg a) ang)))
-       ((eq (or ang calc-angle-mode) 'rad)
+       ((eq (or ang
+                 (and (not math-simplifying-units) calc-angle-mode))
+                 'rad)
         (math-to-hms (math-div a (math-pi-over-180)) 'deg))
        ((memq (car-safe a) '(cplx polar)) a)
        (t
           (if (eq (car-safe a) 'sdev)
               (math-make-sdev (math-from-hms (nth 1 a) ang)
                               (math-from-hms (nth 2 a) ang))
-            (if (eq (or ang calc-angle-mode) 'rad)
+            (if (eq (or ang
+                         (and (not math-simplifying-units) calc-angle-mode))
+                     'rad)
                 (list 'calcFunc-rad a)
               (list 'calcFunc-deg a)))))
        ((math-negp a)
         (math-neg (math-from-hms (math-neg a) ang)))
-       ((eq (or ang calc-angle-mode) 'rad)
+       ((eq (or ang
+                 (and (not math-simplifying-units) calc-angle-mode))
+             'rad)
         (math-mul (math-from-hms a 'deg) (math-pi-over-180)))
        (t
         (math-add (math-div (math-add (math-div (nth 3 a)
index 699ef6f49ae41bd67413088809b8c4802e3b933e..567635eb65b2594f9c27aaace425d03d0536d824 100644 (file)
@@ -763,12 +763,14 @@ If this can't be done, return NIL."
 (defun math-to-radians (a)   ; [N N]
   (cond ((eq (car-safe a) 'hms)
         (math-from-hms a 'rad))
-       ((memq calc-angle-mode '(deg hms))
+       ((and (not math-simplifying-units)
+              (memq calc-angle-mode '(deg hms)))
         (math-mul a (math-pi-over-180)))
        (t a)))
 
 (defun math-from-radians (a)   ; [N N]
-  (cond ((eq calc-angle-mode 'deg)
+  (cond ((and (not math-simplifying-units)
+              (eq calc-angle-mode 'deg))
         (if (math-constp a)
             (math-div a (math-pi-over-180))
           (list 'calcFunc-deg a)))
@@ -779,14 +781,16 @@ If this can't be done, return NIL."
 (defun math-to-radians-2 (a &optional force-symbolic)   ; [N N]
   (cond ((eq (car-safe a) 'hms)
         (math-from-hms a 'rad))
-       ((memq calc-angle-mode '(deg hms))
+       ((and (not math-simplifying-units)
+              (memq calc-angle-mode '(deg hms)))
         (if (or calc-symbolic-mode force-symbolic)
             (math-div (math-mul a '(var pi var-pi)) 180)
           (math-mul a (math-pi-over-180))))
        (t a)))
 
 (defun math-from-radians-2 (a &optional force-symbolic)   ; [N N]
-  (cond ((memq calc-angle-mode '(deg hms))
+  (cond ((and (not math-simplifying-units)
+              (memq calc-angle-mode '(deg hms)))
         (if (or calc-symbolic-mode force-symbolic)
             (math-div (math-mul 180 a) '(var pi var-pi))
           (math-div a (math-pi-over-180))))