]> code.delx.au - gnu-emacs/blobdiff - lisp/calculator.el
Don't quote symbols 'like-this' in docstrings etc.
[gnu-emacs] / lisp / calculator.el
index ad7a7f4c92a3beeefcf48e6cddd37e00a6df5a10..55229bc03fb74abda55980b336f81818174353dd 100644 (file)
@@ -1,6 +1,6 @@
 ;;; calculator.el --- a calculator for Emacs  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1998, 2000-2014 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2000-2015 Free Software Foundation, Inc.
 
 ;; Author: Eli Barzilay <eli@barzilay.org>
 ;; Keywords: tools, convenience
@@ -311,9 +311,9 @@ user-defined operators, use `calculator-user-operators' instead.")
    9 (highest) (optional, defaults to 1);
 
 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.
+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.
 
 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]"
@@ -1197,10 +1203,10 @@ arguments."
     ;; f is an expression
     (let ((TX (and X (calculator-truncate X)))
           (TY (and Y (calculator-truncate Y)))
-          (DX (if (and X calculator-deg) (/ (* X pi) 180) X))
+          (DX (if (and X calculator-deg) (degrees-to-radians X) X))
           (L  calculator-saved-list)
           (fF `(calculator-funcall ',f x y))
-          (fD `(if calculator-deg (/ (* x 180) float-pi) x)))
+          (fD `(if calculator-deg (* radians-to-degrees x) x)))
       (eval `(cl-flet ((F (&optional x y) ,fF) (D (x) ,fD))
                (let ((X ,X) (Y ,Y) (DX ,DX) (TX ,TX) (TY ,TY) (L ',L))
                  ,f))