From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#23889: 25.0.95; Calc; calc-simplify-units not working as documented for trigometric functions Date: Mon, 4 Jul 2016 17:18:52 +0900 (JST) Message-ID: References: <87k2h2odo2.fsf@duenenhof-wilhelm.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="8323329-875147898-1467620334=:7718" X-Trace: ger.gmane.org 1467620425 25210 80.91.229.3 (4 Jul 2016 08:20:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 4 Jul 2016 08:20:25 +0000 (UTC) To: 23889@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jul 04 10:20:14 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bJz70-0005hC-7T for geb-bug-gnu-emacs@m.gmane.org; Mon, 04 Jul 2016 10:20:14 +0200 Original-Received: from localhost ([::1]:45849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJz6z-0003jS-Df for geb-bug-gnu-emacs@m.gmane.org; Mon, 04 Jul 2016 04:20:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJz6s-0003hT-PV for bug-gnu-emacs@gnu.org; Mon, 04 Jul 2016 04:20:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bJz6o-0004sC-J0 for bug-gnu-emacs@gnu.org; Mon, 04 Jul 2016 04:20:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52411) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJz6o-0004s6-DX for bug-gnu-emacs@gnu.org; Mon, 04 Jul 2016 04:20:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bJz6o-00064p-4B for bug-gnu-emacs@gnu.org; Mon, 04 Jul 2016 04:20:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87k2h2odo2.fsf@duenenhof-wilhelm.de> Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 04 Jul 2016 08:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23889 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23889-submit@debbugs.gnu.org id=B23889.146762034323292 (code B ref 23889); Mon, 04 Jul 2016 08:20:02 +0000 Original-Received: (at 23889) by debbugs.gnu.org; 4 Jul 2016 08:19:03 +0000 Original-Received: from localhost ([127.0.0.1]:36515 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bJz5r-00063c-3m for submit@debbugs.gnu.org; Mon, 04 Jul 2016 04:19:03 -0400 Original-Received: from mail-pf0-f196.google.com ([209.85.192.196]:34774) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bJz5o-000638-Qz for 23889@debbugs.gnu.org; Mon, 04 Jul 2016 04:19:01 -0400 Original-Received: by mail-pf0-f196.google.com with SMTP id 66so15832759pfy.1 for <23889@debbugs.gnu.org>; Mon, 04 Jul 2016 01:19:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:subject:message-id:user-agent:mime-version; bh=bvWB4hvqWjvHYPBVAecUYPP4UfzEMZni0dIVeETIV2A=; b=QXlg1/7ecUrATiMGgrV3rTdoiee0W9hwpRBx15DSabMfnmkO+pNGgc3kuA3bxTutlf PfAkuXaSFOBMJjvZ/CH+E0nlr+WyHKmlpAcgJT6m4gC75aMWUzBWgPZVT7cueZN9Peeg WtLKVkru5qW7xEPuQekHJqgnVGWb/73GfAqyf1hym7ocWWd+nLhGwjxZuRtOwhegWUWV /VV9YPgZEWY7wRnyBuHA2Xb1+HiajsP/V69Ya+Vxg0oBPBqH6RHDskiwzoNYpx6BvZ+a gFrmYY5zAgq6OJK+BguveMfhlD+XLwwqHxQVhJBIapfsuERhGt4HBouXkkOFWi/OQNbv LntQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:subject:message-id:user-agent :mime-version; bh=bvWB4hvqWjvHYPBVAecUYPP4UfzEMZni0dIVeETIV2A=; b=EOAuriBp8tFtliJ2x+AhhTwluHCLRb1Sp8zJ4QMwCjV/ooAp+w94urEcEbeEv3UyuZ zZmDHsH6RT95MYE5GKOrDmO2YQ546jzuy3TwNn+bQaLvxL3GVtexRETmcEMIie3CGpt3 pkj3EaE3RWJ5uONk526R6ob3HkdE7Jlll0xLygKlY9Z76xXgsug5IoNxKE1zLIJ+qU/x r705fZsgOLzfiqv4+eX6HmVovpqLpkrp/MylqBZmVBFQCU55B05OKnrifrn9Sg6h3Fsu WIlKzmz8c2D5OcfIjjT71Ih6PyoZ9LqE+HKiuKVJjrIK53OOen3xjYBM0n1W3uCeXfBt Ru+A== X-Gm-Message-State: ALyK8tIBbRrslV3Xz/LwuOc7LgqQRF8zjUfpVn27cPxka0xzpbUBxLPH6cmry8UekkU1lQ== X-Received: by 10.98.204.2 with SMTP id a2mr20451170pfg.149.1467620334953; Mon, 04 Jul 2016 01:18:54 -0700 (PDT) Original-Received: from calancha-pc ([210.160.37.25]) by smtp.gmail.com with ESMTPSA id z88sm3049188pfa.59.2016.07.04.01.18.53 for <23889@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jul 2016 01:18:54 -0700 (PDT) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc User-Agent: Alpine 2.20 (DEB 67 2015-01-07) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:120387 Archived-At: --8323329-875147898-1467620334=:7718 Content-Type: text/plain; format=flowed; charset=ISO-8859-7 Content-Transfer-Encoding: 8BIT 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 --8323329-875147898-1467620334=:7718--