Thanks for the report. From the documentation: "(ˇcalc-simplify-units˘) command will simplify ˇsin(45 deg)˘ by taking the sine of 45 degrees, regardless of the current angular mode." The problem is that ˇcalc-simplify-units˘ is actually checking the value of 'calc-angle-mode'. There is an internal variable 'math-simplifying-units'; 'match-simplify-units' bind this var to a non-nil value while performing its task. Following patch use 'math-simplifying-units' to prevent that 'calc-simplify-units' use the value of 'calc-angle-mode'. Regards, Tino ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; From 96b92d9793bd035a4f0ed79a4e434418b0253608 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Mon, 4 Jul 2016 16:32:27 +0900 Subject: [PATCH] Ignore angle mode when simplifying units * lisp/calc/calc-forms.el (math-to-hms, math-from-hms): Ignore value of 'calc-angle-mode' when 'math-simplifying-units' evaluates non-nil (Bug#23889). * lisp/calc/calc-math.el (math-to-radians) (math-from-radians-2, math-to-radians-2): Idem. --- lisp/calc/calc-forms.el | 12 +++++++++--- lisp/calc/calc-math.el | 9 +++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lisp/calc/calc-forms.el b/lisp/calc/calc-forms.el index c94b89d..153b904 100644 --- a/lisp/calc/calc-forms.el +++ b/lisp/calc/calc-forms.el @@ -317,7 +317,9 @@ math-to-hms (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 @@ -354,12 +356,16 @@ math-from-hms (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) diff --git a/lisp/calc/calc-math.el b/lisp/calc/calc-math.el index 699ef6f..d35460e 100644 --- a/lisp/calc/calc-math.el +++ b/lisp/calc/calc-math.el @@ -763,12 +763,13 @@ calcFunc-nroot (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 +780,14 @@ math-from-radians (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)))) -- 2.8.1 In GNU Emacs 25.1.50.5 (x86_64-pc-linux-gnu, GTK+ Version 3.20.6) of 2016-07-04 Repository revision: 05d76dba6604f78e4b2b7b9f8b30c916cad7d32a