changeset 87472:370b8c2945ae

(calc-arithmetic-menu, calc-scientific-function-menu) (calc-algebra-menu, calc-graphics-menu, calc-vectors-menu) (calc-units-menu, calc-variables-menu, calc-stack-menu): Add :active keywords. (calc-modes-menu): Add complex formats, remaining languages.
author Jay Belanger <jay.p.belanger@gmail.com>
date Sat, 29 Dec 2007 05:32:09 +0000
parents 949048bec87d
children 2c5b54539df2
files lisp/calc/calc-menu.el
diffstat 1 files changed, 276 insertions(+), 82 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/calc/calc-menu.el	Sat Dec 29 04:27:46 2007 +0000
+++ b/lisp/calc/calc-menu.el	Sat Dec 29 05:32:09 2007 +0000
@@ -26,46 +26,58 @@
 (defvar calc-arithmetic-menu
   (list "Arithmetic"
         (list "Basic"
-              ["-(1:)"         calc-change-sign :keys "n"]
-              ["(2:) + (1:)"   calc-plus   :keys "+"]
-              ["(2:) - (1:)"   calc-minus  :keys "-"]
-              ["(2:) * (1:)"   calc-times  :keys "*"]
-              ["(2:) / (1:)"   calc-divide :keys "/"]
-              ["(2:) ^ (1:)"   calc-power  :keys "^"]
+              ["-(1:)"         calc-change-sign 
+               :keys "n" :active (>= (calc-stack-size) 1)]
+              ["(2:) + (1:)"   calc-plus   
+               :keys "+" :active (>= (calc-stack-size) 2)]
+              ["(2:) - (1:)"   calc-minus  
+               :keys "-" :active (>= (calc-stack-size) 2)]
+              ["(2:) * (1:)"   calc-times  
+               :keys "*" :active (>= (calc-stack-size) 2)]
+              ["(2:) / (1:)"   calc-divide 
+               :keys "/" :active (>= (calc-stack-size) 2)]
+              ["(2:) ^ (1:)"   calc-power  
+               :keys "^" :active (>= (calc-stack-size) 2)]
               ["(2:) ^ (1/(1:))" 
                (progn
                  (require 'calc-ext)
                  (let ((calc-inverse-flag t))
                    (call-interactively 'calc-power)))
                :keys "I ^"
+               :active (>= (calc-stack-size) 2)
                :help "The (1:)th root of (2:)"]
               ["abs(1:)"   
                (progn 
                  (require 'calc-arith)
                  (call-interactively 'calc-abs))
                :keys "A"
+               :active (>= (calc-stack-size) 1)
                :help "Absolute value"]
               ["1/(1:)"
                (progn
                  (require 'calc-arith)
                  (call-interactively 'calc-inv))
-               :keys "&"]
+               :keys "&"
+               :active (>= (calc-stack-size) 1)]
               ["sqrt(1:)" 
                (progn
                  (require 'calc-math)
                  (call-interactively 'calc-sqrt))
-               :keys "Q"]
+               :keys "Q"
+               :active (>= (calc-stack-size) 1)]
               ["idiv(2:,1:)"
                (progn
                  (require 'calc-arith)
                  (call-interactively 'calc-idiv))
                :keys "\\"
+               :active (>= (calc-stack-size) 2)
                :help "The integer quotient of (2:) over (1:)"]
               ["(2:) mod (1:)"  
                (progn
                  (require 'calc-misc)
                  (call-interactively 'calc-mod))
                :keys "%"
+               :active (>= (calc-stack-size) 2)
                :help "The remainder when (2:) is divided by (1:)"])
         (list "Rounding"
               ["floor(1:)" 
@@ -73,64 +85,75 @@
                  (require 'calc-arith)
                  (call-interactively 'calc-floor))
                :keys "F"
+               :active (>= (calc-stack-size) 1)
                :help "The greatest integer less than or equal to (1:)"]
               ["ceiling(1:)"  
                (progn
                  (require 'calc-arith)
                  (call-interactively 'calc-ceiling))
                :keys "I F"
+               :active (>= (calc-stack-size) 1)
                :help "The smallest integer greater than or equal to (1:)"]
               ["round(1:)"    
                (progn
                  (require 'calc-arith)
                  (call-interactively 'calc-round))
                :keys "R"
+               :active (>= (calc-stack-size) 1)
                :help "The nearest integer to (1:)"]
               ["truncate(1:)" 
                (progn
                  (require 'calc-arith)
                  (call-interactively 'calc-trunc))
                :keys "I R"
+               :active (>= (calc-stack-size) 1)
                :help "The integer part of (1:)"])
         (list "Complex Numbers"
               ["Re(1:)"
                (progn
                  (require 'calc-cplx)
                  (call-interactively 'calc-re))
-               :keys "f r"]
+               :keys "f r"
+               :active (>= (calc-stack-size) 1)]
               ["Im(1:)"
                (progn
                  (require 'calc-cplx)
                  (call-interactively 'calc-im))
-               :keys "f i"]
+               :keys "f i"
+               :active (>= (calc-stack-size) 1)]
               ["conj(1:)"
                (progn
                  (require 'calc-cplx)
                  (call-interactively 'calc-conj))
                :keys "J"
+               :active (>= (calc-stack-size) 1)
                :help "The complex conjugate of (1:)"]
               ["length(1:)"
                (progn (require 'calc-arith)
                       (call-interactively 'calc-abs))
                :keys "A"
+               :active (>= (calc-stack-size) 1)
                :help "The length (absolute value) of (1:)"]
               ["arg(1:)"
                (progn
                  (require 'calc-cplx)
                  (call-interactively 'calc-argument))
                :keys "G"
+               :active (>= (calc-stack-size) 1)
                :help "The argument (polar angle) of (1:)"])
         (list "Conversion"
               ["Convert (1:) to a float"    
                (progn
                  (require 'calc-ext)
                  (call-interactively 'calc-float))
-               :keys "c f"]
+               :keys "c f"
+               :active (>= (calc-stack-size) 1)]
               ["Convert (1:) to a fraction" 
                (progn
                  (require 'calc-ext)
                  (call-interactively 'calc-fraction))
-               :keys "c F"])
+               :keys "c F"
+               :active (>= (calc-stack-size) 1)])
         (list "Binary"
               ["Set word size" 
                (progn
@@ -142,60 +165,70 @@
                  (require 'calc-bin)
                  (call-interactively 'calc-clip))
                :keys "b c"
+               :active (>= (calc-stack-size) 1)
                :help "Reduce (1:) modulo 2^wordsize"]
               ["(2:) and (1:)"    
                (progn
                  (require 'calc-bin)
                  (call-interactively 'calc-and))
                :keys "b a"
+               :active (>= (calc-stack-size) 2)
                :help "Bitwise AND [modulo 2^wordsize]"]
               ["(2:) or (1:)"
                (progn
                  (require 'calc-bin)
                  (call-interactively 'calc-or))
                :keys "b o"
+               :active (>= (calc-stack-size) 2)
                :help "Bitwise inclusive OR [modulo 2^wordsize]"]
               ["(2:) xor (1:)"
                (progn 
                  (require 'calc-bin)
                  (call-interactively 'calc-xor))
                :keys "b x"
+               :active (>= (calc-stack-size) 2)
                :help "Bitwise exclusive OR [modulo 2^wordsize]"]
               ["diff(2:,1:)" 
                (progn
                  (require 'calc-bin)
                  (call-interactively 'calc-diff))
                :keys "b d"
+               :active (>= (calc-stack-size) 2)
                :help "Bitwise difference [modulo 2^wordsize]"]
               ["not (1:)"
                (progn
                  (require 'calc-bin)
                  (call-interactively 'calc-not))
                :keys "b n"
+               :active (>= (calc-stack-size) 1)
                :help "Bitwise NOT [modulo 2^wordsize]"]
               ["left shift(1:)"
                (progn
                  (require 'calc-bin)
                  (call-interactively 'calc-lshift-binary))
                :keys "b l"
+               :active (>= (calc-stack-size) 1)
                :help "Shift (1:)[modulo 2^wordsize] one bit left"]
               ["right shift(1:)"
                (progn
                  (require 'calc-bin)
                  (call-interactively 'calc-rshift-binary))
                :keys "b r"
+               :active (>= (calc-stack-size) 1)
                :help "Shift (1:)[modulo 2^wordsize] one bit right, putting 0s on the left"]
               ["arithmetic right shift(1:)"
                (progn
                  (require 'calc-bin)
                  (call-interactively 'calc-rshift-arith))
                :keys "b R"
+               :active (>= (calc-stack-size) 1)
                :help "Shift (1:)[modulo 2^wordsize] one bit right, duplicating the leftmost bit"]
               ["rotate(1:)"
                (progn
                  (require 'calc-bin)
                  (call-interactively 'calc-rotate-binary))
                :keys "b t"
+               :active (>= (calc-stack-size) 1)
                :help "Rotate (1:)[modulo 2^wordsize] one bit left"])
         "-------"
         ["Help on Arithmetic"
@@ -237,69 +270,82 @@
                  (require 'calc-math) 
                  (call-interactively 'calc-ln)) 
                :keys "L"
+               :active (>= (calc-stack-size) 1)
                :help "The natural logarithm"]
               ["e^(1:)"   
                (progn
                  (require 'calc-math)
                  (call-interactively 'calc-exp))
-               :keys "E"]
+               :keys "E"
+               :active (>= (calc-stack-size) 1)]
               ["log(1:) [base 10]" 
                (progn
                  (require 'calc-math)
                  (call-interactively 'calc-log10))
                :keys "H L"
+               :active (>= (calc-stack-size) 1)
                :help "The common logarithm"]
               ["10^(1:)" 
                (progn
                  (require 'calc-math)
                  (let ((calc-inverse-flag t))
                    (call-interactively 'calc-log10)))
-               :keys "I H L"]
+               :keys "I H L"
+               :active (>= (calc-stack-size) 1)]
               ["log(2:) [base(1:)]" 
                (progn
                  (require 'calc-math)
                  (call-interactively 'calc-log))
                :keys "B"
+               :active (>= (calc-stack-size) 2)
                :help "The logarithm with an arbitrary base"]
               ["(2:) ^ (1:)"  
                calc-power 
-               :keys "^"])
+               :keys "^"
+               :active (>= (calc-stack-size) 2)])
         (list "Trigonometric Functions"
               ["sin(1:)"  
                (progn
                  (require 'calc-math)
                  (call-interactively 'calc-sin))
-               :keys "S"]
+               :keys "S"
+               :active (>= (calc-stack-size) 1)]
               ["cos(1:)"  
                (progn
                  (require 'calc-math)
                  (call-interactively 'calc-cos))
-               :keys "C"]
+               :keys "C"
+               :active (>= (calc-stack-size) 1)]
               ["tan(1:)"  
                (progn
                  (require 'calc-math)
                  (call-interactively 'calc-tan))
-               :keys "T"]
+               :keys "T"
+               :active (>= (calc-stack-size) 1)]
               ["arcsin(1:)" 
                (progn
                  (require 'calc-math)
                  (call-interactively 'calc-arcsin))
-               :keys "I S"]
+               :keys "I S"
+               :active (>= (calc-stack-size) 1)]
               ["arccos(1:)" 
                (progn
                  (require 'calc-math)
                  (call-interactively 'calc-arccos))
-               :keys "I C"]
+               :keys "I C"
+               :active (>= (calc-stack-size) 1)]
               ["arctan(1:)" 
                (progn
                  (require 'calc-math)
                  (call-interactively 'calc-arctan))
-               :keys "I T"]
+               :keys "I T"
+               :active (>= (calc-stack-size) 1)]
               ["arctan2(2:,1:)" 
                (progn
                  (require 'calc-math)
                  (call-interactively 'calc-arctan2))
-               :keys "f T"]
+               :keys "f T"
+               :active (>= (calc-stack-size) 2)]
               "--Angle Measure--"
               ["Radians"
                (progn
@@ -327,133 +373,157 @@
                (progn
                  (require 'calc-math)
                  (call-interactively 'calc-sinh))
-               :keys "H S"]
+               :keys "H S"
+               :active (>= (calc-stack-size) 1)]
               ["cosh(1:)" 
                (progn
                  (require 'calc-math)
                  (call-interactively 'calc-cosh))
-               :keys "H C"]
+               :keys "H C"
+               :active (>= (calc-stack-size) 1)]
               ["tanh(1:)" 
                (progn
                  (require 'calc-math)
                  (call-interactively 'calc-tanh))
-               :keys "H T"]
+               :keys "H T"
+               :active (>= (calc-stack-size) 1)]
               ["arcsinh(1:)" 
                (progn
                  (require 'calc-math)
                  (call-interactively 'calc-arcsinh))
-               :keys "I H S"]
+               :keys "I H S"
+               :active (>= (calc-stack-size) 1)]
               ["arccosh(1:)" 
                (progn
                  (require 'calc-math)
                  (call-interactively 'calc-arccosh))
-               :keys "I H C"]
+               :keys "I H C"
+               :active (>= (calc-stack-size) 1)]
               ["arctanh(1:)" 
                (progn
                  (require 'calc-math)
                  (call-interactively 'calc-arctanh))
-               :keys "I H T"])
+               :keys "I H T"
+               :active (>= (calc-stack-size) 1)])
         (list "Advanced Math Functions"
               ["Gamma(1:)" 
                (progn
                  (require 'calc-comb)
                  (call-interactively 'calc-gamma))
                :keys "f g"
+               :active (>= (calc-stack-size) 1)
                :help "The Euler Gamma function"]
               ["GammaP(2:,1:)" 
                (progn
                  (require 'calc-funcs)
                  (call-interactively 'calc-inc-gamma))
                :keys "f G"
+               :active (>= (calc-stack-size) 2)
                :help "The lower incomplete Gamma function"]
               ["Beta(2:,1:)" 
                (progn
                  (require 'calc-funcs)
                  (call-interactively 'calc-beta))
                :keys "f b"
+               :active (>= (calc-stack-size) 2)
                :help "The Euler Beta function"]
               ["BetaI(3:,2:,1:)" 
                (progn
                  (require 'calc-funcs)
                  (call-interactively 'calc-inc-beta))
                :keys "f B"
+               :active (>= (calc-stack-size) 3)
                :help "The incomplete Beta function"]
               ["erf(1:)"
                (progn
                  (require 'calc-funcs)
                  (call-interactively 'calc-erf))
                :keys "f e"
+               :active (>= (calc-stack-size) 1)
                :help "The error function"]
               ["BesselJ(2:,1:)" 
                (progn
                  (require 'calc-funcs)
                  (call-interactively 'calc-bessel-J))
                :keys "f j"
+               :active (>= (calc-stack-size) 2)
                :help "The Bessel function of the first kind (of order (2:))"]
               ["BesselY(2:,1:)" 
                (progn
                  (require 'calc-funcs)
                  (call-interactively 'calc-bessel-Y))
                :keys "f y"
+               :active (>= (calc-stack-size) 2)
                :help "The Bessel function of the second kind (of order (2:))"])
         (list "Combinatorial Functions"
               ["gcd(2:,1:)" 
                (progn
                  (require 'calc-comb)
                  (call-interactively 'calc-gcd))
-                 :keys "k g"]
+                 :keys "k g"
+                 :active (>= (calc-stack-size) 2)]
               ["lcm(2:,1:)" 
                (progn
                  (require 'calc-comb)
                  (call-interactively 'calc-lcm))
-               :keys "k l"]
+               :keys "k l"
+               :active (>= (calc-stack-size) 2)]
               ["factorial(1:)" 
                (progn
                  (require 'calc-comb)
                  (call-interactively 'calc-factorial))
-               :keys "!"]
+               :keys "!"
+               :active (>= (calc-stack-size) 1)]
               ["(2:) choose (1:)" 
                (progn
                  (require 'calc-comb)
                  (call-interactively 'calc-choose))
-               :keys "k c"]
+               :keys "k c"
+               :active (>= (calc-stack-size) 2)]
               ["permutations(2:,1:)" 
                (progn
                  (require 'calc-comb)
                  (call-interactively 'calc-perm))
-               :keys "H k c"]
+               :keys "H k c"
+               :active (>= (calc-stack-size) 2)]
               ["Primality test for (1:)" 
                (progn
                  (require 'calc-comb)
                  (call-interactively 'calc-prime-test))
                :keys "k p"
+               :active (>= (calc-stack-size) 1)
                :help "For large (1:), a probabilistic test"]
               ["Factor (1:) into primes" 
                (progn
                  (require 'calc-comb)
                  (call-interactively 'calc-prime-factors))
-               :keys "k f"]
+               :keys "k f"
+               :active (>= (calc-stack-size) 1)]
               ["Next prime after (1:)"
                (progn
                  (require 'calc-comb)
                  (call-interactively 'calc-next-prime))
-               :keys "k n"]
+               :keys "k n"
+               :active (>= (calc-stack-size) 1)]
               ["Previous prime before (1:)"
                (progn
                  (require 'calc-comb)
                  (call-interactively 'calc-prev-prime))
-               :keys "I k n"]
+               :keys "I k n"
+               :active (>= (calc-stack-size) 1)]
               ["phi(1:)"
                (progn
                  (require 'calc-comb)
                  (call-interactively 'calc-totient))
                :keys "k n"
+               :active (>= (calc-stack-size) 1)
                :help "Euler's totient function"]
               ["random(1:)"
                (progn
                  (require 'calc-comb)
                  (call-interactively 'calc-random))
                :keys "k r"
+               :active (>= (calc-stack-size) 1)
                :help "A random number >=1 and < (1:)"])
         "----"
         ["Help on Scientific Functions"
@@ -467,12 +537,14 @@
                (progn
                  (require 'calc-alg)
                  (call-interactively 'calc-simplify))
-               :keys "a s"]
+               :keys "a s"
+               :active (>= (calc-stack-size) 1)]
               ["Simplify (1:) with extended rules" 
                (progn
                  (require 'calc-alg)
                  (call-interactively 'calc-simplify-extended))
                :keys "a e"
+               :active (>= (calc-stack-size) 1)
                :help "Apply possibly unsafe simplifications"])
         (list "Manipulation"
               ["Expand formula (1:)" 
@@ -480,17 +552,20 @@
                  (require 'calc-alg)
                  (call-interactively 'calc-expand-formula))
                :keys "a \""
+               :active (>= (calc-stack-size) 1)
                :help "Expand (1:) into its defining formula, if possible"]
               ["Evaluate variables in (1:)" 
                (progn
                  (require 'calc-ext)
                  (call-interactively 'calc-evaluate))
-               :keys "="]
+               :keys "="
+               :active (>= (calc-stack-size) 1)]
               ["Make substitution in (1:)" 
                (progn
                  (require 'calc-alg)
                  (call-interactively 'calc-substitute))
                :keys "a b"
+               :active (>= (calc-stack-size) 1)
                :help 
                "Substitute all occurrences of a sub-expression with a new sub-expression"])
         (list "Polynomials"
@@ -498,87 +573,102 @@
                (progn
                  (require 'calc-alg)
                  (call-interactively 'calc-factor))
-               :keys "a f"]
+               :keys "a f"
+               :active (>= (calc-stack-size) 1)]
               ["Collect terms in (1:)" 
                (progn
                  (require 'calc-alg)
                  (call-interactively 'calc-collect)) 
                :keys "a c"
+               :active (>= (calc-stack-size) 1)
                :help "Arrange as a polynomial in a given variable"]
               ["Expand (1:)" 
                (progn
                  (require 'calc-alg)
                  (call-interactively 'calc-expand))
                :keys "a x"
+               :active (>= (calc-stack-size) 1)
                :help "Apply distributive law everywhere"]
               ["Find roots of (1:)" 
                (progn
                  (require 'calcalg2)
                  (call-interactively 'calc-poly-roots))
-               :keys "a P"])
+               :keys "a P"
+               :active (>= (calc-stack-size) 1)])
         (list "Calculus"
               ["Differentiate (1:)" 
                (progn
                  (require 'calcalg2)
                  (call-interactively 'calc-derivative))
-               :keys "a d"]
+               :keys "a d"
+               :active (>= (calc-stack-size) 1)]
               ["Integrate (1:) [indefinite]" 
                (progn
                  (require 'calcalg2)
                  (call-interactively 'calc-integral))
-               :keys "a i"]
+               :keys "a i"
+               :active (>= (calc-stack-size) 1)]
               ["Integrate (1:) [definite]" 
                (progn
                  (require 'calcalg2)
                  (let ((var (read-string "Integration variable: ")))
                    (calc-tabular-command 'calcFunc-integ "Integration" 
                                          "intg" nil var nil nil)))
-               :keys "C-u a i"]
+               :keys "C-u a i"
+               :active (>= (calc-stack-size) 1)]
               ["Integrate (1:) [numeric]"
                (progn
                  (require 'calcalg2)
                  (call-interactively 'calc-num-integral))
                :keys "a I"
+               :active (>= (calc-stack-size) 1)
                :help "Integrate using the open Romberg method"]
               ["Taylor expand (1:)" 
                (progn
                  (require 'calcalg2)
                  (call-interactively 'calc-taylor))
-               :keys "a t"]
+               :keys "a t"
+               :active (>= (calc-stack-size) 1)]
               ["Minimize (2:) [initial guess = (1:)]" 
                (progn
                  (require 'calcalg3)
                  (call-interactively 'calc-find-minimum))
                :keys "a N"
+               :active (>= (calc-stack-size) 2)
                :help "Find a local minimum"]
               ["Maximize (2:) [initial guess = (1:)]" 
                (progn
                  (require 'calcalg3)
                  (call-interactively 'calc-find-maximum))
                :keys "a X"
+               :active (>= (calc-stack-size) 2)
                :help "Find a local maximum"])
         (list "Solving"
               ["Solve equation (1:)" 
                (progn
                  (require 'calcalg2)
                  (call-interactively 'calc-solve-for))
-               :keys "a S"]
+               :keys "a S"
+               :active (>= (calc-stack-size) 1)]
               ["Solve equation (2:) numerically [initial guess = (1:)]" 
                (progn
                  (require 'calcalg3)
                  (call-interactively 'calc-find-root))
-               :keys "a R"]
+               :keys "a R"
+               :active (>= (calc-stack-size) 2)]
               ["Find roots of polynomial (1:)" 
                (progn
                  (require 'calcalg2)
                  (call-interactively 'calc-poly-roots))
-               :keys "a P"])
+               :keys "a P"
+               :active (>= (calc-stack-size) 1)])
         (list "Curve Fitting"
               ["Fit (1:)=[x values, y values] to a curve" 
                (progn
                  (require 'calcalg3)
                  (call-interactively 'calc-curve-fit))
-               :keys "a F"])
+               :keys "a F"
+               :active (>= (calc-stack-size) 1)])
         "----"
         ["Help on Algebra"
          (calc-info-goto-node "Algebra")])
@@ -591,12 +681,14 @@
          (progn
            (require 'calc-graph)
            (call-interactively 'calc-graph-fast))
-         :keys "g f"]
+         :keys "g f"
+         :active (>= (calc-stack-size) 2)]
         ["Graph 3D [(1:)= z values, (2:)= y values, (3:)= x values]" 
          (progn
            (require 'calc-graph)
            (call-interactively 'calc-graph-fast-3d))
-         :keys "g F"]
+         :keys "g F"
+         :active (>= (calc-stack-size) 3)]
         "----"
         ["Help on Graphics"
          (calc-info-goto-node "Graphics")])
@@ -606,14 +698,18 @@
 (defvar calc-vectors-menu
   (list "Matrices/Vectors"
         (list "Matrices"
-              ["(2:) + (1:)"   calc-plus   :keys "+"]
-              ["(2:) - (1:)"   calc-minus  :keys "-"]
-              ["(2:) * (1:)"   calc-times  :keys "*"]
-              ["(1:)^(-1)"    
+              ["(2:) + (1:)"   calc-plus   
+               :keys "+" :active (>= (calc-stack-size) 2)]
+              ["(2:) - (1:)"   calc-minus  
+               :keys "-" :active (>= (calc-stack-size) 2)]
+              ["(2:) * (1:)"   calc-times  
+               :keys "*" :active (>= (calc-stack-size) 2)]
+              ["(1:)^(-1)"
                (progn
                  (require 'calc-arith)
                  (call-interactively 'calc-inv))
-               :keys "&"]
+               :keys "&"
+               :active (>= (calc-stack-size) 1)]
               ["Create an identity matrix"
                (progn 
                  (require 'calc-vec)
@@ -623,179 +719,211 @@
                (progn
                  (require 'calc-vec)
                  (call-interactively 'calc-transpose))
-               :keys "v t"]
+               :keys "v t"
+               :active (>= (calc-stack-size) 1)]
               ["det(1:)" 
                (progn
                  (require 'calc-mtx)
                  (call-interactively 'calc-mdet))
-               :keys "V D"]
+               :keys "V D"
+               :active (>= (calc-stack-size) 1)]
               ["trace(1:)"
                (progn
                  (require 'calc-mtx)
                  (call-interactively 'calc-mtrace))
-               :keys "V T"]
+               :keys "V T"
+               :active (>= (calc-stack-size) 1)]
               ["LUD decompose (1:)" 
                (progn
                  (require 'calc-mtx)
                  (call-interactively 'calc-mlud))
-               :keys "V L"]
+               :keys "V L"
+               :active (>= (calc-stack-size) 1)]
               ["Extract a row from (1:)" 
                (progn
                  (require 'calc-vec)
                  (call-interactively 'calc-mrow))
-               :keys "v r"]
+               :keys "v r"
+               :active (>= (calc-stack-size) 1)]
               ["Extract a column from (1:)" 
                (progn
                  (require 'calc-vec)
                  (call-interactively 'calc-mcol))
-               :keys "v c"])
+               :keys "v c"
+               :active (>= (calc-stack-size) 1)])
         (list "Vectors"
               ["Extract the first element of (1:)"
                (progn
                  (require 'calc-vec)
                  (call-interactively 'calc-head))
-               :keys "v h"]
+               :keys "v h"
+               :active (>= (calc-stack-size) 1)]
               ["Extract an element from (1:)" 
                (progn
                  (require 'calc-vec)
                  (call-interactively 'calc-mrow))
-               :keys "v r"]
+               :keys "v r"
+               :active (>= (calc-stack-size) 1)]
               ["Reverse (1:)" 
                (progn
                  (require 'calc-vec)
                  (call-interactively 'calc-reverse-vector))
-               :keys "v v"]
+               :keys "v v"
+               :active (>= (calc-stack-size) 1)]
               ["Unpack (1:)"
                (progn
                  (require 'calc-vec)
                  (call-interactively 'calc-unpack))
                :keys "v u"
+               :active (>= (calc-stack-size) 1)
                :help "Separate the elements of (1:)"]
               ["(2:) cross (1:)" 
                (progn
                  (require 'calc-vec)
                  (call-interactively 'calc-cross))
                :keys "V C"
+               :active (>= (calc-stack-size) 2)
                :help "The cross product in R^3"]
               ["(2:) dot (1:)" 
                calc-mult 
                :keys "*"
+               :active (>= (calc-stack-size) 2)
                :help "The dot product"]
               ["Map a function across (1:)" 
                (progn
                  (require 'calc-map)
                  (call-interactively 'calc-map))
                :keys "V M"
+               :active (>= (calc-stack-size) 1)
                :help "Apply a function to each element"])
         (list "Vectors As Sets"
               ["Remove duplicates from (1:)" 
                (progn
                  (require 'calc-vec)
                  (call-interactively 'calc-remove-duplicates))
-               :keys "V +"]
+               :keys "V +"
+               :active (>= (calc-stack-size) 1)]
               ["(2:) union (1:)" 
                (progn
                  (require 'calc-vec)
                  (call-interactively 'calc-set-union))
-               :keys "V V"]
+               :keys "V V"
+               :active (>= (calc-stack-size) 2)]
               ["(2:) intersect (1:)" 
                (progn
                  (require 'calc-vec)
                  (call-interactively 'calc-set-intersect))
-               :keys "V ^"]
+               :keys "V ^"
+               :active (>= (calc-stack-size) 2)]
               ["(2:) \\ (1:)" 
                (progn
                  (require 'calc-vec)
                  (call-interactively 'calc-set-difference))
                :keys "V -"
-               :help "Set difference"])
+               :help "Set difference"
+               :active (>= (calc-stack-size) 2)])
         (list "Statistics On Vectors"
               ["length(1:)" 
                (progn
                  (require 'calc-stat)
                  (call-interactively 'calc-vector-count))
                :keys "u #"
+               :active (>= (calc-stack-size) 1)
                :help "The number of data values"]
               ["sum(1:)"    
                (progn
                  (require 'calc-stat)
                  (call-interactively 'calc-vector-sum))
                :keys "u +"
+               :active (>= (calc-stack-size) 1)
                :help "The sum of the data values"]
               ["max(1:)"    
                (progn
                  (require 'calc-stat)
                  (call-interactively 'calc-vector-max))  
                :keys "u x"
+               :active (>= (calc-stack-size) 1)
                :help "The maximum of the data values"]
               ["min(1:)"    
                (progn
                  (require 'calc-stat)
                  (call-interactively 'calc-vector-min))  
                :keys "u N"
+               :active (>= (calc-stack-size) 1)
                :help "The minumum of the data values"]
               ["mean(1:)"   
                (progn
                  (require 'calc-stat)
                  (call-interactively 'calc-vector-mean))
                :keys "u M"
+               :active (>= (calc-stack-size) 1)
                :help "The average (arithmetic mean) of the data values"]
               ["mean(1:) with error"
               (progn
                 (require 'calc-stat)
                 (call-interactively 'calc-vector-mean-error))
               :keys "I u M"
+              :active (>= (calc-stack-size) 1)
               :help "The average (arithmetic mean) of the data values as an error form"]
               ["sdev(1:)"   
                (progn
                  (require 'calc-stat)
                  (call-interactively 'calc-vector-sdev))
                :keys "u S"
+               :active (>= (calc-stack-size) 1)
                :help "The sample sdev, sqrt[sum((values - mean)^2)/(N-1)]"]
               ["variance(1:)" 
                (progn
                  (require 'calc-stat)
                  (call-interactively 'calc-vector-variance))
                :keys "H u S"
+               :active (>= (calc-stack-size) 1)
                :help "The sample variance, sum((values - mean)^2)/(N-1)"]
               ["population sdev(1:)" 
                (progn
                  (require 'calc-stat)
                  (call-interactively 'calc-vector-pop-sdev))
                :keys "I u S"
+               :active (>= (calc-stack-size) 1)
                :help "The population sdev, sqrt[sum((values - mean)^2)/N]"]
               ["population variance(1:)" 
                (progn
                  (require 'calc-stat)
                  (call-interactively 'calc-vector-pop-variance))
                :keys "H I u S"
+               :active (>= (calc-stack-size) 1)
                :help "The population variance, sum((values - mean)^2)/N"]
               ["median(1:)"
                (progn
                  (require 'calc-stat)
                  (call-interactively 'calc-vector-median))
                :keys "H u M"
+               :active (>= (calc-stack-size) 1)
                :help "The median of the data values"]
               ["harmonic mean(1:)"
                (progn
                  (require 'calc-stat)
                  (call-interactively 'calc-vector-harmonic-mean))
-               :keys "H I u M"]
+               :keys "H I u M"
+               :active (>= (calc-stack-size) 1)]
               ["geometric mean(1:)"
                (progn
                  (require 'calc-stat)
                  (call-interactively 'calc-vector-geometric-mean))
-               :keys "u G"]
+               :keys "u G"
+               :active (>= (calc-stack-size) 1)]
               ["arithmetic-geometric mean(1:)"
                (progn
                  (require 'calc-stat)
                  (let ((calc-hyperbolic-flag t))
                    (call-interactively 'calc-vector-geometric-mean)))
-               :keys "H u G"]
+               :keys "H u G"
+               :active (>= (calc-stack-size) 1)]
                ["RMS(1:)"
                 (progn (require 'calc-arith)
                        (call-interactively 'calc-abs))
                 :keys "A"
+                :active (>= (calc-stack-size) 1)
                 :help "The root-mean-square, or quadratic mean"])
         ["Abbreviate long vectors"
          (progn
@@ -815,17 +943,20 @@
          (progn
            (require 'calc-units)
            (call-interactively 'calc-convert-units ))
-         :keys "u c"]
+         :keys "u c"
+         :active (>= (calc-stack-size) 1)]
         ["Convert temperature in (1:)" 
          (progn
            (require 'calc-units)
            (call-interactively 'calc-convert-temperature))
-         :keys "u t"]
+         :keys "u t"
+         :active (>= (calc-stack-size) 1)]
         ["Simplify units in (1:)" 
          (progn
            (require 'calc-units)
            (call-interactively 'calc-simplify-units))
-         :keys "u s"]
+         :keys "u s"
+         :active (>= (calc-stack-size) 1)]
         ["View units table" 
          (progn
            (require 'calc-units)
@@ -842,7 +973,8 @@
          (progn
            (require 'calc-store)
            (call-interactively 'calc-store))
-         :keys "s s"]
+         :keys "s s"
+         :active (>= (calc-stack-size) 1)]
         ["Recall a variable value" 
           (progn
             (require 'calc-store)
@@ -857,7 +989,8 @@
          (progn
            (require 'calc-store)
            (call-interactively 'calc-store-exchange))
-         :keys "s x"]
+         :keys "s x"
+         :active (>= (calc-stack-size) 1)]
         ["Clear variable value" 
          (progn
            (require 'calc-store)
@@ -867,12 +1000,14 @@
          (progn
            (require 'calc-ext)
            (call-interactively 'calc-evaluate))
-         :keys "="]
+         :keys "="
+         :active (>= (calc-stack-size) 1)]
         ["Evaluate (1:), assigning a value to a variable" 
          (progn
            (require 'calc-store)
            (call-interactively 'calc-let))
          :keys "s l"
+         :active (>= (calc-stack-size) 1)
          :help "Evaluate (1:) under a temporary assignment of a variable"]
         "----"
         ["Help on Variables"
@@ -883,18 +1018,22 @@
   (list "Stack"
         ["Remove (1:)" 
          calc-pop 
-         :keys "DEL"]
+         :keys "DEL"
+         :active (>= (calc-stack-size) 1)]
         ["Switch (1:) and (2:)" 
          calc-roll-down 
-         :keys "TAB"]
+         :keys "TAB"
+         :active (>= (calc-stack-size) 2)]
         ["Duplicate (1:)" 
          calc-enter 
-         :keys "RET"]
+         :keys "RET"
+         :active (>= (calc-stack-size) 1)]
         ["Edit (1:)" 
          (progn
            (require 'calc-yank)
            (call-interactively calc-edit))
-         :keys "`"]
+         :keys "`"
+         :active (>= (calc-stack-size) 1)]
         "----"
         ["Help on Stack"
          (calc-info-goto-node "Stack and Trail")])
@@ -1051,6 +1190,47 @@
                :keys "d e"
                :style radio
                :selected (eq (car-safe calc-float-format) 'eng)])
+        (list "Complex Format"             
+              ["Default"
+               (progn
+                 (require 'calc-cplx)
+                 (calc-complex-notation))
+               :style radio
+               :selected (not calc-complex-format)
+               :keys "d c"
+               :help "Display complex numbers as ordered pairs."]
+              ["i notation"
+               (progn
+                 (require 'calc-cplx)
+                 (calc-i-notation))
+               :style radio
+               :selected (eq calc-complex-format 'i)
+               :keys "d i"
+               :help "Display complex numbers as a+bi."]
+              ["j notation"
+               (progn
+                 (require 'calc-cplx)
+                 (calc-i-notation))
+               :style radio
+               :selected (eq calc-complex-format 'j)
+               :keys "d j"
+               :help "Display complex numbers as a+bj."]
+              ["Other"
+               (calc-complex-notation)
+               :style radio
+               :selected (and calc-complex-format
+                              (not (eq calc-complex-format 'i))
+                              (not (eq calc-complex-format 'j)))
+               :active nil]
+              "----"
+              ["Polar mode"
+               (progn
+                 (require 'calc-cplx)
+                 (calc-polar-mode nil))
+               :style toggle
+               :selected (eq calc-complex-mode 'polar)
+               :keys "m p"
+               :help "Prefer polar form for complex numbers."])
         (list "Algebraic"
               ["Normal"
                (progn
@@ -1178,7 +1358,21 @@
                  (call-interactively 'calc-giac-language))
                :keys "d A"
                :style radio
-               :selected (eq calc-language 'giac)])
+               :selected (eq calc-language 'giac)]
+              ["Mma"
+               (progn
+                 (require 'calc-lang)
+                 (call-interactively 'calc-mathematica-language))
+               :keys "d M"
+               :style radio
+               :selected (eq calc-language 'math)]
+              ["Maple"
+               (progn
+                 (require 'calc-lang)
+                 (call-interactively 'calc-maple-language))
+               :keys "d W"
+               :style radio
+               :selected (eq calc-language 'maple)])
         "----"
         ["Save mode settings" calc-save-modes :keys "m m"]
         "----"