GNU bug report logs - #37649
[PATCH] Fix optional parameter passing in calc-fin-* functions

Previous Next

Package: emacs;

Reported by: Raimon Grau <raimon <at> konghq.com>

Date: Mon, 7 Oct 2019 19:56:02 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 27.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 37649 in the body.
You can then email your comments to 37649 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#37649; Package emacs. (Mon, 07 Oct 2019 19:56:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Raimon Grau <raimon <at> konghq.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 07 Oct 2019 19:56:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Raimon Grau <raimon <at> konghq.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Fix optional parameter passing in calc-fin-* functions
Date: Mon, 07 Oct 2019 20:55:33 +0100
[Message part 1 (text/plain, inline)]
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

[0001-Fix-optional-parameter-passing-in-calc-fin-functions.patch (text/plain, inline)]
From a25e86f4e8a5d729f1933864330c382e845bfd46 Mon Sep 17 00:00:00 2001
From: Raimon Grau <raimonster <at> gmail.com>
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


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37649; Package emacs. (Sat, 19 Oct 2019 09:47:02 GMT) Full text and rfc822 format available.

Message #8 received at 37649 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Raimon Grau <raimon <at> konghq.com>
Cc: 37649 <at> debbugs.gnu.org
Subject: Re: bug#37649: [PATCH] Fix optional parameter passing in calc-fin-*
 functions
Date: Sat, 19 Oct 2019 11:46:35 +0200
Raimon Grau <raimon <at> konghq.com> 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




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 19 Oct 2019 09:47:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 37649 <at> debbugs.gnu.org and Raimon Grau <raimon <at> konghq.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 19 Oct 2019 09:47:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 16 Nov 2019 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 163 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.