aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorEli Barzilay2015-01-25 22:42:01 -0500
committerEli Barzilay2015-01-25 22:42:01 -0500
commit44df0a8f506db385473ed36c2a5fa26e06e7788d (patch)
treefdb594ecc6ce9e79568e238d4e3e178e000f17ba /lisp
parentc3d4505b5a8bf55044a1f40da5018e83a43157ff (diff)
downloademacs-44df0a8f506db385473ed36c2a5fa26e06e7788d.tar.gz
emacs-44df0a8f506db385473ed36c2a5fa26e06e7788d.zip
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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/calculator.el16
1 files changed, 11 insertions, 5 deletions
diff --git a/lisp/calculator.el b/lisp/calculator.el
index 7d7c73ae327..0aef07b1750 100644
--- a/lisp/calculator.el
+++ b/lisp/calculator.el
@@ -312,8 +312,8 @@ user-defined operators, use `calculator-user-operators' instead.")
312 312
313It it possible have a unary prefix version of a binary operator if it 313It it possible have a unary prefix version of a binary operator if it
314comes later in this list. If the list begins with the symbol 'nobind, 314comes later in this list. If the list begins with the symbol 'nobind,
315then no key binding will take place -- this is only useful for predefined 315then no key binding will take place -- this is only useful for
316keys. 316predefined keys.
317 317
318Use `calculator-user-operators' to add operators to this list, see its 318Use `calculator-user-operators' to add operators to this list, see its
319documentation for an example.") 319documentation for an example.")
@@ -1124,9 +1124,15 @@ If optional argument FORCE is non-nil, don't use the cached string."
1124 " " 1124 " "
1125 (and calculator-display-fragile 1125 (and calculator-display-fragile
1126 calculator-saved-list 1126 calculator-saved-list
1127 (= (car calculator-stack) 1127 ;; Hack: use `eq' to compare the number: it's a
1128 (nth calculator-saved-ptr 1128 ;; flonum, so `eq' means that its the actual
1129 calculator-saved-list)) 1129 ;; number rather than a computation that had an
1130 ;; equal result (eg, enter 1,3,2, use "v" to see
1131 ;; the average -- it now shows "2" instead of
1132 ;; "2 [3]").
1133 (eq (car calculator-stack)
1134 (nth calculator-saved-ptr
1135 calculator-saved-list))
1130 (if (= 0 calculator-saved-ptr) 1136 (if (= 0 calculator-saved-ptr)
1131 (format "[%s]" (length calculator-saved-list)) 1137 (format "[%s]" (length calculator-saved-list))
1132 (format "[%s/%s]" 1138 (format "[%s/%s]"