;;; calc.el --- the GNU Emacs calculator
-;; Copyright (C) 1990-1993, 2001-2011 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2012 Free Software Foundation, Inc.
;; Author: David Gillespie <daveg@synaptics.com>
;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com>
(defgroup calc nil
- "GNU Calc."
+ "Advanced desk calculator and mathematical tool."
:prefix "calc-"
:tag "Calc"
:group 'applications)
:group 'calc
:type 'boolean)
+(defcustom calc-ensure-consistent-units
+ nil
+ "If non-nil, make sure new units are consistent with current units
+when converting units."
+ :group 'calc
+ :type 'boolean)
+
(defcustom calc-undo-length
100
"The number of undo steps that will be preserved when Calc is quit."
by displaying the rest of the formula in `calc-nonselected-face'.
If `calc-show-selections' is nil, then selected sub-formulas are shown
by displaying the sub-formula in `calc-selected-face'."
+ :version "24.1"
:group 'calc
:type 'boolean)
(defcustom calc-lu-field-reference
"20 uPa"
"The default reference level for logarithmic units (field)."
+ :version "24.1"
:group 'calc
:type '(string))
(defcustom calc-lu-power-reference
"mW"
"The default reference level for logarithmic units (power)."
+ :version "24.1"
:group 'calc
:type '(string))
(defcustom calc-note-threshold "1"
"The number of cents that a frequency should be near a note
to be identified as that note."
+ :version "24.1"
:type 'string
:group 'calc)
(defcalcmodevar calc-previous-modulo nil
"Most recently used value of M in a modulo form.")
-(defcalcmodevar calc-simplify-mode nil
+(defcalcmodevar calc-simplify-mode 'alg
"Type of simplification applied to results.
If `none', results are not simplified when pushed on the stack.
If `num', functions are simplified only when args are constant.
-If nil, only fast simplifications are applied.
+If nil, only limited simplifications are applied.
If `binary', `math-clip' is applied if appropriate.
If `alg', `math-simplify' is applied.
If `ext', `math-simplify-extended' is applied.
Used by `calc-user-invocation'.")
(defcalcmodevar calc-show-banner t
- "*If non-nil, show a friendly greeting above the stack.")
+ "If non-nil, show a friendly greeting above the stack.")
(defconst calc-local-var-list '(calc-stack
calc-stack-top
;; Set up the autoloading linkage.
(let ((name (and (fboundp 'calc-dispatch)
- (eq (car-safe (symbol-function 'calc-dispatch)) 'autoload)
+ (autoloadp (symbol-function 'calc-dispatch))
(nth 1 (symbol-function 'calc-dispatch))))
(p load-path))
(defvar calc-quick-prev-results nil
"Previous results from Quick Calc.")
(defvar calc-said-hello nil
- "Non-nil if the welcomd message has been displayed.")
+ "Non-nil if the welcome message has been displayed.")
(defvar calc-executing-macro nil
"Non-nil if a keyboard macro is executing from the \"K\" key.")
(defvar calc-any-selections nil
((eq calc-simplify-mode 'num) "NumSimp ")
((eq calc-simplify-mode 'binary)
(format "BinSimp%d " calc-word-size))
- ((eq calc-simplify-mode 'alg) "AlgSimp ")
+ ((eq calc-simplify-mode 'alg) "")
((eq calc-simplify-mode 'ext) "ExtSimp ")
((eq calc-simplify-mode 'units) "UnitSimp ")
- (t ""))
+ (t "BasicSimp "))
;; Display modes
(cond ((= calc-number-radix 10) "")
;;; Reduce an object to canonical (normalized) form. [O o; Z Z] [Public]
(defvar math-normalize-a)
+(defvar math-normalize-error nil
+ "Non-nil if the last call the `math-normalize' returned an error.")
+
(defun math-normalize (math-normalize-a)
+ (setq math-normalize-error nil)
(cond
((not (consp math-normalize-a))
(if (integerp math-normalize-a)
(fboundp (car math-normalize-a))))
(apply (car math-normalize-a) args)))))
(wrong-number-of-arguments
+ (setq math-normalize-error t)
(calc-record-why "*Wrong number of arguments"
(cons (car math-normalize-a) args))
nil)
(wrong-type-argument
+ (setq math-normalize-error t)
(or calc-next-why
(calc-record-why "Wrong type of argument"
(cons (car math-normalize-a) args)))
nil)
(args-out-of-range
+ (setq math-normalize-error t)
(calc-record-why "*Argument out of range"
(cons (car math-normalize-a) args))
nil)
(inexact-result
+ (setq math-normalize-error t)
(calc-record-why "No exact representation for result"
(cons (car math-normalize-a) args))
nil)
(math-overflow
+ (setq math-normalize-error t)
(calc-record-why "*Floating-point overflow occurred"
(cons (car math-normalize-a) args))
nil)
(math-underflow
+ (setq math-normalize-error t)
(calc-record-why "*Floating-point underflow occurred"
(cons (car math-normalize-a) args))
nil)
(void-variable
+ (setq math-normalize-error t)
(if (eq (nth 1 err) 'var-EvalRules)
(progn
(setq var-EvalRules nil)