emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 44df0a8: lisp/calculator.el (calculator-update-disp


From: Eli Barzilay
Subject: [Emacs-diffs] master 44df0a8: lisp/calculator.el (calculator-update-display): Bug fix & improvement.
Date: Mon, 26 Jan 2015 03:42:12 +0000

branch: master
commit 44df0a8f506db385473ed36c2a5fa26e06e7788d
Author: Eli Barzilay <address@hidden>
Commit: Eli Barzilay <address@hidden>

    lisp/calculator.el (calculator-update-display): Bug fix & improvement.
    
    Avoid a crash when the daved ptr is at the end of the list (= when it's
    before the first one).  Also use `eq' to compare the value so the saved
    list indicator appears when a value was retrieved from the list rather
    than an equal result is shown.
---
 lisp/calculator.el |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/lisp/calculator.el b/lisp/calculator.el
index 7d7c73a..0aef07b 100644
--- a/lisp/calculator.el
+++ b/lisp/calculator.el
@@ -312,8 +312,8 @@ user-defined operators, use `calculator-user-operators' 
instead.")
 
 It it possible have a unary prefix version of a binary operator if it
 comes later in this list.  If the list begins with the symbol 'nobind,
-then no key binding will take place -- this is only useful for predefined
-keys.
+then no key binding will take place -- this is only useful for
+predefined keys.
 
 Use `calculator-user-operators' to add operators to this list, see its
 documentation for an example.")
@@ -1124,9 +1124,15 @@ If optional argument FORCE is non-nil, don't use the 
cached string."
                    " "
                    (and calculator-display-fragile
                         calculator-saved-list
-                        (= (car calculator-stack)
-                           (nth calculator-saved-ptr
-                                calculator-saved-list))
+                        ;; Hack: use `eq' to compare the number: it's a
+                        ;; flonum, so `eq' means that its the actual
+                        ;; number rather than a computation that had an
+                        ;; equal result (eg, enter 1,3,2, use "v" to see
+                        ;; the average -- it now shows "2" instead of
+                        ;; "2 [3]").
+                        (eq (car calculator-stack)
+                            (nth calculator-saved-ptr
+                                 calculator-saved-list))
                         (if (= 0 calculator-saved-ptr)
                           (format "[%s]" (length calculator-saved-list))
                           (format "[%s/%s]"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]