From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Raimon Grau Newsgroups: gmane.emacs.bugs Subject: bug#37649: [PATCH] Fix optional parameter passing in calc-fin-* functions Date: Mon, 07 Oct 2019 20:55:33 +0100 Message-ID: <87wodgqqiy.fsf@konghq.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="106173"; mail-complaints-to="usenet@blaine.gmane.org" To: 37649@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Oct 07 21:56:27 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iHZ7K-000RSY-IM for geb-bug-gnu-emacs@m.gmane.org; Mon, 07 Oct 2019 21:56:26 +0200 Original-Received: from localhost ([::1]:49320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHZ7I-0002E8-PT for geb-bug-gnu-emacs@m.gmane.org; Mon, 07 Oct 2019 15:56:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35129) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHZ6z-0002E0-7v for bug-gnu-emacs@gnu.org; Mon, 07 Oct 2019 15:56:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iHZ6w-0003Ie-Rw for bug-gnu-emacs@gnu.org; Mon, 07 Oct 2019 15:56:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40369) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iHZ6w-0003IK-E1 for bug-gnu-emacs@gnu.org; Mon, 07 Oct 2019 15:56:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iHZ6w-0005hZ-8c for bug-gnu-emacs@gnu.org; Mon, 07 Oct 2019 15:56:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Raimon Grau Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 07 Oct 2019 19:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 37649 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.157047814221884 (code B ref -1); Mon, 07 Oct 2019 19:56:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 Oct 2019 19:55:42 +0000 Original-Received: from localhost ([127.0.0.1]:49190 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iHZ6b-0005gt-Mz for submit@debbugs.gnu.org; Mon, 07 Oct 2019 15:55:42 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:37072) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iHZ6a-0005gm-44 for submit@debbugs.gnu.org; Mon, 07 Oct 2019 15:55:40 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35088) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHZ6Y-0002CE-JX for bug-gnu-emacs@gnu.org; Mon, 07 Oct 2019 15:55:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iHZ6X-00031Q-5v for bug-gnu-emacs@gnu.org; Mon, 07 Oct 2019 15:55:38 -0400 Original-Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:38326) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iHZ6W-0002zU-Sr for bug-gnu-emacs@gnu.org; Mon, 07 Oct 2019 15:55:37 -0400 Original-Received: by mail-wr1-x436.google.com with SMTP id w12so16752376wro.5 for ; Mon, 07 Oct 2019 12:55:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konghq.com; s=google; h=from:to:subject:date:message-id:mime-version; bh=a9H+Ne/fB5KBPRUzZM9FAkWHJQHtwp7vr3qNony/obQ=; b=d35e8ECp0qSI96VvpzUi6aXQcoS+1wWddj0TW3lmdl4bS8pg0WvrpVBSjjEUY0EMnS 6P8dXIibWw9q7fa552Kji36w58N9KFxOM7vMZPYf6/Z/XLe3c21LMvSaJu1OeoE+Sts9 32ypLQ7i4jIHY6G22UV+VSnAt4D5R4ZmX3Adk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=a9H+Ne/fB5KBPRUzZM9FAkWHJQHtwp7vr3qNony/obQ=; b=G7U6YKd2o+/piPTfkbinUZcrqsG+y1x3JKnDRIN1eRjeNGV3aBZfw+M9aDvEa4rfcC 3Ji+lJyYO55zBBCfEP5S5FKypfex0Lto6n90yTy1LNEGuMousgen4uVPEZwJVO5fPkri PK7Nz3i0//SwGdhTeIZcjJnq8c1deYdkcky65Ap24KusmmVy9Hid8mEtazWFSYmfbSoF sHrJsQYRCaYfK+JaE8vm4AVDzhN4l5EEuARg4WPb+dYgyCQRRK5wzzm0fFubxAHuhkzG dZcqA33iiM/j5YuPV5MZdkfeDuJtlXaqPfVIdTANJ3MVdhm6VCL9Sn4Nk3zIpXP0vVUC AH5A== X-Gm-Message-State: APjAAAUAguae+njDFMB1891Ry35MWMU6OXpQPSAwyeuAFHycPi4RMSFI PP0+b7NLWWjDe5EO36i3BXENeCvn/JQ= X-Google-Smtp-Source: APXvYqzu5eMNS5elevs96UgtMr1XeNMueRW/M8gG4rXgVq7Z+o+s6f3bSupF2k83JMtPlmw4CrXNJw== X-Received: by 2002:a05:6000:11ce:: with SMTP id i14mr10659790wrx.380.1570478135226; Mon, 07 Oct 2019 12:55:35 -0700 (PDT) Original-Received: from raikong (85.155.103.148.dyn.user.ono.com. [85.155.103.148]) by smtp.gmail.com with ESMTPSA id r13sm27628724wrn.0.2019.10.07.12.55.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 12:55:34 -0700 (PDT) X-Google-Original-From: Raimon Grau X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. 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: 209.51.188.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:168587 Archived-At: --=-=-= Content-Type: text/plain; format=flowed Hi, I noticed some calc financial functions are not accepting the optional flag on calc "stack" mode. The docs talk about them, and they work in algebraic mode, so there's no need to modify any docs. Here's a patch that enables the option flag that varies the number of parameters passed from 3 to 4 in those cases. Cheers, Raimon Grau --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=0001-Fix-optional-parameter-passing-in-calc-fin-functions.patch >From a25e86f4e8a5d729f1933864330c382e845bfd46 Mon Sep 17 00:00:00 2001 From: Raimon Grau Date: Thu, 3 Oct 2019 19:52:25 +0100 Subject: [PATCH] Fix optional parameter passing in calc-fin-* functions * lisp/calc/calc-fin.el (calc-fin-pv, calc-fin-fv, calc-fin-pmt) (calc-fin-pner, calc-fin-rate): Add support for an optional parameter standing for an initial lump. The functions already support it but the extra parameter was not taken into account in stack mode. This commit it takes into consideration when deciding if a function takes 3 or 4 parameters. --- lisp/calc/calc-fin.el | 53 +++++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/lisp/calc/calc-fin.el b/lisp/calc/calc-fin.el index 813da28..4302cbc 100644 --- a/lisp/calc/calc-fin.el +++ b/lisp/calc/calc-fin.el @@ -35,9 +35,10 @@ calc-fin-pv (calc-slow-wrapper (if (calc-is-hyperbolic) (calc-enter-result 3 "pvl" (cons 'calcFunc-pvl (calc-top-list-n 3))) - (if (calc-is-inverse) - (calc-enter-result 3 "pvb" (cons 'calcFunc-pvb (calc-top-list-n 3))) - (calc-enter-result 3 "pv" (cons 'calcFunc-pv (calc-top-list-n 3))))))) + (let ((n (if (calc-is-option) 4 3))) + (if (calc-is-inverse) + (calc-enter-result n "pvb" (cons 'calcFunc-pvb (calc-top-list-n n))) + (calc-enter-result n "pv" (cons 'calcFunc-pv (calc-top-list-n n)))))))) (defun calc-fin-npv (arg) (interactive "p") @@ -51,42 +52,48 @@ calc-fin-fv (calc-slow-wrapper (if (calc-is-hyperbolic) (calc-enter-result 3 "fvl" (cons 'calcFunc-fvl (calc-top-list-n 3))) - (if (calc-is-inverse) - (calc-enter-result 3 "fvb" (cons 'calcFunc-fvb (calc-top-list-n 3))) - (calc-enter-result 3 "fv" (cons 'calcFunc-fv (calc-top-list-n 3))))))) + (let ((n (if (calc-is-option) 4 3))) + (if (calc-is-inverse) + (calc-enter-result n "fvb" (cons 'calcFunc-fvb (calc-top-list-n n))) + (calc-enter-result n "fv" (cons 'calcFunc-fv (calc-top-list-n n)))))))) (defun calc-fin-pmt () (interactive) (calc-slow-wrapper (if (calc-is-hyperbolic) (calc-enter-result 3 "fvl" (cons 'calcFunc-fvl (calc-top-list-n 3))) - (if (calc-is-inverse) - (calc-enter-result 3 "pmtb" (cons 'calcFunc-pmtb (calc-top-list-n 3))) - (calc-enter-result 3 "pmt" (cons 'calcFunc-pmt (calc-top-list-n 3))))))) + (let ((n (if (calc-is-option) 4 3))) + (if (calc-is-inverse) + (calc-enter-result n "pmtb" (cons 'calcFunc-pmtb (calc-top-list-n n))) + (calc-enter-result n "pmt" (cons 'calcFunc-pmt (calc-top-list-n n)))))))) (defun calc-fin-nper () (interactive) (calc-slow-wrapper (if (calc-is-hyperbolic) (calc-enter-result 3 "nprl" (cons 'calcFunc-nperl (calc-top-list-n 3))) - (if (calc-is-inverse) - (calc-enter-result 3 "nprb" (cons 'calcFunc-nperb - (calc-top-list-n 3))) - (calc-enter-result 3 "nper" (cons 'calcFunc-nper - (calc-top-list-n 3))))))) + (let ((n (if (calc-is-option) 4 3))) + (if (calc-is-inverse) + (calc-enter-result n "nprb" (cons 'calcFunc-nperb + (calc-top-list-n n))) + (calc-enter-result n "nper" (cons 'calcFunc-nper + (calc-top-list-n n)))))))) (defun calc-fin-rate () (interactive) (calc-slow-wrapper - (calc-pop-push-record 3 - (if (calc-is-hyperbolic) "ratl" - (if (calc-is-inverse) "ratb" "rate")) - (calc-to-percentage - (calc-normalize - (cons (if (calc-is-hyperbolic) 'calcFunc-ratel - (if (calc-is-hyperbolic) 'calcFunc-rateb - 'calcFunc-rate)) - (calc-top-list-n 3))))))) + (let ((n (if (and (not (calc-is-hyperbolic)) + (calc-is-option)) + 4 3))) + (calc-pop-push-record n + (if (calc-is-hyperbolic) "ratl" + (if (calc-is-inverse) "ratb" "rate")) + (calc-to-percentage + (calc-normalize + (cons (if (calc-is-hyperbolic) 'calcFunc-ratel + (if (calc-is-hyperbolic) 'calcFunc-rateb + 'calcFunc-rate)) + (calc-top-list-n n)))))))) (defun calc-fin-irr (arg) (interactive "P") -- 2.7.4 --=-=-=--