From unknown Mon Aug 18 21:50:54 2025 X-Loop: help-debbugs@gnu.org Subject: bug#37649: [PATCH] Fix optional parameter passing in calc-fin-* functions 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 To: 37649@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.157047814221884 (code B ref -1); Mon, 07 Oct 2019 19:56:02 +0000 Received: (at submit) by debbugs.gnu.org; 7 Oct 2019 19:55:42 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40 autolearn=disabled version=3.3.2 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 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 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) 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) From: Raimon Grau X-Google-Original-From: Raimon Grau Date: Mon, 07 Oct 2019 20:55:33 +0100 Message-ID: <87wodgqqiy.fsf@konghq.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::436 X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-=-= 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 --=-=-=-- From unknown Mon Aug 18 21:50:54 2025 X-Loop: help-debbugs@gnu.org Subject: bug#37649: [PATCH] Fix optional parameter passing in calc-fin-* functions Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Oct 2019 09:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37649 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Raimon Grau Cc: 37649@debbugs.gnu.org Received: via spool by 37649-submit@debbugs.gnu.org id=B37649.15714784039728 (code B ref 37649); Sat, 19 Oct 2019 09:47:02 +0000 Received: (at 37649) by debbugs.gnu.org; 19 Oct 2019 09:46:43 +0000 Received: from localhost ([127.0.0.1]:51999 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iLlJq-0002Wq-Lk for submit@debbugs.gnu.org; Sat, 19 Oct 2019 05:46:42 -0400 Received: from quimby.gnus.org ([80.91.231.51]:48650) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iLlJn-0002We-Qa for 37649@debbugs.gnu.org; Sat, 19 Oct 2019 05:46:41 -0400 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=marnie) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iLlJj-0004zi-Nh; Sat, 19 Oct 2019 11:46:38 +0200 From: Lars Ingebrigtsen References: <87wodgqqiy.fsf@konghq.com> Date: Sat, 19 Oct 2019 11:46:35 +0200 In-Reply-To: <87wodgqqiy.fsf@konghq.com> (Raimon Grau's message of "Mon, 07 Oct 2019 20:55:33 +0100") Message-ID: <87zhhxf4p0.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Raimon Grau writes: > 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 [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Raimon Grau writes: > 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. Thanks; applied to Emacs 27. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 19 05:46:48 2019 Received: (at control) by debbugs.gnu.org; 19 Oct 2019 09:46:48 +0000 Received: from localhost ([127.0.0.1]:52002 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iLlJw-0002XA-10 for submit@debbugs.gnu.org; Sat, 19 Oct 2019 05:46:48 -0400 Received: from quimby.gnus.org ([80.91.231.51]:48664) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iLlJs-0002Wy-8o for control@debbugs.gnu.org; Sat, 19 Oct 2019 05:46:44 -0400 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=marnie) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iLlJp-0004zs-J3 for control@debbugs.gnu.org; Sat, 19 Oct 2019 11:46:43 +0200 Date: Sat, 19 Oct 2019 11:46:41 +0200 Message-Id: <87y2xhf4ou.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #37649 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: tags 37649 fixed close 37649 27.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 37649 fixed close 37649 27.1 quit