emacs/lisp/calc/calc-ext.el

3432 lines
127 KiB
EmacsLisp
Raw Normal View History

2018-11-20 16:09:35 -05:00
;;; calc-ext.el --- various extension functions for Calc -*- lexical-binding:t -*-
2022-01-01 02:45:51 -05:00
;; Copyright (C) 1990-1993, 2001-2022 Free Software Foundation, Inc.
;; Author: David Gillespie <daveg@synaptics.com>
2001-11-06 18:59:06 +00:00
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
2001-11-06 18:59:06 +00:00
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
2001-11-06 18:59:06 +00:00
;;; Commentary:
2001-11-06 18:59:06 +00:00
;;; Code:
2001-11-06 18:59:06 +00:00
(require 'calc)
2001-11-06 18:59:06 +00:00
(require 'calc-macs)
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(require 'cl-lib)
2001-11-06 18:59:06 +00:00
;; Declare functions which are defined elsewhere.
(declare-function math-clip "calc-bin" (a &optional w))
(declare-function math-round "calc-arith" (a &optional prec))
(declare-function math-simplify "calc-alg" (top-expr))
(declare-function math-simplify-extended "calc-alg" (a))
(declare-function math-simplify-units "calc-units" (a))
(declare-function calc-set-language "calc-lang" (lang &optional option no-refresh))
(declare-function calc-flush-caches "calc-stuff" (&optional inhibit-msg))
(declare-function calc-save-modes "calc-mode" ())
(declare-function calc-embedded-modes-change "calc-embed" (vars))
(declare-function calc-embedded-var-change "calc-embed" (var &optional buf))
(declare-function math-mul-float "calc-arith" (a b))
(declare-function math-arctan-raw "calc-math" (x))
(declare-function math-sqrt-raw "calc-math" (a &optional guess))
(declare-function math-sqrt-float "calc-math" (a &optional guess))
(declare-function math-exp-minus-1-raw "calc-math" (x))
(declare-function math-normalize-polar "calc-cplx" (a))
(declare-function math-normalize-hms "calc-forms" (a))
(declare-function math-normalize-mod "calc-forms" (a))
(declare-function math-make-sdev "calc-forms" (x sigma))
(declare-function math-make-intv "calc-forms" (mask lo hi))
(declare-function math-normalize-logical-op "calc-prog" (a))
(declare-function math-possible-signs "calc-arith" (a &optional origin))
(declare-function math-infinite-dir "calc-math" (a &optional inf))
(declare-function math-calcFunc-to-var "calc-map" (f))
(declare-function calc-embedded-evaluate-expr "calc-embed" (x))
(declare-function math-known-nonzerop "calc-arith" (a))
(declare-function math-read-expr-level "calc-aent" (exp-prec &optional exp-term))
2007-11-27 07:58:30 +00:00
(declare-function math-read-big-rec "calc-lang" (math-rb-h1 math-rb-v1 math-rb-h2 math-rb-v2 &optional baseline prec short))
(declare-function math-read-big-balance "calc-lang" (h v what &optional commas))
(declare-function math-format-date "calc-forms" (math-fd-date))
(declare-function math-vector-is-string "calccomp" (a))
(declare-function math-vector-to-string "calccomp" (a &optional quoted))
(declare-function math-format-radix-float "calc-bin" (a prec))
(declare-function math-compose-expr "calccomp" (a prec &optional div))
(declare-function math-abs "calc-arith" (a))
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(declare-function math-format-binary "calc-bin" (a))
(declare-function math-format-radix "calc-bin" (a))
(declare-function math-compute-max-digits "calc-bin" (w r))
(declare-function math-map-vec "calc-vec" (f a))
(declare-function math-make-frac "calc-frac" (num den))
(defvar math-simplifying nil)
(defvar math-living-dangerously nil) ; true if unsafe simplifications are okay.
(defvar math-integrating nil)
(defvar math-rewrite-selections nil)
(defvar math-compose-level 0)
(defvar math-comp-selected nil)
(defvar math-comp-tagged nil)
(defvar math-comp-sel-hpos nil)
(defvar math-comp-sel-vpos nil)
(defvar math-comp-sel-cpos nil)
(defvar math-compose-hash-args nil)
(defvar calc-alg-map)
(defvar calc-alg-esc-map)
2018-11-20 16:09:35 -05:00
;; The following was made a function so that it could be byte-compiled.
2001-11-06 18:59:06 +00:00
(defun calc-init-extensions ()
(define-key calc-mode-map ":" 'calc-fdiv)
(define-key calc-mode-map "\\" 'calc-idiv)
(define-key calc-mode-map "|" 'calc-concat)
(define-key calc-mode-map "!" 'calc-factorial)
(define-key calc-mode-map "C" 'calc-cos)
(define-key calc-mode-map "E" 'calc-exp)
(define-key calc-mode-map "H" 'calc-hyperbolic)
(define-key calc-mode-map "I" 'calc-inverse)
(define-key calc-mode-map "J" 'calc-conj)
(define-key calc-mode-map "L" 'calc-ln)
(define-key calc-mode-map "N" 'calc-eval-num)
(define-key calc-mode-map "O" 'calc-option)
2001-11-06 18:59:06 +00:00
(define-key calc-mode-map "P" 'calc-pi)
(define-key calc-mode-map "Q" 'calc-sqrt)
(define-key calc-mode-map "R" 'calc-round)
(define-key calc-mode-map "S" 'calc-sin)
(define-key calc-mode-map "T" 'calc-tan)
(define-key calc-mode-map "U" 'calc-undo)
(define-key calc-mode-map "X" 'calc-call-last-kbd-macro)
(define-key calc-mode-map "o" 'calc-realign)
(define-key calc-mode-map "p" 'calc-precision)
(define-key calc-mode-map "w" 'calc-why)
(define-key calc-mode-map "x" 'calc-execute-extended-command)
(define-key calc-mode-map "y" 'calc-copy-to-buffer)
(define-key calc-mode-map "(" 'calc-begin-complex)
(define-key calc-mode-map ")" 'calc-end-complex)
(define-key calc-mode-map "[" 'calc-begin-vector)
(define-key calc-mode-map "]" 'calc-end-vector)
(define-key calc-mode-map "," 'calc-comma)
(define-key calc-mode-map ";" 'calc-semi)
(define-key calc-mode-map "`" 'calc-edit)
(define-key calc-mode-map "=" 'calc-evaluate)
(define-key calc-mode-map "~" 'calc-num-prefix)
(define-key calc-mode-map "<" 'calc-scroll-left)
(define-key calc-mode-map ">" 'calc-scroll-right)
(define-key calc-mode-map "{" 'calc-scroll-down)
(define-key calc-mode-map "}" 'calc-scroll-up)
(define-key calc-mode-map "\C-k" 'calc-kill)
(define-key calc-mode-map "\M-k" 'calc-copy-as-kill)
(define-key calc-mode-map "\C-w" 'calc-kill-region)
(define-key calc-mode-map "\M-w" 'calc-copy-region-as-kill)
(define-key calc-mode-map "\M-\C-w" 'kill-ring-save)
2001-11-06 18:59:06 +00:00
(define-key calc-mode-map "\M-\C-m" 'calc-last-args)
(define-key calc-mode-map "a" nil)
(define-key calc-mode-map "a?" 'calc-a-prefix-help)
(define-key calc-mode-map "aa" 'calc-apart)
(define-key calc-mode-map "ab" 'calc-substitute)
(define-key calc-mode-map "ac" 'calc-collect)
(define-key calc-mode-map "ad" 'calc-derivative)
(define-key calc-mode-map "ae" 'calc-simplify-extended)
(define-key calc-mode-map "af" 'calc-factor)
(define-key calc-mode-map "ag" 'calc-poly-gcd)
(define-key calc-mode-map "ai" 'calc-integral)
(define-key calc-mode-map "am" 'calc-match)
(define-key calc-mode-map "an" 'calc-normalize-rat)
(define-key calc-mode-map "ap" 'calc-poly-interp)
(define-key calc-mode-map "ar" 'calc-rewrite)
(define-key calc-mode-map "as" 'calc-simplify)
(define-key calc-mode-map "at" 'calc-taylor)
(define-key calc-mode-map "av" 'calc-alg-evaluate)
(define-key calc-mode-map "ax" 'calc-expand)
(define-key calc-mode-map "aA" 'calc-abs)
(define-key calc-mode-map "aF" 'calc-curve-fit)
(define-key calc-mode-map "aI" 'calc-num-integral)
(define-key calc-mode-map "aM" 'calc-map-equation)
(define-key calc-mode-map "aN" 'calc-find-minimum)
(define-key calc-mode-map "aP" 'calc-poly-roots)
(define-key calc-mode-map "aS" 'calc-solve-for)
(define-key calc-mode-map "aR" 'calc-find-root)
(define-key calc-mode-map "aT" 'calc-tabulate)
(define-key calc-mode-map "aX" 'calc-find-maximum)
(define-key calc-mode-map "a+" 'calc-summation)
(define-key calc-mode-map "a-" 'calc-alt-summation)
(define-key calc-mode-map "a*" 'calc-product)
(define-key calc-mode-map "a\\" 'calc-poly-div)
(define-key calc-mode-map "a%" 'calc-poly-rem)
(define-key calc-mode-map "a/" 'calc-poly-div-rem)
(define-key calc-mode-map "a=" 'calc-equal-to)
(define-key calc-mode-map "a#" 'calc-not-equal-to)
(define-key calc-mode-map "a<" 'calc-less-than)
(define-key calc-mode-map "a>" 'calc-greater-than)
(define-key calc-mode-map "a[" 'calc-less-equal)
(define-key calc-mode-map "a]" 'calc-greater-equal)
(define-key calc-mode-map "a." 'calc-remove-equal)
(define-key calc-mode-map "a{" 'calc-in-set)
(define-key calc-mode-map "a&" 'calc-logical-and)
(define-key calc-mode-map "a|" 'calc-logical-or)
(define-key calc-mode-map "a!" 'calc-logical-not)
(define-key calc-mode-map "a:" 'calc-logical-if)
(define-key calc-mode-map "a_" 'calc-subscript)
(define-key calc-mode-map "a\"" 'calc-expand-formula)
(define-key calc-mode-map "b" nil)
(define-key calc-mode-map "b?" 'calc-b-prefix-help)
(define-key calc-mode-map "ba" 'calc-and)
(define-key calc-mode-map "bc" 'calc-clip)
(define-key calc-mode-map "bd" 'calc-diff)
(define-key calc-mode-map "bl" 'calc-lshift-binary)
(define-key calc-mode-map "bn" 'calc-not)
(define-key calc-mode-map "bo" 'calc-or)
(define-key calc-mode-map "bp" 'calc-pack-bits)
(define-key calc-mode-map "br" 'calc-rshift-binary)
(define-key calc-mode-map "bt" 'calc-rotate-binary)
(define-key calc-mode-map "bu" 'calc-unpack-bits)
(define-key calc-mode-map "bw" 'calc-word-size)
(define-key calc-mode-map "bx" 'calc-xor)
(define-key calc-mode-map "bB" 'calc-log)
(define-key calc-mode-map "bD" 'calc-fin-ddb)
(define-key calc-mode-map "bF" 'calc-fin-fv)
(define-key calc-mode-map "bI" 'calc-fin-irr)
(define-key calc-mode-map "bL" 'calc-lshift-arith)
(define-key calc-mode-map "bM" 'calc-fin-pmt)
(define-key calc-mode-map "bN" 'calc-fin-npv)
(define-key calc-mode-map "bP" 'calc-fin-pv)
(define-key calc-mode-map "bR" 'calc-rshift-arith)
(define-key calc-mode-map "bS" 'calc-fin-sln)
(define-key calc-mode-map "bT" 'calc-fin-rate)
(define-key calc-mode-map "bY" 'calc-fin-syd)
(define-key calc-mode-map "b#" 'calc-fin-nper)
(define-key calc-mode-map "b%" 'calc-percent-change)
(define-key calc-mode-map "c" nil)
(define-key calc-mode-map "c?" 'calc-c-prefix-help)
(define-key calc-mode-map "cc" 'calc-clean)
(define-key calc-mode-map "cd" 'calc-to-degrees)
(define-key calc-mode-map "cf" 'calc-float)
(define-key calc-mode-map "ch" 'calc-to-hms)
(define-key calc-mode-map "cp" 'calc-polar)
(define-key calc-mode-map "cr" 'calc-to-radians)
(define-key calc-mode-map "cC" 'calc-cos)
(define-key calc-mode-map "cF" 'calc-fraction)
(define-key calc-mode-map "c%" 'calc-convert-percent)
(define-key calc-mode-map "d" nil)
(define-key calc-mode-map "d?" 'calc-d-prefix-help)
(define-key calc-mode-map "d0" 'calc-decimal-radix)
(define-key calc-mode-map "d2" 'calc-binary-radix)
(define-key calc-mode-map "d6" 'calc-hex-radix)
(define-key calc-mode-map "d8" 'calc-octal-radix)
(define-key calc-mode-map "db" 'calc-line-breaking)
(define-key calc-mode-map "dc" 'calc-complex-notation)
(define-key calc-mode-map "dd" 'calc-date-notation)
(define-key calc-mode-map "de" 'calc-eng-notation)
(define-key calc-mode-map "df" 'calc-fix-notation)
(define-key calc-mode-map "dg" 'calc-group-digits)
(define-key calc-mode-map "dh" 'calc-hms-notation)
(define-key calc-mode-map "di" 'calc-i-notation)
(define-key calc-mode-map "dj" 'calc-j-notation)
(define-key calc-mode-map "dl" 'calc-line-numbering)
(define-key calc-mode-map "dn" 'calc-normal-notation)
(define-key calc-mode-map "do" 'calc-over-notation)
(define-key calc-mode-map "dp" 'calc-show-plain)
(define-key calc-mode-map "dr" 'calc-radix)
(define-key calc-mode-map "ds" 'calc-sci-notation)
(define-key calc-mode-map "dt" 'calc-truncate-stack)
(define-key calc-mode-map "dw" 'calc-auto-why)
(define-key calc-mode-map "dz" 'calc-leading-zeros)
(define-key calc-mode-map "dA" 'calc-giac-language)
2001-11-06 18:59:06 +00:00
(define-key calc-mode-map "dB" 'calc-big-language)
(define-key calc-mode-map "dD" 'calc-redo)
(define-key calc-mode-map "dC" 'calc-c-language)
(define-key calc-mode-map "dE" 'calc-eqn-language)
(define-key calc-mode-map "dF" 'calc-fortran-language)
(define-key calc-mode-map "dM" 'calc-mathematica-language)
(define-key calc-mode-map "dN" 'calc-normal-language)
(define-key calc-mode-map "dO" 'calc-flat-language)
(define-key calc-mode-map "dP" 'calc-pascal-language)
(define-key calc-mode-map "dT" 'calc-tex-language)
(define-key calc-mode-map "dL" 'calc-latex-language)
2001-11-06 18:59:06 +00:00
(define-key calc-mode-map "dU" 'calc-unformatted-language)
(define-key calc-mode-map "dW" 'calc-maple-language)
(define-key calc-mode-map "dX" 'calc-maxima-language)
(define-key calc-mode-map "dY" 'calc-yacas-language)
2001-11-06 18:59:06 +00:00
(define-key calc-mode-map "d[" 'calc-truncate-up)
(define-key calc-mode-map "d]" 'calc-truncate-down)
(define-key calc-mode-map "d." 'calc-point-char)
(define-key calc-mode-map "d," 'calc-group-char)
(define-key calc-mode-map "d\"" 'calc-display-strings)
(define-key calc-mode-map "d<" 'calc-left-justify)
(define-key calc-mode-map "d=" 'calc-center-justify)
(define-key calc-mode-map "d>" 'calc-right-justify)
(define-key calc-mode-map "d{" 'calc-left-label)
(define-key calc-mode-map "d}" 'calc-right-label)
(define-key calc-mode-map "d'" 'calc-display-raw)
(define-key calc-mode-map "d " 'calc-refresh)
(define-key calc-mode-map "d\r" 'calc-refresh-top)
(define-key calc-mode-map "d@" 'calc-toggle-banner)
2001-11-06 18:59:06 +00:00
(define-key calc-mode-map "f" nil)
(define-key calc-mode-map "f?" 'calc-f-prefix-help)
(define-key calc-mode-map "fb" 'calc-beta)
(define-key calc-mode-map "fe" 'calc-erf)
(define-key calc-mode-map "fg" 'calc-gamma)
(define-key calc-mode-map "fh" 'calc-hypot)
(define-key calc-mode-map "fi" 'calc-im)
(define-key calc-mode-map "fj" 'calc-bessel-J)
(define-key calc-mode-map "fn" 'calc-min)
(define-key calc-mode-map "fr" 'calc-re)
(define-key calc-mode-map "fs" 'calc-sign)
(define-key calc-mode-map "fx" 'calc-max)
(define-key calc-mode-map "fy" 'calc-bessel-Y)
(define-key calc-mode-map "fA" 'calc-abssqr)
(define-key calc-mode-map "fB" 'calc-inc-beta)
(define-key calc-mode-map "fE" 'calc-expm1)
(define-key calc-mode-map "fF" 'calc-floor)
(define-key calc-mode-map "fG" 'calc-inc-gamma)
(define-key calc-mode-map "fI" 'calc-ilog)
(define-key calc-mode-map "fL" 'calc-lnp1)
(define-key calc-mode-map "fM" 'calc-mant-part)
(define-key calc-mode-map "fQ" 'calc-isqrt)
(define-key calc-mode-map "fS" 'calc-scale-float)
(define-key calc-mode-map "fT" 'calc-arctan2)
(define-key calc-mode-map "fX" 'calc-xpon-part)
(define-key calc-mode-map "f[" 'calc-decrement)
(define-key calc-mode-map "f]" 'calc-increment)
(define-key calc-mode-map "g" nil)
(define-key calc-mode-map "g?" 'calc-g-prefix-help)
(define-key calc-mode-map "ga" 'calc-graph-add)
(define-key calc-mode-map "gb" 'calc-graph-border)
(define-key calc-mode-map "gc" 'calc-graph-clear)
(define-key calc-mode-map "gd" 'calc-graph-delete)
(define-key calc-mode-map "gf" 'calc-graph-fast)
(define-key calc-mode-map "gg" 'calc-graph-grid)
(define-key calc-mode-map "gh" 'calc-graph-header)
(define-key calc-mode-map "gk" 'calc-graph-key)
(define-key calc-mode-map "gj" 'calc-graph-juggle)
(define-key calc-mode-map "gl" 'calc-graph-log-x)
(define-key calc-mode-map "gn" 'calc-graph-name)
(define-key calc-mode-map "gp" 'calc-graph-plot)
(define-key calc-mode-map "gq" 'calc-graph-quit)
(define-key calc-mode-map "gr" 'calc-graph-range-x)
(define-key calc-mode-map "gs" 'calc-graph-line-style)
(define-key calc-mode-map "gt" 'calc-graph-title-x)
(define-key calc-mode-map "gv" 'calc-graph-view-commands)
(define-key calc-mode-map "gx" 'calc-graph-display)
(define-key calc-mode-map "gz" 'calc-graph-zero-x)
(define-key calc-mode-map "gA" 'calc-graph-add-3d)
(define-key calc-mode-map "gC" 'calc-graph-command)
(define-key calc-mode-map "gD" 'calc-graph-device)
(define-key calc-mode-map "gF" 'calc-graph-fast-3d)
(define-key calc-mode-map "gG" 'calc-argument)
(define-key calc-mode-map "gH" 'calc-graph-hide)
(define-key calc-mode-map "gK" 'calc-graph-kill)
(define-key calc-mode-map "gL" 'calc-graph-log-y)
(define-key calc-mode-map "gN" 'calc-graph-num-points)
(define-key calc-mode-map "gO" 'calc-graph-output)
(define-key calc-mode-map "gP" 'calc-graph-print)
(define-key calc-mode-map "gR" 'calc-graph-range-y)
(define-key calc-mode-map "gS" 'calc-graph-point-style)
(define-key calc-mode-map "gT" 'calc-graph-title-y)
(define-key calc-mode-map "gV" 'calc-graph-view-trail)
(define-key calc-mode-map "gX" 'calc-graph-geometry)
(define-key calc-mode-map "gZ" 'calc-graph-zero-y)
(define-key calc-mode-map "g\C-l" 'calc-graph-log-z)
(define-key calc-mode-map "g\C-r" 'calc-graph-range-z)
(define-key calc-mode-map "g\C-t" 'calc-graph-title-z)
(define-key calc-mode-map "h" 'calc-help-prefix)
(define-key calc-mode-map "j" nil)
(define-key calc-mode-map "j?" 'calc-j-prefix-help)
(define-key calc-mode-map "ja" 'calc-select-additional)
(define-key calc-mode-map "jb" 'calc-break-selections)
(define-key calc-mode-map "jc" 'calc-clear-selections)
(define-key calc-mode-map "jd" 'calc-show-selections)
(define-key calc-mode-map "je" 'calc-enable-selections)
(define-key calc-mode-map "jl" 'calc-select-less)
(define-key calc-mode-map "jm" 'calc-select-more)
(define-key calc-mode-map "jn" 'calc-select-next)
(define-key calc-mode-map "jo" 'calc-select-once)
(define-key calc-mode-map "jp" 'calc-select-previous)
(define-key calc-mode-map "jr" 'calc-rewrite-selection)
(define-key calc-mode-map "js" 'calc-select-here)
(define-key calc-mode-map "jv" 'calc-sel-evaluate)
(define-key calc-mode-map "ju" 'calc-unselect)
(define-key calc-mode-map "jC" 'calc-sel-commute)
(define-key calc-mode-map "jD" 'calc-sel-distribute)
(define-key calc-mode-map "jE" 'calc-sel-jump-equals)
(define-key calc-mode-map "jI" 'calc-sel-isolate)
(define-key calc-mode-map "jJ" 'calc-conj)
(define-key calc-mode-map "jL" 'calc-commute-left)
(define-key calc-mode-map "jM" 'calc-sel-merge)
(define-key calc-mode-map "jN" 'calc-sel-negate)
(define-key calc-mode-map "jO" 'calc-select-once-maybe)
(define-key calc-mode-map "jR" 'calc-commute-right)
(define-key calc-mode-map "jS" 'calc-select-here-maybe)
(define-key calc-mode-map "jU" 'calc-sel-unpack)
(define-key calc-mode-map "j&" 'calc-sel-invert)
(define-key calc-mode-map "j\r" 'calc-copy-selection)
(define-key calc-mode-map "j\n" 'calc-copy-selection)
(define-key calc-mode-map "j\010" 'calc-del-selection)
(define-key calc-mode-map "j\177" 'calc-del-selection)
(define-key calc-mode-map "j'" 'calc-enter-selection)
(define-key calc-mode-map "j`" 'calc-edit-selection)
(define-key calc-mode-map "j+" 'calc-sel-add-both-sides)
(define-key calc-mode-map "j-" 'calc-sel-sub-both-sides)
(define-key calc-mode-map "j*" 'calc-sel-mult-both-sides)
(define-key calc-mode-map "j/" 'calc-sel-div-both-sides)
(define-key calc-mode-map "j\"" 'calc-sel-expand-formula)
(define-key calc-mode-map "k" nil)
(define-key calc-mode-map "k?" 'calc-k-prefix-help)
(define-key calc-mode-map "ka" 'calc-random-again)
(define-key calc-mode-map "kb" 'calc-bernoulli-number)
(define-key calc-mode-map "kc" 'calc-choose)
(define-key calc-mode-map "kd" 'calc-double-factorial)
(define-key calc-mode-map "ke" 'calc-euler-number)
(define-key calc-mode-map "kf" 'calc-prime-factors)
(define-key calc-mode-map "kg" 'calc-gcd)
(define-key calc-mode-map "kh" 'calc-shuffle)
(define-key calc-mode-map "kl" 'calc-lcm)
(define-key calc-mode-map "km" 'calc-moebius)
(define-key calc-mode-map "kn" 'calc-next-prime)
(define-key calc-mode-map "kp" 'calc-prime-test)
(define-key calc-mode-map "kr" 'calc-random)
(define-key calc-mode-map "ks" 'calc-stirling-number)
(define-key calc-mode-map "kt" 'calc-totient)
(define-key calc-mode-map "kB" 'calc-utpb)
(define-key calc-mode-map "kC" 'calc-utpc)
(define-key calc-mode-map "kE" 'calc-extended-gcd)
(define-key calc-mode-map "kF" 'calc-utpf)
(define-key calc-mode-map "kK" 'calc-keep-args)
(define-key calc-mode-map "kN" 'calc-utpn)
(define-key calc-mode-map "kP" 'calc-utpp)
(define-key calc-mode-map "kT" 'calc-utpt)
(define-key calc-mode-map "l" nil)
* lisp/calc/README: Mention musical notes. * lisp/calc-units.el (calc-lu-quant): Rename from `calc-logunits-quantity'. (calcFunc-lupquant): Rename from `calcFunc-powerquant'. (calcFunc-lufquant): Rename from `calcFunc-fieldquant'. (calc-db): Rename from `calc-dblevel'. (calcFunc-dbpower): Rename from `calcFunc-dbpowerlevel'. (calcFunc-dbfield): Rename from `calcFunc-dbfieldlevel'. (calc-np): Rename from `calc-nplevel'. (calcFunc-nppower): Rename from `calcFunc-nppowerlevel'. (calcFunc-npfield): Rename from `calcFunc-npfieldlevel'. (calc-lu-plus): Rename from `calc-logunits-add'. (calcFunc-lupadd): Rename from `calcFunc-lupoweradd'. (calcFunc-lufadd): Rename from `calcFunc-lufieldadd'. (calc-lu-minus): Rename from `calc-logunits-sub'. (calcFunc-lupsub): Rename from `calcFunc-lupowersub'. (calcFunc-lufsub): Rename from `calcFunc-lufieldsub'. (calc-lu-times): Rename from `calc-logunits-mul'. (calcFunc-lupmul): Rename from `calcFunc-lupowermul'. (calcFunc-lufmul): Rename from `calcFunc-lufieldmul'. (calc-lu-divide): Rename from `calc-logunits-div'. (calcFunc-lupdiv): Rename from `calcFunc-lupowerdiv'. (calcFunc-lufdiv): Rename from `calcFunc-lufielddiv'. * lisp/calc/calc-ext.el (calc-init-extensions): Update the names of the functions being autoloaded. * lisp/calc/calc.el (calc-lu-power-reference): Rename from `calc-logunits-power-reference'. (calc-lu-field-reference): Rename from `calc-logunits-field-reference'. * lisp/calc/calc-help (calc-l-prefix-help): Mention musical note functions. * doc/misc/calc.texi (Logarithmic Units): Update the function names.
2011-03-16 20:30:08 -05:00
(define-key calc-mode-map "lq" 'calc-lu-quant)
(define-key calc-mode-map "ld" 'calc-db)
(define-key calc-mode-map "ln" 'calc-np)
(define-key calc-mode-map "l+" 'calc-lu-plus)
(define-key calc-mode-map "l-" 'calc-lu-minus)
(define-key calc-mode-map "l*" 'calc-lu-times)
(define-key calc-mode-map "l/" 'calc-lu-divide)
(define-key calc-mode-map "ls" 'calc-spn)
(define-key calc-mode-map "lm" 'calc-midi)
(define-key calc-mode-map "lf" 'calc-freq)
2011-11-17 01:09:20 -08:00
(define-key calc-mode-map "l?" 'calc-l-prefix-help)
2001-11-06 18:59:06 +00:00
(define-key calc-mode-map "m" nil)
(define-key calc-mode-map "m?" 'calc-m-prefix-help)
(define-key calc-mode-map "ma" 'calc-algebraic-mode)
(define-key calc-mode-map "md" 'calc-degrees-mode)
(define-key calc-mode-map "me" 'calc-embedded-preserve-modes)
2001-11-06 18:59:06 +00:00
(define-key calc-mode-map "mf" 'calc-frac-mode)
(define-key calc-mode-map "mg" 'calc-get-modes)
(define-key calc-mode-map "mh" 'calc-hms-mode)
(define-key calc-mode-map "mi" 'calc-infinite-mode)
(define-key calc-mode-map "mm" 'calc-save-modes)
(define-key calc-mode-map "mp" 'calc-polar-mode)
(define-key calc-mode-map "mr" 'calc-radians-mode)
(define-key calc-mode-map "ms" 'calc-symbolic-mode)
(define-key calc-mode-map "mt" 'calc-total-algebraic-mode)
(define-key calc-mode-map "\emt" 'calc-total-algebraic-mode)
(define-key calc-mode-map "\em\et" 'calc-total-algebraic-mode)
(define-key calc-mode-map "mv" 'calc-matrix-mode)
(define-key calc-mode-map "mw" 'calc-working)
(define-key calc-mode-map "mx" 'calc-always-load-extensions)
(define-key calc-mode-map "mA" 'calc-alg-simplify-mode)
2001-11-06 18:59:06 +00:00
(define-key calc-mode-map "mB" 'calc-bin-simplify-mode)
(define-key calc-mode-map "mC" 'calc-auto-recompute)
(define-key calc-mode-map "mD" 'calc-default-simplify-mode)
(define-key calc-mode-map "mE" 'calc-ext-simplify-mode)
(define-key calc-mode-map "mF" 'calc-settings-file-name)
(define-key calc-mode-map "mI" 'calc-basic-simplify-mode)
2001-11-06 18:59:06 +00:00
(define-key calc-mode-map "mM" 'calc-more-recursion-depth)
(define-key calc-mode-map "mN" 'calc-num-simplify-mode)
(define-key calc-mode-map "mO" 'calc-no-simplify-mode)
(define-key calc-mode-map "mR" 'calc-mode-record-mode)
(define-key calc-mode-map "mS" 'calc-shift-prefix)
(define-key calc-mode-map "mU" 'calc-units-simplify-mode)
(define-key calc-mode-map "mX" 'calc-load-everything)
(define-key calc-mode-map "r" nil)
(define-key calc-mode-map "ri" 'calc-insert-register)
(define-key calc-mode-map "rs" 'calc-copy-to-register)
2001-11-06 18:59:06 +00:00
(define-key calc-mode-map "r?" 'calc-r-prefix-help)
(define-key calc-mode-map "s" nil)
(define-key calc-mode-map "s?" 'calc-s-prefix-help)
(define-key calc-mode-map "sc" 'calc-copy-variable)
(define-key calc-mode-map "sd" 'calc-declare-variable)
(define-key calc-mode-map "se" 'calc-edit-variable)
(define-key calc-mode-map "si" 'calc-insert-variables)
(define-key calc-mode-map "sk" 'calc-copy-special-constant)
2001-11-06 18:59:06 +00:00
(define-key calc-mode-map "sl" 'calc-let)
(define-key calc-mode-map "sm" 'calc-store-map)
(define-key calc-mode-map "sn" 'calc-store-neg)
(define-key calc-mode-map "sp" 'calc-permanent-variable)
(define-key calc-mode-map "sr" 'calc-recall)
(define-key calc-mode-map "ss" 'calc-store)
(define-key calc-mode-map "st" 'calc-store-into)
(define-key calc-mode-map "su" 'calc-unstore)
(define-key calc-mode-map "sx" 'calc-store-exchange)
(define-key calc-mode-map "sA" 'calc-edit-AlgSimpRules)
(define-key calc-mode-map "sD" 'calc-edit-Decls)
(define-key calc-mode-map "sE" 'calc-edit-EvalRules)
(define-key calc-mode-map "sF" 'calc-edit-FitRules)
(define-key calc-mode-map "sG" 'calc-edit-GenCount)
(define-key calc-mode-map "sH" 'calc-edit-Holidays)
(define-key calc-mode-map "sI" 'calc-edit-IntegLimit)
(define-key calc-mode-map "sL" 'calc-edit-LineStyles)
(define-key calc-mode-map "sP" 'calc-edit-PointStyles)
(define-key calc-mode-map "sR" 'calc-edit-PlotRejects)
(define-key calc-mode-map "sS" 'calc-sin)
(define-key calc-mode-map "sT" 'calc-edit-TimeZone)
(define-key calc-mode-map "sU" 'calc-edit-Units)
(define-key calc-mode-map "sX" 'calc-edit-ExtSimpRules)
(define-key calc-mode-map "s+" 'calc-store-plus)
(define-key calc-mode-map "s-" 'calc-store-minus)
(define-key calc-mode-map "s*" 'calc-store-times)
(define-key calc-mode-map "s/" 'calc-store-div)
(define-key calc-mode-map "s^" 'calc-store-power)
(define-key calc-mode-map "s|" 'calc-store-concat)
(define-key calc-mode-map "s&" 'calc-store-inv)
(define-key calc-mode-map "s[" 'calc-store-decr)
(define-key calc-mode-map "s]" 'calc-store-incr)
(define-key calc-mode-map "s:" 'calc-assign)
(define-key calc-mode-map "s=" 'calc-evalto)
(define-key calc-mode-map "t" nil)
(define-key calc-mode-map "t?" 'calc-t-prefix-help)
(define-key calc-mode-map "tb" 'calc-trail-backward)
(define-key calc-mode-map "td" 'calc-trail-display)
(define-key calc-mode-map "tf" 'calc-trail-forward)
(define-key calc-mode-map "th" 'calc-trail-here)
(define-key calc-mode-map "ti" 'calc-trail-in)
(define-key calc-mode-map "tk" 'calc-trail-kill)
(define-key calc-mode-map "tm" 'calc-trail-marker)
(define-key calc-mode-map "tn" 'calc-trail-next)
(define-key calc-mode-map "to" 'calc-trail-out)
(define-key calc-mode-map "tp" 'calc-trail-previous)
(define-key calc-mode-map "tr" 'calc-trail-isearch-backward)
(define-key calc-mode-map "ts" 'calc-trail-isearch-forward)
(define-key calc-mode-map "ty" 'calc-trail-yank)
(define-key calc-mode-map "t[" 'calc-trail-first)
(define-key calc-mode-map "t]" 'calc-trail-last)
(define-key calc-mode-map "t<" 'calc-trail-scroll-left)
(define-key calc-mode-map "t>" 'calc-trail-scroll-right)
(define-key calc-mode-map "t{" 'calc-trail-backward)
(define-key calc-mode-map "t}" 'calc-trail-forward)
(define-key calc-mode-map "t." 'calc-full-trail-vectors)
(define-key calc-mode-map "tC" 'calc-convert-time-zones)
(define-key calc-mode-map "tD" 'calc-date)
(define-key calc-mode-map "tI" 'calc-inc-month)
(define-key calc-mode-map "tJ" 'calc-julian)
(define-key calc-mode-map "tM" 'calc-new-month)
(define-key calc-mode-map "tN" 'calc-now)
(define-key calc-mode-map "tP" 'calc-date-part)
(define-key calc-mode-map "tT" 'calc-tan)
(define-key calc-mode-map "tU" 'calc-unix-time)
(define-key calc-mode-map "tW" 'calc-new-week)
(define-key calc-mode-map "tY" 'calc-new-year)
(define-key calc-mode-map "tZ" 'calc-time-zone)
(define-key calc-mode-map "t+" 'calc-business-days-plus)
(define-key calc-mode-map "t-" 'calc-business-days-minus)
(define-key calc-mode-map "u" 'nil)
(define-key calc-mode-map "u?" 'calc-u-prefix-help)
(define-key calc-mode-map "ua" 'calc-autorange-units)
(define-key calc-mode-map "ub" 'calc-base-units)
(define-key calc-mode-map "uc" 'calc-convert-units)
(define-key calc-mode-map "ud" 'calc-define-unit)
(define-key calc-mode-map "ue" 'calc-explain-units)
(define-key calc-mode-map "ug" 'calc-get-unit-definition)
(define-key calc-mode-map "un" 'calc-convert-exact-units)
2001-11-06 18:59:06 +00:00
(define-key calc-mode-map "up" 'calc-permanent-units)
(define-key calc-mode-map "ur" 'calc-remove-units)
(define-key calc-mode-map "us" 'calc-simplify-units)
(define-key calc-mode-map "ut" 'calc-convert-temperature)
(define-key calc-mode-map "uu" 'calc-undefine-unit)
(define-key calc-mode-map "uv" 'calc-enter-units-table)
(define-key calc-mode-map "ux" 'calc-extract-units)
(define-key calc-mode-map "uV" 'calc-view-units-table)
(define-key calc-mode-map "uC" 'calc-vector-covariance)
(define-key calc-mode-map "uG" 'calc-vector-geometric-mean)
(define-key calc-mode-map "uM" 'calc-vector-mean)
(define-key calc-mode-map "uN" 'calc-vector-min)
(define-key calc-mode-map "uR" 'calc-vector-rms)
2001-11-06 18:59:06 +00:00
(define-key calc-mode-map "uS" 'calc-vector-sdev)
(define-key calc-mode-map "uU" 'calc-undo)
(define-key calc-mode-map "uX" 'calc-vector-max)
(define-key calc-mode-map "u#" 'calc-vector-count)
(define-key calc-mode-map "u+" 'calc-vector-sum)
(define-key calc-mode-map "u*" 'calc-vector-product)
(define-key calc-mode-map "v" 'nil)
(define-key calc-mode-map "v?" 'calc-v-prefix-help)
(define-key calc-mode-map "va" 'calc-arrange-vector)
(define-key calc-mode-map "vb" 'calc-build-vector)
(define-key calc-mode-map "vc" 'calc-mcol)
(define-key calc-mode-map "vd" 'calc-diag)
(define-key calc-mode-map "ve" 'calc-expand-vector)
(define-key calc-mode-map "vf" 'calc-vector-find)
(define-key calc-mode-map "vh" 'calc-head)
(define-key calc-mode-map "vi" 'calc-ident)
(define-key calc-mode-map "vk" 'calc-cons)
(define-key calc-mode-map "vl" 'calc-vlength)
(define-key calc-mode-map "vm" 'calc-mask-vector)
(define-key calc-mode-map "vn" 'calc-rnorm)
(define-key calc-mode-map "vp" 'calc-pack)
(define-key calc-mode-map "vr" 'calc-mrow)
(define-key calc-mode-map "vs" 'calc-subvector)
(define-key calc-mode-map "vt" 'calc-transpose)
(define-key calc-mode-map "vu" 'calc-unpack)
(define-key calc-mode-map "vv" 'calc-reverse-vector)
(define-key calc-mode-map "vx" 'calc-index)
(define-key calc-mode-map "vA" 'calc-apply)
(define-key calc-mode-map "vC" 'calc-cross)
(define-key calc-mode-map "vK" 'calc-kron)
2001-11-06 18:59:06 +00:00
(define-key calc-mode-map "vD" 'calc-mdet)
(define-key calc-mode-map "vE" 'calc-set-enumerate)
(define-key calc-mode-map "vF" 'calc-set-floor)
(define-key calc-mode-map "vG" 'calc-grade)
(define-key calc-mode-map "vH" 'calc-histogram)
(define-key calc-mode-map "vI" 'calc-inner-product)
(define-key calc-mode-map "vJ" 'calc-conj-transpose)
(define-key calc-mode-map "vL" 'calc-mlud)
(define-key calc-mode-map "vM" 'calc-map)
(define-key calc-mode-map "vN" 'calc-cnorm)
(define-key calc-mode-map "vO" 'calc-outer-product)
(define-key calc-mode-map "vR" 'calc-reduce)
(define-key calc-mode-map "vS" 'calc-sort)
(define-key calc-mode-map "vT" 'calc-mtrace)
(define-key calc-mode-map "vU" 'calc-accumulate)
(define-key calc-mode-map "vV" 'calc-set-union)
(define-key calc-mode-map "vX" 'calc-set-xor)
(define-key calc-mode-map "v^" 'calc-set-intersect)
(define-key calc-mode-map "v-" 'calc-set-difference)
(define-key calc-mode-map "v~" 'calc-set-complement)
(define-key calc-mode-map "v:" 'calc-set-span)
(define-key calc-mode-map "v#" 'calc-set-cardinality)
(define-key calc-mode-map "v+" 'calc-remove-duplicates)
(define-key calc-mode-map "v&" 'calc-inv)
(define-key calc-mode-map "v<" 'calc-matrix-left-justify)
(define-key calc-mode-map "v=" 'calc-matrix-center-justify)
(define-key calc-mode-map "v>" 'calc-matrix-right-justify)
(define-key calc-mode-map "v." 'calc-full-vectors)
(define-key calc-mode-map "v/" 'calc-break-vectors)
(define-key calc-mode-map "v," 'calc-vector-commas)
(define-key calc-mode-map "v[" 'calc-vector-brackets)
(define-key calc-mode-map "v]" 'calc-matrix-brackets)
(define-key calc-mode-map "v{" 'calc-vector-braces)
(define-key calc-mode-map "v}" 'calc-matrix-brackets)
(define-key calc-mode-map "v(" 'calc-vector-parens)
(define-key calc-mode-map "v)" 'calc-matrix-brackets)
2004-03-26 15:30:42 +00:00
;; We can't rely on the automatic upper->lower conversion because
;; in the global map V is explicitly bound, so we need to bind it
;; explicitly as well :-( --stef
2001-11-06 18:59:06 +00:00
(define-key calc-mode-map "V" (lookup-key calc-mode-map "v"))
(define-key calc-mode-map "z" 'nil)
(define-key calc-mode-map "z?" 'calc-z-prefix-help)
(define-key calc-mode-map "Z" 'nil)
(define-key calc-mode-map "Z?" 'calc-shift-Z-prefix-help)
(define-key calc-mode-map "ZC" 'calc-user-define-composition)
(define-key calc-mode-map "ZD" 'calc-user-define)
(define-key calc-mode-map "ZE" 'calc-user-define-edit)
(define-key calc-mode-map "ZF" 'calc-user-define-formula)
(define-key calc-mode-map "ZG" 'calc-get-user-defn)
(define-key calc-mode-map "ZI" 'calc-user-define-invocation)
(define-key calc-mode-map "ZK" 'calc-user-define-kbd-macro)
(define-key calc-mode-map "ZP" 'calc-user-define-permanent)
(define-key calc-mode-map "ZS" 'calc-edit-user-syntax)
(define-key calc-mode-map "ZT" 'calc-timing)
(define-key calc-mode-map "ZU" 'calc-user-undefine)
(define-key calc-mode-map "Z[" 'calc-kbd-if)
(define-key calc-mode-map "Z:" 'calc-kbd-else)
(define-key calc-mode-map "Z|" 'calc-kbd-else-if)
(define-key calc-mode-map "Z]" 'calc-kbd-end-if)
(define-key calc-mode-map "Z<" 'calc-kbd-repeat)
(define-key calc-mode-map "Z>" 'calc-kbd-end-repeat)
(define-key calc-mode-map "Z(" 'calc-kbd-for)
(define-key calc-mode-map "Z)" 'calc-kbd-end-for)
(define-key calc-mode-map "Z{" 'calc-kbd-loop)
(define-key calc-mode-map "Z}" 'calc-kbd-end-loop)
(define-key calc-mode-map "Z/" 'calc-kbd-break)
(define-key calc-mode-map "Z`" 'calc-kbd-push)
(define-key calc-mode-map "Z'" 'calc-kbd-pop)
(define-key calc-mode-map "Z#" 'calc-kbd-query)
(calc-init-prefixes)
Don't quote lambdas with 'function' in calc/*.el * lisp/calc/calc-aent.el (calc-do-quick-calc) (calc-do-calc-eval, math-build-parse-table): * lisp/calc/calc-alg.el (math-polynomial-base): * lisp/calc/calc-alg.el (math-is-poly-rec): * lisp/calc/calc-arith.el (calcFunc-scf): * lisp/calc/calc-arith.el (math-ceiling, math-round): * lisp/calc/calc-arith.el (math-trunc-fancy, math-floor-fancy): * lisp/calc/calc-ext.el (calc-init-extensions, calc-reset) (calc-refresh-top, calc-z-prefix-help, calc-binary-op-fancy) (calc-unary-op-fancy): * lisp/calc/calc-forms.el (math-make-mod): * lisp/calc/calc-frac.el (calcFunc-frac): * lisp/calc/calc-funcs.el (calcFunc-euler): * lisp/calc/calc-help.el (calc-full-help): * lisp/calc/calc-lang.el (c, pascal, fortran, tex, latex, eqn) (yacas, maxima, giac, math, maple): * lisp/calc/calc-macs.el (calc-wrapper, calc-slow-wrapper): * lisp/calc/calc-map.el (calc-get-operator, calcFunc-mapeqr) (calcFunc-reducea, calcFunc-rreducea, calcFunc-reduced) (calcFunc-rreduced, calcFunc-outer): * lisp/calc/calc-misc.el (another-calc, calc-do-handle-whys): * lisp/calc/calc-mode.el (calc-save-modes): * lisp/calc/calc-mtx.el (math-col-matrix, math-mul-mat-vec): * lisp/calc/calc-poly.el (math-sort-terms, math-poly-div-list) (math-mul-list, math-sort-poly-base-list) (math-partial-fractions): * lisp/calc/calc-prog.el (calc-user-define-formula): * lisp/calc/calc-rewr.el (math-rewrite, math-compile-patterns) (math-compile-rewrites, math-parse-schedule) (math-rwcomp-pattern): * lisp/calc/calc-store.el (calc-var-name-map, calc-let) (calc-permanent-variable, calc-insert-variables): * lisp/calc/calc-stuff.el (calc-flush-caches, calcFunc-pclean) (calcFunc-pfrac): * lisp/calc/calc-units.el (math-build-units-table) (math-decompose-units): * lisp/calc/calc-vec.el (calcFunc-mrow, math-mat-col) (calcFunc-mcol, math-mat-less-col, math-mimic-ident): * lisp/calc/calc-yank.el (calc-edit): * lisp/calc/calc.el (calc-mode-var-list-restore-default-values) (calc-mode-var-list-restore-saved-values, calc-mode, calc-quit): * lisp/calc/calccomp.el (math-compose-expr) (math-compose-matrix, math-vector-to-string): Don't quote lambdas with 'function'.
2020-11-17 02:51:30 +01:00
(mapc (lambda (x)
(define-key calc-mode-map (format "c%c" x) 'calc-clean-num)
(define-key calc-mode-map (format "j%c" x) 'calc-select-part)
(define-key calc-mode-map (format "r%c" x) 'calc-recall-quick)
(define-key calc-mode-map (format "s%c" x) 'calc-store-quick)
(define-key calc-mode-map (format "t%c" x) 'calc-store-into-quick)
Don't quote lambdas with 'function' in calc/*.el * lisp/calc/calc-aent.el (calc-do-quick-calc) (calc-do-calc-eval, math-build-parse-table): * lisp/calc/calc-alg.el (math-polynomial-base): * lisp/calc/calc-alg.el (math-is-poly-rec): * lisp/calc/calc-arith.el (calcFunc-scf): * lisp/calc/calc-arith.el (math-ceiling, math-round): * lisp/calc/calc-arith.el (math-trunc-fancy, math-floor-fancy): * lisp/calc/calc-ext.el (calc-init-extensions, calc-reset) (calc-refresh-top, calc-z-prefix-help, calc-binary-op-fancy) (calc-unary-op-fancy): * lisp/calc/calc-forms.el (math-make-mod): * lisp/calc/calc-frac.el (calcFunc-frac): * lisp/calc/calc-funcs.el (calcFunc-euler): * lisp/calc/calc-help.el (calc-full-help): * lisp/calc/calc-lang.el (c, pascal, fortran, tex, latex, eqn) (yacas, maxima, giac, math, maple): * lisp/calc/calc-macs.el (calc-wrapper, calc-slow-wrapper): * lisp/calc/calc-map.el (calc-get-operator, calcFunc-mapeqr) (calcFunc-reducea, calcFunc-rreducea, calcFunc-reduced) (calcFunc-rreduced, calcFunc-outer): * lisp/calc/calc-misc.el (another-calc, calc-do-handle-whys): * lisp/calc/calc-mode.el (calc-save-modes): * lisp/calc/calc-mtx.el (math-col-matrix, math-mul-mat-vec): * lisp/calc/calc-poly.el (math-sort-terms, math-poly-div-list) (math-mul-list, math-sort-poly-base-list) (math-partial-fractions): * lisp/calc/calc-prog.el (calc-user-define-formula): * lisp/calc/calc-rewr.el (math-rewrite, math-compile-patterns) (math-compile-rewrites, math-parse-schedule) (math-rwcomp-pattern): * lisp/calc/calc-store.el (calc-var-name-map, calc-let) (calc-permanent-variable, calc-insert-variables): * lisp/calc/calc-stuff.el (calc-flush-caches, calcFunc-pclean) (calcFunc-pfrac): * lisp/calc/calc-units.el (math-build-units-table) (math-decompose-units): * lisp/calc/calc-vec.el (calcFunc-mrow, math-mat-col) (calcFunc-mcol, math-mat-less-col, math-mimic-ident): * lisp/calc/calc-yank.el (calc-edit): * lisp/calc/calc.el (calc-mode-var-list-restore-default-values) (calc-mode-var-list-restore-saved-values, calc-mode, calc-quit): * lisp/calc/calccomp.el (math-compose-expr) (math-compose-matrix, math-vector-to-string): Don't quote lambdas with 'function'.
2020-11-17 02:51:30 +01:00
(define-key calc-mode-map (format "u%c" x) 'calc-quick-units))
"0123456789")
2001-11-06 18:59:06 +00:00
(let ((i ?A))
(while (<= i ?z)
(if (eq (car-safe (aref (nth 1 calc-mode-map) i)) 'keymap)
(aset (nth 1 calc-mode-map) i
(cons 'keymap (cons (cons ?\e (aref (nth 1 calc-mode-map) i))
(cdr (aref (nth 1 calc-mode-map) i))))))
2001-11-06 18:59:06 +00:00
(setq i (1+ i))))
(setq calc-alg-map (copy-keymap calc-mode-map)
calc-alg-esc-map (copy-keymap esc-map))
2001-11-06 18:59:06 +00:00
(let ((i 32))
(while (< i 127)
(or (memq i '(?' ?` ?= ??))
(aset (nth 1 calc-alg-map) i 'calc-auto-algebraic-entry))
2001-11-06 18:59:06 +00:00
(or (memq i '(?# ?x ?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9))
(aset (nth 1 calc-alg-esc-map) i (aref (nth 1 calc-mode-map) i)))
2001-11-06 18:59:06 +00:00
(setq i (1+ i))))
(define-key calc-alg-map "\e" calc-alg-esc-map)
(define-key calc-alg-map "\e\t" 'calc-roll-up)
(define-key calc-alg-map "\e\C-m" 'calc-last-args-stub)
(define-key calc-alg-map "\e\177" 'calc-pop-above)
2003-02-04 13:24:35 +00:00
2001-11-06 18:59:06 +00:00
;;;; (Autoloads here)
Don't quote lambdas with 'function' in calc/*.el * lisp/calc/calc-aent.el (calc-do-quick-calc) (calc-do-calc-eval, math-build-parse-table): * lisp/calc/calc-alg.el (math-polynomial-base): * lisp/calc/calc-alg.el (math-is-poly-rec): * lisp/calc/calc-arith.el (calcFunc-scf): * lisp/calc/calc-arith.el (math-ceiling, math-round): * lisp/calc/calc-arith.el (math-trunc-fancy, math-floor-fancy): * lisp/calc/calc-ext.el (calc-init-extensions, calc-reset) (calc-refresh-top, calc-z-prefix-help, calc-binary-op-fancy) (calc-unary-op-fancy): * lisp/calc/calc-forms.el (math-make-mod): * lisp/calc/calc-frac.el (calcFunc-frac): * lisp/calc/calc-funcs.el (calcFunc-euler): * lisp/calc/calc-help.el (calc-full-help): * lisp/calc/calc-lang.el (c, pascal, fortran, tex, latex, eqn) (yacas, maxima, giac, math, maple): * lisp/calc/calc-macs.el (calc-wrapper, calc-slow-wrapper): * lisp/calc/calc-map.el (calc-get-operator, calcFunc-mapeqr) (calcFunc-reducea, calcFunc-rreducea, calcFunc-reduced) (calcFunc-rreduced, calcFunc-outer): * lisp/calc/calc-misc.el (another-calc, calc-do-handle-whys): * lisp/calc/calc-mode.el (calc-save-modes): * lisp/calc/calc-mtx.el (math-col-matrix, math-mul-mat-vec): * lisp/calc/calc-poly.el (math-sort-terms, math-poly-div-list) (math-mul-list, math-sort-poly-base-list) (math-partial-fractions): * lisp/calc/calc-prog.el (calc-user-define-formula): * lisp/calc/calc-rewr.el (math-rewrite, math-compile-patterns) (math-compile-rewrites, math-parse-schedule) (math-rwcomp-pattern): * lisp/calc/calc-store.el (calc-var-name-map, calc-let) (calc-permanent-variable, calc-insert-variables): * lisp/calc/calc-stuff.el (calc-flush-caches, calcFunc-pclean) (calcFunc-pfrac): * lisp/calc/calc-units.el (math-build-units-table) (math-decompose-units): * lisp/calc/calc-vec.el (calcFunc-mrow, math-mat-col) (calcFunc-mcol, math-mat-less-col, math-mimic-ident): * lisp/calc/calc-yank.el (calc-edit): * lisp/calc/calc.el (calc-mode-var-list-restore-default-values) (calc-mode-var-list-restore-saved-values, calc-mode, calc-quit): * lisp/calc/calccomp.el (math-compose-expr) (math-compose-matrix, math-vector-to-string): Don't quote lambdas with 'function'.
2020-11-17 02:51:30 +01:00
(mapc (lambda (x)
(mapcar (lambda (func) (autoload func (car x)))
(cdr x)))
2001-11-06 18:59:06 +00:00
'(
("calc-alg" calc-has-rules math-defsimplify
2001-11-06 18:59:06 +00:00
calc-modify-simplify-mode calcFunc-collect calcFunc-esimplify
calcFunc-islin calcFunc-islinnt calcFunc-lin calcFunc-linnt
calcFunc-simplify calcFunc-subst calcFunc-powerexpand math-beforep
2001-11-06 18:59:06 +00:00
math-build-polynomial-expr math-expand-formula math-expr-contains
math-expr-contains-count math-expr-depends math-expr-height
math-expr-subst math-expr-weight math-integer-plus math-is-linear
math-is-multiple math-is-polynomial math-linear-in math-multiple-of
math-poly-depends math-poly-mix math-poly-mul
2001-11-06 18:59:06 +00:00
math-poly-simplify math-poly-zerop math-polynomial-base
math-polynomial-p math-recompile-eval-rules math-simplify
math-simplify-exp math-simplify-extended math-simplify-sqrt
math-to-simple-fraction)
("calcalg2" calcFunc-asum calcFunc-deriv
2001-11-06 18:59:06 +00:00
calcFunc-ffinv calcFunc-finv calcFunc-fsolve calcFunc-gpoly
calcFunc-integ calcFunc-poly calcFunc-prod calcFunc-roots
calcFunc-solve calcFunc-sum calcFunc-table calcFunc-taylor
calcFunc-tderiv math-expr-calls math-integral-q02 math-integral-q12
math-integral-rational-funcs math-lcm-denoms math-looks-evenp
math-poly-all-roots math-prod-rec math-reject-solution math-solve-eqn
math-solve-for math-sum-rec math-try-integral)
("calcalg3" calcFunc-efit calcFunc-fit
2001-11-06 18:59:06 +00:00
calcFunc-fitdummy calcFunc-fitparam calcFunc-fitvar
calcFunc-hasfitparams calcFunc-hasfitvars calcFunc-maximize
calcFunc-minimize calcFunc-ninteg calcFunc-polint calcFunc-ratint
calcFunc-root calcFunc-wmaximize calcFunc-wminimize calcFunc-wroot
calcFunc-xfit math-find-minimum math-find-root math-ninteg-evaluate
math-ninteg-midpoint math-ninteg-romberg math-poly-interp)
("calc-arith" calcFunc-abs calcFunc-abssqr
2001-11-06 18:59:06 +00:00
calcFunc-add calcFunc-ceil calcFunc-decr calcFunc-deven calcFunc-dimag
calcFunc-dint calcFunc-div calcFunc-dnatnum calcFunc-dneg
calcFunc-dnonneg calcFunc-dnonzero calcFunc-dnumint calcFunc-dodd
calcFunc-dpos calcFunc-drange calcFunc-drat calcFunc-dreal
calcFunc-dscalar calcFunc-fceil calcFunc-ffloor calcFunc-float
calcFunc-fround calcFunc-frounde calcFunc-froundu calcFunc-ftrunc
calcFunc-idiv calcFunc-incr calcFunc-ldiv calcFunc-mant calcFunc-max calcFunc-min
2001-11-06 18:59:06 +00:00
calcFunc-mod calcFunc-mul calcFunc-neg calcFunc-percent calcFunc-pow
calcFunc-relch calcFunc-round calcFunc-rounde calcFunc-roundu
calcFunc-scf calcFunc-sub calcFunc-xpon math-abs math-abs-approx
math-add-objects-fancy math-add-or-sub math-add-symb-fancy
math-ceiling math-combine-prod math-combine-sum math-div-by-zero
math-div-objects-fancy math-div-symb-fancy math-div-zero
math-float-fancy math-floor-fancy math-floor-special math-guess-if-neg
math-intv-constp math-known-evenp math-known-imagp math-known-integerp
math-known-matrixp math-known-negp math-known-nonnegp
math-known-nonposp math-known-nonzerop math-known-num-integerp
math-known-oddp math-known-posp math-known-realp math-known-scalarp
math-max math-min math-mod-fancy math-mul-float math-mul-objects-fancy
math-mul-or-div math-mul-symb-fancy math-mul-zero math-neg-fancy
math-neg-float math-okay-neg math-possible-signs math-possible-types
math-pow-fancy math-pow-mod math-pow-of-zero math-pow-zero
math-quarter-integer math-round math-setup-declarations math-sqr
math-sqr-float math-trunc-fancy math-trunc-special)
("calc-bin" calcFunc-and calcFunc-ash
calcFunc-clip calcFunc-diff calcFunc-lsh calcFunc-not calcFunc-or
2001-11-06 18:59:06 +00:00
calcFunc-rash calcFunc-rot calcFunc-rsh calcFunc-xor math-clip
math-compute-max-digits math-convert-radix-digits math-float-parts
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
math-format-binary
2001-11-06 18:59:06 +00:00
math-format-radix math-format-radix-float math-integer-log2
math-power-of-2 math-radix-float-power)
("calc-comb" calc-report-prime-test
2001-11-06 18:59:06 +00:00
calcFunc-choose calcFunc-dfact calcFunc-egcd calcFunc-fact
calcFunc-gcd calcFunc-lcm calcFunc-moebius calcFunc-nextprime
calcFunc-perm calcFunc-prevprime calcFunc-prfac calcFunc-prime
calcFunc-random calcFunc-shuffle calcFunc-stir1 calcFunc-stir2
calcFunc-totient math-init-random-base math-member math-prime-test
math-random-base)
("calccomp" calcFunc-cascent calcFunc-cdescent
2001-11-06 18:59:06 +00:00
calcFunc-cheight calcFunc-cwidth math-comp-ascent math-comp-descent
math-comp-height math-comp-width math-compose-expr
math-composition-to-string math-stack-value-offset-fancy
math-vector-is-string math-vector-to-string)
("calc-cplx" calcFunc-arg calcFunc-conj
2001-11-06 18:59:06 +00:00
calcFunc-im calcFunc-polar calcFunc-re calcFunc-rect math-complex
math-fix-circular math-imaginary math-imaginary-i math-normalize-polar
math-polar math-want-polar)
("calc-embed" calc-do-embedded
2001-11-06 18:59:06 +00:00
calc-do-embedded-activate calc-embedded-evaluate-expr
calc-embedded-modes-change calc-embedded-var-change
calc-embedded-preserve-modes)
2001-11-06 18:59:06 +00:00
("calc-fin" calc-to-percentage calcFunc-ddb
2001-11-06 18:59:06 +00:00
calcFunc-fv calcFunc-fvb calcFunc-fvl calcFunc-irr calcFunc-irrb
calcFunc-nper calcFunc-nperb calcFunc-nperl calcFunc-npv calcFunc-npvb
calcFunc-pmt calcFunc-pmtb calcFunc-pv calcFunc-pvb calcFunc-pvl
calcFunc-rate calcFunc-rateb calcFunc-ratel calcFunc-sln calcFunc-syd)
("calc-forms" calcFunc-badd calcFunc-bsub
2001-11-06 18:59:06 +00:00
calcFunc-date calcFunc-day calcFunc-dsadj calcFunc-hms
calcFunc-holiday calcFunc-hour calcFunc-incmonth calcFunc-incyear
calcFunc-intv calcFunc-julian calcFunc-makemod calcFunc-minute
calcFunc-month calcFunc-newmonth calcFunc-newweek calcFunc-newyear
calcFunc-now calcFunc-pwday calcFunc-sdev calcFunc-second
calcFunc-time calcFunc-tzconv calcFunc-tzone calcFunc-unixtime
calcFunc-weekday calcFunc-year calcFunc-yearday math-combine-intervals
math-date-parts math-date-to-dt math-div-mod math-dt-to-date
math-format-date math-from-business-day math-from-hms math-make-intv
math-make-mod math-make-sdev math-mod-intv math-normalize-hms
math-normalize-mod math-parse-date math-read-angle-brackets
math-setup-add-holidays math-setup-holidays math-setup-year-holidays
math-sort-intv math-to-business-day math-to-hms)
("calc-frac" calc-add-fractions
2001-11-06 18:59:06 +00:00
calc-div-fractions calc-mul-fractions calcFunc-fdiv calcFunc-frac
math-make-frac)
("calc-funcs" calc-prob-dist calcFunc-bern
2001-11-06 18:59:06 +00:00
calcFunc-besJ calcFunc-besY calcFunc-beta calcFunc-betaB
calcFunc-betaI calcFunc-erf calcFunc-erfc calcFunc-euler
calcFunc-gamma calcFunc-gammaG calcFunc-gammaP calcFunc-gammaQ
calcFunc-gammag calcFunc-ltpb calcFunc-ltpc calcFunc-ltpf
calcFunc-ltpn calcFunc-ltpp calcFunc-ltpt calcFunc-utpb calcFunc-utpc
calcFunc-utpf calcFunc-utpn calcFunc-utpp calcFunc-utpt
math-bernoulli-number math-gammap1-raw)
("calc-graph" calc-graph-show-tty)
2001-11-06 18:59:06 +00:00
("calc-incom" calc-digit-dots)
2001-11-06 18:59:06 +00:00
("calc-keypd" calc-do-keypad
calc-keypad-left-click calc-keypad-middle-click
calc-keypad-right-click)
2001-11-06 18:59:06 +00:00
("calc-lang" calc-set-language
2001-11-06 18:59:06 +00:00
math-read-big-balance math-read-big-rec)
("calc-map" calc-get-operator calcFunc-accum
2001-11-06 18:59:06 +00:00
calcFunc-afixp calcFunc-anest calcFunc-apply calcFunc-call
calcFunc-fixp calcFunc-inner calcFunc-map calcFunc-mapa calcFunc-mapc
calcFunc-mapd calcFunc-mapeq calcFunc-mapeqp calcFunc-mapeqr
calcFunc-mapr calcFunc-nest calcFunc-outer calcFunc-raccum
calcFunc-reduce calcFunc-reducea calcFunc-reducec calcFunc-reduced
calcFunc-reducer calcFunc-rreduce calcFunc-rreducea calcFunc-rreducec
calcFunc-rreduced calcFunc-rreducer math-build-call
math-calcFunc-to-var math-multi-subst math-multi-subst-rec
math-var-to-calcFunc)
("calc-mtx" calcFunc-det calcFunc-lud calcFunc-tr
2001-11-06 18:59:06 +00:00
math-col-matrix math-lud-solve math-matrix-inv-raw math-matrix-lud
math-mul-mat-vec math-mul-mats math-row-matrix)
("calc-math" calcFunc-alog calcFunc-arccos
2001-11-06 18:59:06 +00:00
calcFunc-arccosh calcFunc-arcsin calcFunc-arcsincos calcFunc-arcsinh
2005-02-15 19:24:49 +00:00
calcFunc-arctan calcFunc-arctan2 calcFunc-arctanh calcFunc-csc
calcFunc-csch calcFunc-cos calcFunc-cosh calcFunc-cot calcFunc-coth
calcFunc-deg calcFunc-exp calcFunc-exp10 calcFunc-expm1
2001-11-06 18:59:06 +00:00
calcFunc-hypot calcFunc-ilog calcFunc-isqrt calcFunc-ln calcFunc-lnp1
2005-02-15 19:24:49 +00:00
calcFunc-log calcFunc-log10 calcFunc-nroot calcFunc-rad calcFunc-sec
calcFunc-sech calcFunc-sin
2001-11-06 18:59:06 +00:00
calcFunc-sincos calcFunc-sinh calcFunc-sqr calcFunc-sqrt calcFunc-tan
calcFunc-tanh math-arccos-raw math-arcsin-raw math-arctan-raw
2005-02-15 19:24:49 +00:00
math-arctan2-raw math-cos-raw math-cot-raw math-csc-raw
math-exp-minus-1-raw math-exp-raw
2001-11-06 18:59:06 +00:00
math-from-radians math-from-radians-2 math-hypot math-infinite-dir
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
math-ln-raw math-nearly-equal math-nearly-equal-float
2001-11-06 18:59:06 +00:00
math-nearly-zerop math-nearly-zerop-float math-nth-root
math-sin-cos-raw math-sin-raw math-sqrt math-sqrt-float math-sqrt-raw
math-tan-raw math-to-radians math-to-radians-2)
("calc-mode" math-get-modes-vec)
2001-11-06 18:59:06 +00:00
("calc-poly" calcFunc-apart calcFunc-expand
2001-11-06 18:59:06 +00:00
calcFunc-expandpow calcFunc-factor calcFunc-factors calcFunc-nrat
calcFunc-pcont calcFunc-pdeg calcFunc-pdiv calcFunc-pdivide
calcFunc-pdivrem calcFunc-pgcd calcFunc-plead calcFunc-pprim
calcFunc-prem math-accum-factors math-atomic-factorp
math-div-poly-const math-div-thru math-expand-power math-expand-term
2018-11-20 16:09:35 -05:00
math-factor-contains math-factor-expr
math-factor-finish
2001-11-06 18:59:06 +00:00
math-factor-protect math-mul-thru math-padded-polynomial
math-partial-fractions math-poly-degree math-poly-deriv-coefs
math-poly-gcd-frac-list math-poly-modulus-rec math-ratpoly-p
math-to-ratpoly math-to-ratpoly-rec)
("calc-prog" calc-default-formula-arglist
2001-11-06 18:59:06 +00:00
calc-execute-kbd-macro calc-finish-user-syntax-edit
calc-fix-token-name calc-fix-user-formula calc-read-parse-table
calc-read-parse-table-part calc-subsetp calc-write-parse-table
calc-write-parse-table-part calcFunc-constant calcFunc-eq calcFunc-geq
calcFunc-gt calcFunc-if calcFunc-in calcFunc-integer calcFunc-istrue
calcFunc-land calcFunc-leq calcFunc-lnot calcFunc-lor calcFunc-lt
calcFunc-negative calcFunc-neq calcFunc-nonvar calcFunc-real
calcFunc-refers calcFunc-rmeq calcFunc-typeof calcFunc-variable
math-body-refers-to math-break math-composite-inequalities
math-do-defmath math-handle-for math-handle-foreach
math-normalize-logical-op math-return)
("calc-rewr" calcFunc-match calcFunc-matches
2001-11-06 18:59:06 +00:00
calcFunc-matchnot calcFunc-rewrite calcFunc-vmatches
math-apply-rewrites math-compile-patterns math-compile-rewrites
math-flatten-lands math-match-patterns math-rewrite
math-rewrite-heads)
("calc-rules" calc-CommuteRules calc-DistribRules calc-FactorRules
calc-FitRules calc-IntegAfterRules calc-InvertRules calc-JumpRules
calc-MergeRules calc-NegateRules
2001-11-06 18:59:06 +00:00
calc-compile-rule-set)
("calc-sel" calc-auto-selection
2001-11-06 18:59:06 +00:00
calc-delete-selection calc-encase-atoms calc-find-assoc-parent-formula
calc-find-parent-formula calc-find-sub-formula calc-prepare-selection
calc-preserve-point calc-replace-selections calc-replace-sub-formula
calc-roll-down-with-selections calc-roll-up-with-selections
calc-sel-error)
("calc-stat" calc-vector-op calcFunc-agmean calcFunc-rms
2001-11-06 18:59:06 +00:00
calcFunc-vcorr calcFunc-vcount calcFunc-vcov calcFunc-vflat
calcFunc-vgmean calcFunc-vhmean calcFunc-vmax calcFunc-vmean
calcFunc-vmeane calcFunc-vmedian calcFunc-vmin calcFunc-vpcov
calcFunc-vprod calcFunc-vpsdev calcFunc-vpvar calcFunc-vsdev
calcFunc-vsum calcFunc-vvar math-flatten-many-vecs)
("calc-store" calc-read-var-name
2001-11-06 18:59:06 +00:00
calc-store-value calc-var-name)
("calc-stuff" calc-explain-why calcFunc-clean
2001-11-06 18:59:06 +00:00
calcFunc-pclean calcFunc-pfloat calcFunc-pfrac)
* lisp/calc/README: Mention musical notes. * lisp/calc-units.el (calc-lu-quant): Rename from `calc-logunits-quantity'. (calcFunc-lupquant): Rename from `calcFunc-powerquant'. (calcFunc-lufquant): Rename from `calcFunc-fieldquant'. (calc-db): Rename from `calc-dblevel'. (calcFunc-dbpower): Rename from `calcFunc-dbpowerlevel'. (calcFunc-dbfield): Rename from `calcFunc-dbfieldlevel'. (calc-np): Rename from `calc-nplevel'. (calcFunc-nppower): Rename from `calcFunc-nppowerlevel'. (calcFunc-npfield): Rename from `calcFunc-npfieldlevel'. (calc-lu-plus): Rename from `calc-logunits-add'. (calcFunc-lupadd): Rename from `calcFunc-lupoweradd'. (calcFunc-lufadd): Rename from `calcFunc-lufieldadd'. (calc-lu-minus): Rename from `calc-logunits-sub'. (calcFunc-lupsub): Rename from `calcFunc-lupowersub'. (calcFunc-lufsub): Rename from `calcFunc-lufieldsub'. (calc-lu-times): Rename from `calc-logunits-mul'. (calcFunc-lupmul): Rename from `calcFunc-lupowermul'. (calcFunc-lufmul): Rename from `calcFunc-lufieldmul'. (calc-lu-divide): Rename from `calc-logunits-div'. (calcFunc-lupdiv): Rename from `calcFunc-lupowerdiv'. (calcFunc-lufdiv): Rename from `calcFunc-lufielddiv'. * lisp/calc/calc-ext.el (calc-init-extensions): Update the names of the functions being autoloaded. * lisp/calc/calc.el (calc-lu-power-reference): Rename from `calc-logunits-power-reference'. (calc-lu-field-reference): Rename from `calc-logunits-field-reference'. * lisp/calc/calc-help (calc-l-prefix-help): Mention musical note functions. * doc/misc/calc.texi (Logarithmic Units): Update the function names.
2011-03-16 20:30:08 -05:00
("calc-units" calcFunc-usimplify calcFunc-lufadd calcFunc-lupadd
calcFunc-lufsub calcFunc-lupsub calcFunc-lufmul calcFunc-lupmul
calcFunc-lufdiv calcFunc-lupdiv calcFunc-lufquant calcFunc-lupquant
* lisp/calc/README: Mention musical notes. * lisp/calc-units.el (calc-lu-quant): Rename from `calc-logunits-quantity'. (calcFunc-lupquant): Rename from `calcFunc-powerquant'. (calcFunc-lufquant): Rename from `calcFunc-fieldquant'. (calc-db): Rename from `calc-dblevel'. (calcFunc-dbpower): Rename from `calcFunc-dbpowerlevel'. (calcFunc-dbfield): Rename from `calcFunc-dbfieldlevel'. (calc-np): Rename from `calc-nplevel'. (calcFunc-nppower): Rename from `calcFunc-nppowerlevel'. (calcFunc-npfield): Rename from `calcFunc-npfieldlevel'. (calc-lu-plus): Rename from `calc-logunits-add'. (calcFunc-lupadd): Rename from `calcFunc-lupoweradd'. (calcFunc-lufadd): Rename from `calcFunc-lufieldadd'. (calc-lu-minus): Rename from `calc-logunits-sub'. (calcFunc-lupsub): Rename from `calcFunc-lupowersub'. (calcFunc-lufsub): Rename from `calcFunc-lufieldsub'. (calc-lu-times): Rename from `calc-logunits-mul'. (calcFunc-lupmul): Rename from `calcFunc-lupowermul'. (calcFunc-lufmul): Rename from `calcFunc-lufieldmul'. (calc-lu-divide): Rename from `calc-logunits-div'. (calcFunc-lupdiv): Rename from `calcFunc-lupowerdiv'. (calcFunc-lufdiv): Rename from `calcFunc-lufielddiv'. * lisp/calc/calc-ext.el (calc-init-extensions): Update the names of the functions being autoloaded. * lisp/calc/calc.el (calc-lu-power-reference): Rename from `calc-logunits-power-reference'. (calc-lu-field-reference): Rename from `calc-logunits-field-reference'. * lisp/calc/calc-help (calc-l-prefix-help): Mention musical note functions. * doc/misc/calc.texi (Logarithmic Units): Update the function names.
2011-03-16 20:30:08 -05:00
calcFunc-dbfield calcFunc-dbpower calcFunc-npfield
calcFunc-nppower calcFunc-spn calcFunc-midi calcFunc-freq
2001-11-06 18:59:06 +00:00
math-build-units-table math-build-units-table-buffer
math-check-unit-name math-convert-temperature math-convert-units
math-extract-units math-remove-units math-simplify-units
math-single-units-in-expr-p math-to-standard-units
math-units-in-expr-p)
("calc-vec" calcFunc-append calcFunc-appendrev
2001-11-06 18:59:06 +00:00
calcFunc-arrange calcFunc-cnorm calcFunc-cons calcFunc-cross
calcFunc-kron calcFunc-ctrn calcFunc-cvec calcFunc-diag calcFunc-find
2001-11-06 18:59:06 +00:00
calcFunc-getdiag calcFunc-grade calcFunc-head calcFunc-histogram
calcFunc-idn calcFunc-index calcFunc-mcol calcFunc-mdims
calcFunc-mrcol calcFunc-mrow calcFunc-mrrow calcFunc-pack
calcFunc-rcons calcFunc-rdup calcFunc-rev calcFunc-rgrade
calcFunc-rhead calcFunc-rnorm calcFunc-rsort calcFunc-rsubvec
calcFunc-rtail calcFunc-sort calcFunc-subscr calcFunc-subvec
calcFunc-tail calcFunc-trn calcFunc-unpack calcFunc-unpackt
calcFunc-vcard calcFunc-vcompl calcFunc-vconcat calcFunc-vconcatrev
calcFunc-vdiff calcFunc-vec calcFunc-venum calcFunc-vexp
calcFunc-vfloor calcFunc-vint calcFunc-vlen calcFunc-vmask
calcFunc-vpack calcFunc-vspan calcFunc-vunion calcFunc-vunpack
calcFunc-vxor math-check-for-commas math-clean-set math-copy-matrix
math-dimension-error math-dot-product math-flatten-vector math-map-vec
math-map-vec-2 math-mat-col math-mimic-ident math-prepare-set
math-read-brackets math-reduce-cols math-reduce-vec math-transpose)
("calc-yank" calc-alg-edit calc-clean-newlines
2001-11-06 18:59:06 +00:00
calc-do-grab-rectangle calc-do-grab-region calc-finish-stack-edit
calc-copy-to-register calc-insert-register
calc-append-to-register calc-prepend-to-register
2001-11-06 18:59:06 +00:00
calc-force-refresh calc-locate-cursor-element calc-show-edit-buffer)
))
Don't quote lambdas with 'function' in calc/*.el * lisp/calc/calc-aent.el (calc-do-quick-calc) (calc-do-calc-eval, math-build-parse-table): * lisp/calc/calc-alg.el (math-polynomial-base): * lisp/calc/calc-alg.el (math-is-poly-rec): * lisp/calc/calc-arith.el (calcFunc-scf): * lisp/calc/calc-arith.el (math-ceiling, math-round): * lisp/calc/calc-arith.el (math-trunc-fancy, math-floor-fancy): * lisp/calc/calc-ext.el (calc-init-extensions, calc-reset) (calc-refresh-top, calc-z-prefix-help, calc-binary-op-fancy) (calc-unary-op-fancy): * lisp/calc/calc-forms.el (math-make-mod): * lisp/calc/calc-frac.el (calcFunc-frac): * lisp/calc/calc-funcs.el (calcFunc-euler): * lisp/calc/calc-help.el (calc-full-help): * lisp/calc/calc-lang.el (c, pascal, fortran, tex, latex, eqn) (yacas, maxima, giac, math, maple): * lisp/calc/calc-macs.el (calc-wrapper, calc-slow-wrapper): * lisp/calc/calc-map.el (calc-get-operator, calcFunc-mapeqr) (calcFunc-reducea, calcFunc-rreducea, calcFunc-reduced) (calcFunc-rreduced, calcFunc-outer): * lisp/calc/calc-misc.el (another-calc, calc-do-handle-whys): * lisp/calc/calc-mode.el (calc-save-modes): * lisp/calc/calc-mtx.el (math-col-matrix, math-mul-mat-vec): * lisp/calc/calc-poly.el (math-sort-terms, math-poly-div-list) (math-mul-list, math-sort-poly-base-list) (math-partial-fractions): * lisp/calc/calc-prog.el (calc-user-define-formula): * lisp/calc/calc-rewr.el (math-rewrite, math-compile-patterns) (math-compile-rewrites, math-parse-schedule) (math-rwcomp-pattern): * lisp/calc/calc-store.el (calc-var-name-map, calc-let) (calc-permanent-variable, calc-insert-variables): * lisp/calc/calc-stuff.el (calc-flush-caches, calcFunc-pclean) (calcFunc-pfrac): * lisp/calc/calc-units.el (math-build-units-table) (math-decompose-units): * lisp/calc/calc-vec.el (calcFunc-mrow, math-mat-col) (calcFunc-mcol, math-mat-less-col, math-mimic-ident): * lisp/calc/calc-yank.el (calc-edit): * lisp/calc/calc.el (calc-mode-var-list-restore-default-values) (calc-mode-var-list-restore-saved-values, calc-mode, calc-quit): * lisp/calc/calccomp.el (math-compose-expr) (math-compose-matrix, math-vector-to-string): Don't quote lambdas with 'function'.
2020-11-17 02:51:30 +01:00
(mapcar (lambda (x)
(mapcar (lambda (cmd) (autoload cmd (car x) nil t))
(cdr x)))
2001-11-06 18:59:06 +00:00
'(
("calc-alg" calc-alg-evaluate calc-apart calc-collect calc-expand
calc-expand-formula calc-factor calc-normalize-rat calc-poly-div
calc-poly-div-rem calc-poly-gcd calc-poly-rem calc-simplify
calc-simplify-extended calc-substitute calc-powerexpand)
2001-11-06 18:59:06 +00:00
("calcalg2" calc-alt-summation calc-derivative
2001-11-06 18:59:06 +00:00
calc-dump-integral-cache calc-integral calc-num-integral
calc-poly-roots calc-product calc-solve-for calc-summation
calc-tabulate calc-taylor)
("calcalg3" calc-curve-fit calc-find-maximum calc-find-minimum
2001-11-06 18:59:06 +00:00
calc-find-root calc-poly-interp)
("calc-arith" calc-abs calc-abssqr calc-ceiling calc-decrement
calc-floor calc-idiv calc-increment calc-mant-part calc-max calc-min
calc-round calc-scale-float calc-sign calc-trunc calc-xpon-part)
("calc-bin" calc-and calc-binary-radix calc-clip
calc-decimal-radix calc-diff calc-hex-radix calc-leading-zeros
calc-lshift-arith calc-lshift-binary calc-not calc-octal-radix calc-or calc-radix
2001-11-06 18:59:06 +00:00
calc-rotate-binary calc-rshift-arith calc-rshift-binary calc-word-size
calc-xor)
("calc-comb" calc-choose calc-double-factorial calc-extended-gcd
calc-factorial calc-gamma calc-gcd calc-lcm calc-moebius
calc-next-prime calc-perm calc-prev-prime calc-prime-factors
calc-prime-test calc-random calc-random-again calc-rrandom
calc-shuffle calc-totient)
("calc-cplx" calc-argument calc-complex-notation calc-i-notation
calc-im calc-j-notation calc-polar calc-polar-mode calc-re)
("calc-embed" calc-embedded-copy-formula-as-kill
calc-embedded-duplicate calc-embedded-edit calc-embedded-forget
calc-embedded-kill-formula calc-embedded-mark-formula
calc-embedded-new-formula calc-embedded-next calc-embedded-previous
calc-embedded-select calc-embedded-update-formula calc-embedded-word
calc-find-globals calc-show-plain)
("calc-fin" calc-convert-percent calc-fin-ddb calc-fin-fv
calc-fin-irr calc-fin-nper calc-fin-npv calc-fin-pmt calc-fin-pv
calc-fin-rate calc-fin-sln calc-fin-syd calc-percent-change)
("calc-forms" calc-business-days-minus calc-business-days-plus
calc-convert-time-zones calc-date calc-date-notation calc-date-part
calc-from-hms calc-hms-mode calc-hms-notation calc-inc-month
calc-julian calc-new-month calc-new-week calc-new-year calc-now
calc-time calc-time-zone calc-to-hms calc-unix-time)
("calc-frac" calc-fdiv calc-frac-mode calc-fraction
calc-over-notation calc-slash-notation)
("calc-funcs" calc-bernoulli-number calc-bessel-J calc-bessel-Y
calc-beta calc-erf calc-erfc calc-euler-number calc-inc-beta
calc-inc-gamma calc-stirling-number calc-utpb calc-utpc calc-utpf
calc-utpn calc-utpp calc-utpt)
("calc-graph" calc-graph-add calc-graph-add-3d calc-graph-border
calc-graph-clear calc-graph-command calc-graph-delete
calc-graph-device calc-graph-display calc-graph-fast
calc-graph-fast-3d calc-graph-geometry calc-graph-grid
calc-graph-header calc-graph-hide calc-graph-juggle calc-graph-key
calc-graph-kill calc-graph-line-style calc-graph-log-x
calc-graph-log-y calc-graph-log-z calc-graph-name
calc-graph-num-points calc-graph-output calc-graph-plot
calc-graph-point-style calc-graph-print calc-graph-quit
calc-graph-range-x calc-graph-range-y calc-graph-range-z
calc-graph-show-dumb calc-graph-title-x calc-graph-title-y
calc-graph-title-z calc-graph-view-commands calc-graph-view-trail
calc-graph-zero-x calc-graph-zero-y)
("calc-help" calc-a-prefix-help calc-b-prefix-help calc-c-prefix-help
calc-d-prefix-help calc-describe-function calc-describe-key
calc-describe-key-briefly calc-describe-variable calc-f-prefix-help
calc-full-help calc-g-prefix-help calc-help-prefix
calc-hyperbolic-prefix-help calc-inv-hyp-prefix-help calc-option-prefix-help
2001-11-06 18:59:06 +00:00
calc-inverse-prefix-help calc-j-prefix-help calc-k-prefix-help
calc-m-prefix-help calc-r-prefix-help calc-s-prefix-help
calc-t-prefix-help calc-u-prefix-help calc-l-prefix-help
calc-v-prefix-help)
2001-11-06 18:59:06 +00:00
("calc-incom" calc-begin-complex calc-begin-vector calc-comma
calc-dots calc-end-complex calc-end-vector calc-semi)
("calc-keypd" calc-keypad-menu calc-keypad-menu-back
calc-keypad-press)
("calc-lang" calc-big-language calc-c-language calc-eqn-language
calc-flat-language calc-fortran-language calc-maple-language
calc-yacas-language calc-maxima-language calc-giac-language
2001-11-06 18:59:06 +00:00
calc-mathematica-language calc-normal-language calc-pascal-language
calc-tex-language calc-latex-language calc-unformatted-language)
2001-11-06 18:59:06 +00:00
("calc-map" calc-accumulate calc-apply calc-inner-product calc-map
calc-map-equation calc-map-stack calc-outer-product calc-reduce)
("calc-mtx" calc-mdet calc-mlud calc-mtrace)
2001-11-06 18:59:06 +00:00
("calc-math" calc-arccos calc-arccosh calc-arcsin calc-arcsinh
calc-arctan calc-arctan2 calc-arctanh calc-conj calc-cos calc-cosh
2005-02-15 19:24:49 +00:00
calc-cot calc-coth calc-csc calc-csch
2001-11-06 18:59:06 +00:00
calc-degrees-mode calc-exp calc-expm1 calc-hypot calc-ilog
calc-imaginary calc-isqrt calc-ln calc-lnp1 calc-log calc-log10
calc-pi calc-radians-mode calc-sec calc-sech
2005-02-15 19:24:49 +00:00
calc-sin calc-sincos calc-sinh calc-sqrt
2001-11-06 18:59:06 +00:00
calc-tan calc-tanh calc-to-degrees calc-to-radians)
("calc-mode" calc-alg-simplify-mode calc-algebraic-mode
2001-11-06 18:59:06 +00:00
calc-always-load-extensions calc-auto-recompute calc-auto-why
calc-basic-simplify-mode calc-bin-simplify-mode calc-break-vectors
calc-center-justify calc-default-simplify-mode calc-display-raw
calc-eng-notation calc-ext-simplify-mode calc-fix-notation
calc-full-trail-vectors calc-full-vectors calc-get-modes calc-group-char
calc-group-digits calc-infinite-mode calc-left-justify calc-left-label
2001-11-06 18:59:06 +00:00
calc-line-breaking calc-line-numbering calc-matrix-brackets
calc-matrix-center-justify calc-matrix-left-justify calc-matrix-mode
calc-matrix-right-justify calc-mode-record-mode calc-no-simplify-mode
calc-normal-notation calc-num-simplify-mode calc-point-char
calc-right-justify calc-right-label calc-save-modes calc-sci-notation
calc-settings-file-name calc-shift-prefix calc-symbolic-mode
calc-total-algebraic-mode calc-truncate-down calc-truncate-stack
calc-truncate-up calc-units-simplify-mode calc-vector-braces
calc-vector-brackets calc-vector-commas calc-vector-parens
calc-working)
("calc-prog" calc-call-last-kbd-macro calc-edit-user-syntax
calc-equal-to calc-get-user-defn calc-greater-equal calc-greater-than
calc-in-set calc-kbd-break calc-kbd-else calc-kbd-else-if
calc-kbd-end-for calc-kbd-end-if calc-kbd-end-loop calc-kbd-end-repeat
calc-kbd-for calc-kbd-if calc-kbd-loop calc-kbd-pop calc-kbd-push
calc-kbd-query calc-kbd-repeat calc-less-equal
2001-11-06 18:59:06 +00:00
calc-less-than calc-logical-and calc-logical-if calc-logical-not
calc-logical-or calc-not-equal-to calc-pass-errors calc-remove-equal
calc-timing calc-user-define calc-user-define-composition
calc-user-define-edit calc-user-define-formula
calc-user-define-invocation calc-user-define-kbd-macro
calc-user-define-permanent calc-user-undefine)
("calc-rewr" calc-match calc-rewrite calc-rewrite-selection)
("calc-sel" calc-break-selections calc-clear-selections
calc-copy-selection calc-del-selection calc-edit-selection
calc-enable-selections calc-enter-selection calc-sel-add-both-sides
calc-sel-div-both-sides calc-sel-evaluate calc-sel-expand-formula
calc-sel-mult-both-sides calc-sel-sub-both-sides
calc-select-additional calc-select-here calc-select-here-maybe
calc-select-less calc-select-more calc-select-next calc-select-once
calc-select-once-maybe calc-select-part calc-select-previous
calc-show-selections calc-unselect)
("calcsel2" calc-commute-left calc-commute-right calc-sel-commute
2001-11-06 18:59:06 +00:00
calc-sel-distribute calc-sel-invert calc-sel-isolate
calc-sel-jump-equals calc-sel-merge calc-sel-negate calc-sel-unpack)
("calc-stat" calc-vector-correlation calc-vector-count
calc-vector-covariance calc-vector-geometric-mean
calc-vector-harmonic-mean calc-vector-max calc-vector-mean
calc-vector-mean-error calc-vector-median calc-vector-min
calc-vector-pop-covariance calc-vector-pop-sdev
calc-vector-pop-variance calc-vector-product calc-vector-rms
calc-vector-sdev calc-vector-sum calc-vector-variance)
2001-11-06 18:59:06 +00:00
("calc-store" calc-assign calc-copy-special-constant
calc-copy-variable calc-declare-variable
2001-11-06 18:59:06 +00:00
calc-edit-AlgSimpRules calc-edit-Decls calc-edit-EvalRules
calc-edit-ExtSimpRules calc-edit-FitRules calc-edit-GenCount
calc-edit-Holidays calc-edit-IntegLimit calc-edit-LineStyles
calc-edit-PlotRejects calc-edit-PointStyles calc-edit-TimeZone
calc-edit-Units calc-edit-variable calc-evalto calc-insert-variables
calc-let calc-permanent-variable calc-recall calc-recall-quick
calc-store calc-store-concat calc-store-decr calc-store-div
calc-store-exchange calc-store-incr calc-store-into
calc-store-into-quick calc-store-inv calc-store-map calc-store-minus
calc-store-neg calc-store-plus calc-store-power calc-store-quick
calc-store-times calc-subscript calc-unstore)
("calc-stuff" calc-clean calc-clean-num calc-flush-caches
calc-less-recursion-depth calc-more-recursion-depth calc-num-prefix
2008-08-14 18:32:40 +00:00
calc-why)
2001-11-06 18:59:06 +00:00
("calc-trail" calc-trail-backward calc-trail-first calc-trail-forward
calc-trail-in calc-trail-isearch-backward calc-trail-isearch-forward
calc-trail-kill calc-trail-last calc-trail-marker calc-trail-next
calc-trail-out calc-trail-previous calc-trail-scroll-left
calc-trail-scroll-right calc-trail-yank)
("calc-undo" calc-last-args calc-redo)
2001-11-06 18:59:06 +00:00
("calc-units" calc-autorange-units calc-base-units
calc-convert-temperature calc-convert-units
calc-convert-exact-units calc-define-unit
2001-11-06 18:59:06 +00:00
calc-enter-units-table calc-explain-units calc-extract-units
calc-get-unit-definition calc-permanent-units calc-quick-units
calc-remove-units calc-simplify-units calc-undefine-unit
* lisp/calc/README: Mention musical notes. * lisp/calc-units.el (calc-lu-quant): Rename from `calc-logunits-quantity'. (calcFunc-lupquant): Rename from `calcFunc-powerquant'. (calcFunc-lufquant): Rename from `calcFunc-fieldquant'. (calc-db): Rename from `calc-dblevel'. (calcFunc-dbpower): Rename from `calcFunc-dbpowerlevel'. (calcFunc-dbfield): Rename from `calcFunc-dbfieldlevel'. (calc-np): Rename from `calc-nplevel'. (calcFunc-nppower): Rename from `calcFunc-nppowerlevel'. (calcFunc-npfield): Rename from `calcFunc-npfieldlevel'. (calc-lu-plus): Rename from `calc-logunits-add'. (calcFunc-lupadd): Rename from `calcFunc-lupoweradd'. (calcFunc-lufadd): Rename from `calcFunc-lufieldadd'. (calc-lu-minus): Rename from `calc-logunits-sub'. (calcFunc-lupsub): Rename from `calcFunc-lupowersub'. (calcFunc-lufsub): Rename from `calcFunc-lufieldsub'. (calc-lu-times): Rename from `calc-logunits-mul'. (calcFunc-lupmul): Rename from `calcFunc-lupowermul'. (calcFunc-lufmul): Rename from `calcFunc-lufieldmul'. (calc-lu-divide): Rename from `calc-logunits-div'. (calcFunc-lupdiv): Rename from `calcFunc-lupowerdiv'. (calcFunc-lufdiv): Rename from `calcFunc-lufielddiv'. * lisp/calc/calc-ext.el (calc-init-extensions): Update the names of the functions being autoloaded. * lisp/calc/calc.el (calc-lu-power-reference): Rename from `calc-logunits-power-reference'. (calc-lu-field-reference): Rename from `calc-logunits-field-reference'. * lisp/calc/calc-help (calc-l-prefix-help): Mention musical note functions. * doc/misc/calc.texi (Logarithmic Units): Update the function names.
2011-03-16 20:30:08 -05:00
calc-view-units-table calc-lu-quant calc-db
calc-np calc-lu-plus calc-lu-minus
calc-lu-times calc-lu-divide calc-spn calc-midi
calc-freq)
2001-11-06 18:59:06 +00:00
("calc-vec" calc-arrange-vector calc-build-vector calc-cnorm
calc-conj-transpose calc-cons calc-cross calc-kron calc-diag
2001-11-06 18:59:06 +00:00
calc-display-strings calc-expand-vector calc-grade calc-head
calc-histogram calc-ident calc-index calc-mask-vector calc-mcol
calc-mrow calc-pack calc-pack-bits calc-remove-duplicates
calc-reverse-vector calc-rnorm calc-set-cardinality
calc-set-complement calc-set-difference calc-set-enumerate
calc-set-floor calc-set-intersect calc-set-span calc-set-union
calc-set-xor calc-sort calc-subvector calc-tail calc-transpose
calc-unpack calc-unpack-bits calc-vector-find calc-vlength)
("calc-yank" calc-copy-as-kill calc-copy-region-as-kill
calc-copy-to-buffer calc-edit calc-edit-cancel calc--edit-mode
calc-kill calc-kill-region calc-yank))))
2001-11-06 18:59:06 +00:00
(defun calc-init-prefixes ()
(if calc-shift-prefix
(progn
(define-key calc-mode-map "A" (lookup-key calc-mode-map "a"))
(define-key calc-mode-map "B" (lookup-key calc-mode-map "b"))
(define-key calc-mode-map "C" (lookup-key calc-mode-map "c"))
(define-key calc-mode-map "D" (lookup-key calc-mode-map "d"))
(define-key calc-mode-map "F" (lookup-key calc-mode-map "f"))
(define-key calc-mode-map "G" (lookup-key calc-mode-map "g"))
(define-key calc-mode-map "J" (lookup-key calc-mode-map "j"))
(define-key calc-mode-map "K" (lookup-key calc-mode-map "k"))
(define-key calc-mode-map "M" (lookup-key calc-mode-map "m"))
(define-key calc-mode-map "S" (lookup-key calc-mode-map "s"))
(define-key calc-mode-map "T" (lookup-key calc-mode-map "t"))
(define-key calc-mode-map "U" (lookup-key calc-mode-map "u")))
(define-key calc-mode-map "A" 'calc-abs)
(define-key calc-mode-map "B" 'calc-log)
(define-key calc-mode-map "C" 'calc-cos)
(define-key calc-mode-map "D" 'calc-redo)
(define-key calc-mode-map "F" 'calc-floor)
(define-key calc-mode-map "G" 'calc-argument)
(define-key calc-mode-map "J" 'calc-conj)
(define-key calc-mode-map "K" 'calc-keep-args)
(define-key calc-mode-map "M" 'calc-more-recursion-depth)
(define-key calc-mode-map "S" 'calc-sin)
(define-key calc-mode-map "T" 'calc-tan)
(define-key calc-mode-map "U" 'calc-undo)))
2001-11-06 18:59:06 +00:00
(calc-init-extensions)
;;;; Miscellaneous.
;; calc-command-flags is declared in calc.el
(defvar calc-command-flags)
2001-11-06 18:59:06 +00:00
(defun calc-clear-command-flag (f)
(setq calc-command-flags (delq f calc-command-flags)))
2001-11-06 18:59:06 +00:00
(defun calc-record-message (tag &rest args)
More-conservative ‘format’ quote restyling Instead of restyling curved quotes for every call to ‘format’, create a new function ‘format-message’ that does the restyling, and using the new function instead of ‘format’ only in contexts where this seems appropriate. Problem reported by Dmitry Gutov and Andreas Schwab in: http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00826.html http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00827.html * doc/lispref/commands.texi (Using Interactive): * doc/lispref/control.texi (Signaling Errors, Signaling Errors): * doc/lispref/display.texi (Displaying Messages, Progress): * doc/lispref/elisp.texi: * doc/lispref/help.texi (Keys in Documentation): * doc/lispref/minibuf.texi (Minibuffer Misc): * doc/lispref/strings.texi (Formatting Strings): * etc/NEWS: Document the changes. * lisp/abbrev.el (expand-region-abbrevs): * lisp/apropos.el (apropos-library): * lisp/calc/calc-ext.el (calc-record-message) (calc-user-function-list): * lisp/calc/calc-help.el (calc-describe-key, calc-full-help): * lisp/calc/calc-lang.el (math-read-big-balance): * lisp/calc/calc-store.el (calc-edit-variable): * lisp/calc/calc-units.el (math-build-units-table-buffer): * lisp/calc/calc-yank.el (calc-edit-mode): * lisp/calendar/icalendar.el (icalendar-export-region) (icalendar--add-diary-entry): * lisp/cedet/mode-local.el (mode-local-print-binding) (mode-local-describe-bindings-2): * lisp/cedet/semantic/complete.el (semantic-completion-message): * lisp/cedet/semantic/edit.el (semantic-parse-changes-failed): * lisp/cedet/semantic/wisent/comp.el (wisent-log): * lisp/cedet/srecode/insert.el (srecode-insert-show-error-report): * lisp/descr-text.el (describe-text-properties-1, describe-char): * lisp/dframe.el (dframe-message): * lisp/dired-aux.el (dired-query): * lisp/emacs-lisp/byte-opt.el (byte-compile-log-lap-1): * lisp/emacs-lisp/bytecomp.el (byte-compile-log) (byte-compile-log-file, byte-compile-warn, byte-compile-form): * lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use) (cconv-analyze-form): * lisp/emacs-lisp/check-declare.el (check-declare-warn): * lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine): * lisp/emacs-lisp/cl-macs.el (cl-symbol-macrolet): * lisp/emacs-lisp/edebug.el (edebug-format): * lisp/emacs-lisp/eieio-core.el (eieio-oref): * lisp/emacs-lisp/eldoc.el (eldoc-minibuffer-message) (eldoc-message): * lisp/emacs-lisp/elint.el (elint-file, elint-log): * lisp/emacs-lisp/find-func.el (find-function-library): * lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning): * lisp/emacs-lisp/map-ynp.el (map-y-or-n-p): * lisp/emacs-lisp/nadvice.el (advice--make-docstring): * lisp/emacs-lisp/package.el (package-compute-transaction) (package-install-button-action, package-delete-button-action) (package-menu--list-to-prompt): * lisp/emacs-lisp/timer.el (timer-event-handler): * lisp/emacs-lisp/warnings.el (lwarn, warn): * lisp/emulation/viper-cmd.el: (viper-toggle-parse-sexp-ignore-comments) (viper-kill-buffer, viper-brac-function): * lisp/emulation/viper-macs.el (viper-record-kbd-macro): * lisp/facemenu.el (facemenu-add-new-face): * lisp/faces.el (face-documentation, read-face-name) (face-read-string, read-face-font, describe-face): * lisp/files.el (find-alternate-file, hack-local-variables) (hack-one-local-variable--obsolete, write-file) (basic-save-buffer, delete-directory): * lisp/format.el (format-write-file, format-find-file) (format-insert-file): * lisp/help-fns.el (help-fns--key-bindings) (help-fns--compiler-macro, help-fns--obsolete) (help-fns--interactive-only, describe-function-1) (describe-variable): * lisp/help.el (describe-mode): * lisp/info-xref.el (info-xref-output): * lisp/info.el (Info-virtual-index-find-node) (Info-virtual-index, info-apropos): * lisp/international/kkc.el (kkc-error): * lisp/international/mule-cmds.el: (select-safe-coding-system-interactively) (select-safe-coding-system, describe-input-method): * lisp/international/mule-conf.el (code-offset): * lisp/international/mule-diag.el (describe-character-set) (list-input-methods-1): * lisp/international/quail.el (quail-error): * lisp/minibuffer.el (minibuffer-message): * lisp/mpc.el (mpc--debug): * lisp/msb.el (msb--choose-menu): * lisp/net/ange-ftp.el (ange-ftp-message): * lisp/net/gnutls.el (gnutls-message-maybe): * lisp/net/newst-backend.el (newsticker--sentinel-work): * lisp/net/newst-treeview.el (newsticker--treeview-load): * lisp/net/nsm.el (nsm-query-user): * lisp/net/rlogin.el (rlogin): * lisp/net/soap-client.el (soap-warning): * lisp/net/tramp.el (tramp-debug-message): * lisp/nxml/nxml-outln.el (nxml-report-outline-error): * lisp/nxml/nxml-parse.el (nxml-parse-error): * lisp/nxml/rng-cmpct.el (rng-c-error): * lisp/nxml/rng-match.el (rng-compile-error): * lisp/nxml/rng-uri.el (rng-uri-error): * lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer): * lisp/org/org-ctags.el: (org-ctags-ask-rebuild-tags-file-then-find-tag): * lisp/proced.el (proced-log): * lisp/progmodes/ebnf2ps.el (ebnf-log): * lisp/progmodes/flymake.el (flymake-log): * lisp/progmodes/vhdl-mode.el (vhdl-warning-when-idle): * lisp/replace.el (occur-1): * lisp/simple.el (execute-extended-command) (undo-outer-limit-truncate, define-alternatives): * lisp/startup.el (command-line): * lisp/subr.el (error, user-error, add-to-list): * lisp/tutorial.el (tutorial--describe-nonstandard-key) (tutorial--find-changed-keys): * src/callint.c (Fcall_interactively): * src/editfns.c (Fmessage, Fmessage_box): Restyle the quotes of format strings intended for use as a diagnostic, when restyling seems appropriate. * lisp/subr.el (format-message): New function. * src/doc.c (Finternal__text_restyle): New function. (syms_of_doc): Define it.
2015-08-23 22:38:02 -07:00
(let ((msg (apply #'format-message args)))
2001-11-06 18:59:06 +00:00
(message "%s" msg)
(calc-record msg tag))
(calc-clear-command-flag 'clear-message))
2001-11-06 18:59:06 +00:00
(defun calc-normalize-fancy (val)
(let ((simp (if (consp calc-simplify-mode)
(car calc-simplify-mode)
calc-simplify-mode)))
(cond ((eq simp 'binary)
(let ((s (math-normalize val)))
(if (math-realp s)
(math-clip (math-round s))
s)))
((eq simp 'alg)
(math-simplify val))
((eq simp 'ext)
(math-simplify-extended val))
((eq simp 'units)
(math-simplify-units val))
(t ; nil, none, num
(math-normalize val)))))
2001-11-06 18:59:06 +00:00
(defvar-keymap calc-help-map
"b" 'calc-describe-bindings
"c" 'calc-describe-key-briefly
"f" 'calc-describe-function
"h" 'calc-full-help
"i" 'calc-info
"k" 'calc-describe-key
"n" 'calc-view-news
"s" 'calc-info-summary
"t" 'calc-tutorial
"v" 'calc-describe-variable
"C-c" 'calc-describe-copying
"C-d" 'calc-describe-distribution
"C-n" 'calc-view-news
"C-w" 'calc-describe-no-warranty
"?" 'calc-help-for-help
"C-h" 'calc-help-for-help)
2001-11-06 18:59:06 +00:00
(defvar calc-prefix-help-retry nil)
(defvar calc-prefix-help-phase 0)
2001-11-06 18:59:06 +00:00
(defun calc-do-prefix-help (msgs group key)
(if calc-full-help-flag
(list msgs group key)
(if (cdr msgs)
(progn
(setq calc-prefix-help-phase
(if calc-prefix-help-retry
2001-11-06 18:59:06 +00:00
(% (1+ calc-prefix-help-phase) (1+ (length msgs)))
0))
(let ((msg (nth calc-prefix-help-phase msgs)))
(message "%s" (if msg
(concat group ": " msg ":"
(make-string
2018-11-20 16:09:35 -05:00
(- (apply #'max (mapcar #'length msgs))
(length msg))
?\s)
2001-11-06 18:59:06 +00:00
" [MORE]"
(if key
(concat " " (char-to-string key)
"-")
""))
(if key (format "%c-" key) "")))))
(setq calc-prefix-help-phase 0)
(if key
(if msgs
(message "%s: %s: %c-" group (car msgs) key)
(message "%s: (none) %c-" group key))
2001-11-06 18:59:06 +00:00
(message "%s: %s" group (car msgs))))
(let* ((chr (read-char))
(bnd (local-key-binding (if key (string key chr) (string chr)))))
(setq calc-prefix-help-retry (= chr ??))
(if bnd
(call-interactively bnd)
(message "%s is undefined"
(key-description (if key (vector key chr) (vector chr))))))))
2001-11-06 18:59:06 +00:00
;;;; Commands.
;;; General.
2018-11-20 16:09:35 -05:00
(defvar calc-embedded-quiet)
2001-11-06 18:59:06 +00:00
(defun calc-reset (arg)
(interactive "P")
(setq arg (if arg (prefix-numeric-value arg) nil))
(cond
((and
calc-embedded-info
(equal (aref calc-embedded-info 0) (current-buffer))
(<= (point) (aref calc-embedded-info 5))
(>= (point) (aref calc-embedded-info 4)))
(let ((cbuf (aref calc-embedded-info 1))
(calc-embedded-quiet t))
(save-window-excursion
(calc-embedded nil)
(set-buffer cbuf)
(calc-reset arg))
(calc-embedded nil)))
((eq major-mode 'calc-mode)
(save-excursion
(unless (and arg (> (abs arg) 0))
(setq calc-stack nil))
(setq calc-undo-list nil
calc-redo-list nil)
(let (calc-stack calc-user-parse-tables calc-standard-date-formats
calc-invocation-macro)
Don't quote lambdas with 'function' in calc/*.el * lisp/calc/calc-aent.el (calc-do-quick-calc) (calc-do-calc-eval, math-build-parse-table): * lisp/calc/calc-alg.el (math-polynomial-base): * lisp/calc/calc-alg.el (math-is-poly-rec): * lisp/calc/calc-arith.el (calcFunc-scf): * lisp/calc/calc-arith.el (math-ceiling, math-round): * lisp/calc/calc-arith.el (math-trunc-fancy, math-floor-fancy): * lisp/calc/calc-ext.el (calc-init-extensions, calc-reset) (calc-refresh-top, calc-z-prefix-help, calc-binary-op-fancy) (calc-unary-op-fancy): * lisp/calc/calc-forms.el (math-make-mod): * lisp/calc/calc-frac.el (calcFunc-frac): * lisp/calc/calc-funcs.el (calcFunc-euler): * lisp/calc/calc-help.el (calc-full-help): * lisp/calc/calc-lang.el (c, pascal, fortran, tex, latex, eqn) (yacas, maxima, giac, math, maple): * lisp/calc/calc-macs.el (calc-wrapper, calc-slow-wrapper): * lisp/calc/calc-map.el (calc-get-operator, calcFunc-mapeqr) (calcFunc-reducea, calcFunc-rreducea, calcFunc-reduced) (calcFunc-rreduced, calcFunc-outer): * lisp/calc/calc-misc.el (another-calc, calc-do-handle-whys): * lisp/calc/calc-mode.el (calc-save-modes): * lisp/calc/calc-mtx.el (math-col-matrix, math-mul-mat-vec): * lisp/calc/calc-poly.el (math-sort-terms, math-poly-div-list) (math-mul-list, math-sort-poly-base-list) (math-partial-fractions): * lisp/calc/calc-prog.el (calc-user-define-formula): * lisp/calc/calc-rewr.el (math-rewrite, math-compile-patterns) (math-compile-rewrites, math-parse-schedule) (math-rwcomp-pattern): * lisp/calc/calc-store.el (calc-var-name-map, calc-let) (calc-permanent-variable, calc-insert-variables): * lisp/calc/calc-stuff.el (calc-flush-caches, calcFunc-pclean) (calcFunc-pfrac): * lisp/calc/calc-units.el (math-build-units-table) (math-decompose-units): * lisp/calc/calc-vec.el (calcFunc-mrow, math-mat-col) (calcFunc-mcol, math-mat-less-col, math-mimic-ident): * lisp/calc/calc-yank.el (calc-edit): * lisp/calc/calc.el (calc-mode-var-list-restore-default-values) (calc-mode-var-list-restore-saved-values, calc-mode, calc-quit): * lisp/calc/calccomp.el (math-compose-expr) (math-compose-matrix, math-vector-to-string): Don't quote lambdas with 'function'.
2020-11-17 02:51:30 +01:00
(mapc (lambda (v) (set v nil)) calc-local-var-list)
(if (and arg (<= arg 0))
(calc-mode-var-list-restore-default-values)
(calc-mode-var-list-restore-saved-values)))
(calc-set-language nil nil t)
(calc-mode)
(calc-flush-caches t)
(run-hooks 'calc-reset-hook))
(calc-wrapper
(let ((win (get-buffer-window (current-buffer))))
(calc-realign 0)
;; Adjust the window height if the window is visible, but doesn't
;; take up the whole height of the frame.
(if (and
win
2009-10-06 02:42:29 +00:00
(not (window-full-height-p)))
(let ((height (- (window-height win) 2)))
(set-window-point win (point))
(or (= height calc-window-height)
(let ((swin (selected-window)))
(select-window win)
(enlarge-window (- calc-window-height height))
(select-window swin)))))))
(message "(Calculator reset)"))
(t
(message "(Not inside a Calc buffer)"))))
2001-11-06 18:59:06 +00:00
;; What a pain; scroll-left behaves differently when called non-interactively.
2001-11-06 18:59:06 +00:00
(defun calc-scroll-left (n)
(interactive "P")
(setq prefix-arg (or n (/ (window-width) 2)))
(call-interactively #'scroll-left))
2001-11-06 18:59:06 +00:00
(defun calc-scroll-right (n)
(interactive "P")
(setq prefix-arg (or n (/ (window-width) 2)))
(call-interactively #'scroll-right))
2001-11-06 18:59:06 +00:00
(defun calc-scroll-up (n)
(interactive "P")
* lisp/calc/: Use lexical scoping in all the files Includes the following pervasive changes: - Move some defvars earlier in the file so they cover earlier let-bindings - Change dynamically scoped `calc-FOO` or `math-FOO` function arguments to just FOO and then let-bind the `calc-FOO` or `math-FOO` variable explicitly in the body of the function. In some cases, the beginning of the function was changed to refer to FOO so as to delay the binding to a nearby `let` when I could ensure that it did not make a difference. - Add an underscore in front of unused vars or comment them out altogether. - Replace unused `err` arg to `condition-case` with nil. Plus the additional itemized changes below. * lisp/calc/calc-map.el (calcFunc-reducer): * lisp/calc/calc-arith.el (math-setup-declarations): * lisp/calc/calc-help.el (calc-full-help, calc-help-index-entries) (calc-full-help): Use `ignore-errors`. * lisp/calc/calc-embed.el (calc-embedded-modes-change): Declare `the-language` and `the-display-just` as dynamically scoped. * lisp/calc/calc-forms.el (math-setup-year-holidays): Use `dolist`. * lisp/calc/calc-graph.el (calc-graph-set-styles): Use `symbol-value` rather than `eval.` (calc-graph-delete-temps, calc-graph-set-styles): Use ignore-errors. * lisp/calc/calc-macs.el (calc-with-trail-buffer): Add artificial use of `save-buf` to silence compiler warnings in all the cases where `body` doesn't make use of it. * lisp/calc/calc-math.el (math-largest-emacs-expt) (math-smallest-emacs-expt, math-use-emacs-fn): Use ignore-errors. * lisp/calc/calc-mode.el (calc-total-algebraic-mode): Remove "P" from interactive spec since it's not used anyway. * lisp/calc/calc-rewr.el (calc-match): Simplify. * lisp/calc/calc.el (calc-buffer): Give it a global nil value, so it's automatically declared dynbound in any file that requires `calc`. (calcDigit-nondigit): Adjust accordingly. * lisp/calc/calcalg2.el (calcFunc-table): Declare `var-dummy` as dynbound. (math-scan-for-limits): Comment out dead code. * lisp/calc/calcalg3.el (math-general-fit): Declare `var-YVAL` and `var-YVALX` as dynbound.
2020-10-10 16:00:51 -04:00
(ignore-errors
(scroll-up (or n (/ (window-height) 2))))
2001-11-06 18:59:06 +00:00
(if (pos-visible-in-window-p (max 1 (- (point-max) 2)))
(if (eq major-mode 'calc-mode)
(calc-realign)
(goto-char (point-max))
(set-window-start (selected-window)
(save-excursion
(forward-line (- (1- (window-height))))
(point)))
(forward-line -1))))
2001-11-06 18:59:06 +00:00
(defun calc-scroll-down (n)
(interactive "P")
(or (pos-visible-in-window-p 1)
(scroll-down (or n (/ (window-height) 2)))))
2001-11-06 18:59:06 +00:00
(defun calc-precision (n)
(interactive "NPrecision: ")
(calc-wrapper
(if (< (prefix-numeric-value n) 3)
(error "Precision must be at least 3 digits")
2001-11-06 18:59:06 +00:00
(calc-change-mode 'calc-internal-prec (prefix-numeric-value n)
(and (memq (car calc-float-format) '(float sci eng))
(< (nth 1 calc-float-format)
(if (= calc-number-radix 10) 0 1))))
(calc-record calc-internal-prec "prec"))
(message "Floating-point precision is %d digits" calc-internal-prec)))
2001-11-06 18:59:06 +00:00
(defun calc-inverse (&optional n)
(interactive "P")
(let* ((hyp-flag (if (or
(eq major-mode 'calc-keypad-mode)
(eq major-mode 'calc-trail-mode))
(with-current-buffer calc-main-buffer
calc-hyperbolic-flag)
calc-hyperbolic-flag))
(opt-flag (if (or
(eq major-mode 'calc-keypad-mode)
(eq major-mode 'calc-trail-mode))
(with-current-buffer calc-main-buffer
calc-option-flag)
calc-option-flag))
(msg
(cond
((and opt-flag hyp-flag) "Option Inverse Hyperbolic...")
(hyp-flag "Inverse Hyperbolic...")
(opt-flag "Option Inverse...")
(t "Inverse..."))))
(calc-fancy-prefix 'calc-inverse-flag msg n)))
2001-11-06 18:59:06 +00:00
(defconst calc-fancy-prefix-map
(let ((map (make-sparse-keymap)))
(define-key map [t] 'calc-fancy-prefix-other-key)
(define-key map (vector meta-prefix-char t) 'calc-fancy-prefix-other-key)
(define-key map [switch-frame] nil)
(define-key map [?\C-u] 'universal-argument)
(define-key map [?0] 'digit-argument)
(define-key map [?1] 'digit-argument)
(define-key map [?2] 'digit-argument)
(define-key map [?3] 'digit-argument)
(define-key map [?4] 'digit-argument)
(define-key map [?5] 'digit-argument)
(define-key map [?6] 'digit-argument)
(define-key map [?7] 'digit-argument)
(define-key map [?8] 'digit-argument)
(define-key map [?9] 'digit-argument)
map)
"Keymap used while processing calc-fancy-prefix.")
(defvar calc-is-keypad-press nil)
2001-11-06 18:59:06 +00:00
(defun calc-fancy-prefix (flag msg n)
(let (prefix)
(calc-wrapper
(calc-set-command-flag 'keep-flags)
(calc-set-command-flag 'no-align)
(setq prefix (set flag (not (symbol-value flag)))
prefix-arg n)
* erc-stamp.el (erc-echo-timestamp): * erc-lang.el (language): * erc-backend.el (erc-server-connect): Fix buggy call to `message'. * gnus-sum.el (gnus-summary-simplify-subject-query): * ecomplete.el (ecomplete-display-matches): Fix buggy call to `message'. * textmodes/reftex.el (reftex-select-with-char): * textmodes/reftex-toc.el (reftex-toc-do-promote) (reftex-toc-visit-location, reftex-toc-find-section): * textmodes/reftex-index.el (reftex-index-show-entry): * textmodes/org.el (org-cycle-hide-archived-subtrees) (org-table-rotate-recalc-marks, org-mark-ring-push) (org-follow-info-link, org-mhe-get-message-folder-from-index) (org-auto-repeat-maybe, org-store-log-note, org-delete-property) (org-evaluate-time-range, org-edit-agenda-file-list): * textmodes/artist.el (artist-select-next-op-in-list) (artist-select-prev-op-in-list): * term/mac-win.el (mac-service-insert-text): * startup.el (fancy-about-screen): * progmodes/vhdl-mode.el (vhdl-decision-query): * progmodes/idlwave.el (idlwave-template) (idlwave-scroll-completions, idlwave-display-completion-list): * progmodes/ebrowse.el (ebrowse-show-progress): * progmodes/cperl-mode.el (cperl-find-pods-heres): * progmodes/antlr-mode.el (antlr-insert-option-do): * play/mpuz.el (mpuz-close-game): * net/rcirc.el (rcirc-next-active-buffer): * mail/reporter.el (reporter-update-status): * kmacro.el (kmacro-display): * international/ja-dic-cnv.el (skkdic-set-okuri-nasi): * emulation/viper-util.el (viper-save-setting): * emacs-lisp/lisp-mnt.el (lm-verify): * emacs-lisp/edebug.el (edebug-set-mode): * emacs-lisp/checkdoc.el (checkdoc-rogue-spaces, checkdoc-defun): * calendar/calendar.el (calendar-print-day-of-year): * calc/calcalg3.el (calc-curve-fit): * calc/calcalg2.el (math-integral): * calc/calc.el (calc-read-key-sequence, calc-version): * calc/calc-mode.el (calc-set-simplify-mode): * calc/calc-ext.el (calc-fancy-prefix): Fix buggy call to `message'.
2007-12-08 01:02:29 +00:00
(message "%s" (if prefix msg "")))
2001-11-06 18:59:06 +00:00
(and prefix
(not calc-is-keypad-press)
(if (boundp 'overriding-terminal-local-map)
(setq overriding-terminal-local-map calc-fancy-prefix-map)
(let ((event (read-event)))
(if (eq (setq last-command-event event) ?\C-u)
(universal-argument)
(if (or (not (integerp last-command-event))
(and (>= last-command-event 0) (< last-command-event ? )
(not (memq last-command-event '(?\e)))))
(calc-wrapper)) ; clear flags if not a Calc command.
(setq last-command-event event)
(if (or (not (integerp last-command-event))
(eq last-command-event ?-))
(calc-unread-command)
(digit-argument n))))))))
2001-11-06 18:59:06 +00:00
(defun calc-fancy-prefix-other-key (arg)
(interactive "P")
(if (and
(not (eq last-command-event 'tab))
(not (eq last-command-event 'M-tab))
(or (not (integerp last-command-event))
(and (>= last-command-event 0) (< last-command-event ? )
(not (eq last-command-event meta-prefix-char)))))
(calc-wrapper)) ; clear flags if not a Calc command.
(setq prefix-arg arg)
(calc-unread-command)
(setq overriding-terminal-local-map nil))
2001-11-06 18:59:06 +00:00
(defun calc-invert-func ()
(save-excursion
(calc-select-buffer)
(setq calc-inverse-flag (not (calc-is-inverse))
calc-hyperbolic-flag (calc-is-hyperbolic)
current-prefix-arg nil)))
2001-11-06 18:59:06 +00:00
(defun calc-is-inverse ()
calc-inverse-flag)
2001-11-06 18:59:06 +00:00
(defun calc-hyperbolic (&optional n)
(interactive "P")
(let* ((inv-flag (if (or
(eq major-mode 'calc-keypad-mode)
(eq major-mode 'calc-trail-mode))
(with-current-buffer calc-main-buffer
calc-inverse-flag)
calc-inverse-flag))
(opt-flag (if (or
(eq major-mode 'calc-keypad-mode)
(eq major-mode 'calc-trail-mode))
(with-current-buffer calc-main-buffer
calc-option-flag)
calc-option-flag))
(msg
(cond
((and opt-flag inv-flag) "Option Inverse Hyperbolic...")
(opt-flag "Option Hyperbolic...")
(inv-flag "Inverse Hyperbolic...")
(t "Hyperbolic..."))))
(calc-fancy-prefix 'calc-hyperbolic-flag msg n)))
2001-11-06 18:59:06 +00:00
(defun calc-hyperbolic-func ()
(save-excursion
(calc-select-buffer)
(setq calc-inverse-flag (calc-is-inverse)
calc-hyperbolic-flag (not (calc-is-hyperbolic))
current-prefix-arg nil)))
2001-11-06 18:59:06 +00:00
(defun calc-is-hyperbolic ()
calc-hyperbolic-flag)
2001-11-06 18:59:06 +00:00
(defun calc-option (&optional n)
(interactive "P")
(let* ((inv-flag (if (or
(eq major-mode 'calc-keypad-mode)
(eq major-mode 'calc-trail-mode))
(with-current-buffer calc-main-buffer
calc-inverse-flag)
calc-inverse-flag))
(hyp-flag (if (or
(eq major-mode 'calc-keypad-mode)
(eq major-mode 'calc-trail-mode))
(with-current-buffer calc-main-buffer
calc-hyperbolic-flag)
calc-hyperbolic-flag))
(msg
(cond
((and hyp-flag inv-flag) "Option Inverse Hyperbolic...")
(hyp-flag "Option Hyperbolic...")
(inv-flag "Option Inverse...")
(t "Option..."))))
(calc-fancy-prefix 'calc-option-flag msg n)))
(defun calc-is-option ()
calc-option-flag)
2001-11-06 18:59:06 +00:00
(defun calc-keep-args (&optional n)
(interactive "P")
(calc-fancy-prefix 'calc-keep-args-flag "Keep args..." n))
2001-11-06 18:59:06 +00:00
(defun calc-change-mode (var value &optional refresh option)
(if option
(setq value (if value
(> (prefix-numeric-value value) 0)
(not (symbol-value var)))))
(or (consp var) (setq var (list var) value (list value)))
(if calc-inverse-flag
(let ((old nil))
(or refresh (error "Not a display-mode command"))
(calc-check-stack 1)
(unwind-protect
(let ((v var))
(while v
(setq old (cons (symbol-value (car v)) old))
(set (car v) (car value))
(setq v (cdr v)
value (cdr value)))
(calc-refresh-top 1)
(calc-refresh-evaltos)
(symbol-value (car var)))
(let ((v var))
(setq old (nreverse old))
(while v
(set (car v) (car old))
(setq v (cdr v)
old (cdr old)))
(if (eq (car var) 'calc-language)
(calc-set-language calc-language calc-language-option t)))))
(let ((chg nil)
(v var))
(while v
(or (equal (symbol-value (car v)) (car value))
(progn
(set (car v) (car value))
(if (eq (car v) 'calc-float-format)
(setq calc-full-float-format
(list (if (eq (car (car value)) 'fix)
'float
(car (car value)))
0)))
(setq chg t)))
(setq v (cdr v)
value (cdr value)))
(if chg
(progn
(or (and refresh (calc-do-refresh))
(calc-refresh-evaltos))
(and (eq calc-mode-save-mode 'save)
(not (equal var '(calc-mode-save-mode)))
(calc-save-modes))))
2001-11-06 18:59:06 +00:00
(if calc-embedded-info (calc-embedded-modes-change var))
(calc-set-mode-line)
(symbol-value (car var)))))
2001-11-06 18:59:06 +00:00
(defun calc-toggle-banner ()
"Toggle display of the friendly greeting calc normally shows above the stack."
(interactive)
(setq calc-show-banner (not calc-show-banner))
(calc-refresh))
2001-11-06 18:59:06 +00:00
(defun calc-refresh-top (n)
(interactive "p")
(calc-wrapper
(cond ((< n 0)
(setq n (- n))
(let ((entry (calc-top n 'entry))
(calc-undo-list nil) (calc-redo-list nil))
(calc-pop-stack 1 n t)
(calc-push-list (list (car entry)) n (list (nth 2 entry)))))
((= n 0)
(calc-refresh))
(t
(let ((entries (calc-top-list n 1 'entry))
(calc-undo-list nil) (calc-redo-list nil))
(calc-pop-stack n 1 t)
2018-11-20 16:09:35 -05:00
(calc-push-list (mapcar #'car entries)
2001-11-06 18:59:06 +00:00
1
Don't quote lambdas with 'function' in calc/*.el * lisp/calc/calc-aent.el (calc-do-quick-calc) (calc-do-calc-eval, math-build-parse-table): * lisp/calc/calc-alg.el (math-polynomial-base): * lisp/calc/calc-alg.el (math-is-poly-rec): * lisp/calc/calc-arith.el (calcFunc-scf): * lisp/calc/calc-arith.el (math-ceiling, math-round): * lisp/calc/calc-arith.el (math-trunc-fancy, math-floor-fancy): * lisp/calc/calc-ext.el (calc-init-extensions, calc-reset) (calc-refresh-top, calc-z-prefix-help, calc-binary-op-fancy) (calc-unary-op-fancy): * lisp/calc/calc-forms.el (math-make-mod): * lisp/calc/calc-frac.el (calcFunc-frac): * lisp/calc/calc-funcs.el (calcFunc-euler): * lisp/calc/calc-help.el (calc-full-help): * lisp/calc/calc-lang.el (c, pascal, fortran, tex, latex, eqn) (yacas, maxima, giac, math, maple): * lisp/calc/calc-macs.el (calc-wrapper, calc-slow-wrapper): * lisp/calc/calc-map.el (calc-get-operator, calcFunc-mapeqr) (calcFunc-reducea, calcFunc-rreducea, calcFunc-reduced) (calcFunc-rreduced, calcFunc-outer): * lisp/calc/calc-misc.el (another-calc, calc-do-handle-whys): * lisp/calc/calc-mode.el (calc-save-modes): * lisp/calc/calc-mtx.el (math-col-matrix, math-mul-mat-vec): * lisp/calc/calc-poly.el (math-sort-terms, math-poly-div-list) (math-mul-list, math-sort-poly-base-list) (math-partial-fractions): * lisp/calc/calc-prog.el (calc-user-define-formula): * lisp/calc/calc-rewr.el (math-rewrite, math-compile-patterns) (math-compile-rewrites, math-parse-schedule) (math-rwcomp-pattern): * lisp/calc/calc-store.el (calc-var-name-map, calc-let) (calc-permanent-variable, calc-insert-variables): * lisp/calc/calc-stuff.el (calc-flush-caches, calcFunc-pclean) (calcFunc-pfrac): * lisp/calc/calc-units.el (math-build-units-table) (math-decompose-units): * lisp/calc/calc-vec.el (calcFunc-mrow, math-mat-col) (calcFunc-mcol, math-mat-less-col, math-mimic-ident): * lisp/calc/calc-yank.el (calc-edit): * lisp/calc/calc.el (calc-mode-var-list-restore-default-values) (calc-mode-var-list-restore-saved-values, calc-mode, calc-quit): * lisp/calc/calccomp.el (math-compose-expr) (math-compose-matrix, math-vector-to-string): Don't quote lambdas with 'function'.
2020-11-17 02:51:30 +01:00
(mapcar (lambda (x) (nth 2 x))
entries)))))))
2001-11-06 18:59:06 +00:00
(defvar calc-refreshing-evaltos nil)
(defvar calc-no-refresh-evaltos nil)
2001-11-06 18:59:06 +00:00
(defun calc-refresh-evaltos (&optional which-var)
(and calc-any-evaltos calc-auto-recompute (not calc-no-refresh-evaltos)
(let ((calc-refreshing-evaltos t)
(num (calc-stack-size))
(calc-undo-list nil) (calc-redo-list nil)
value new-val)
(while (> num 0)
(setq value (calc-top num 'entry))
(if (and (not (nth 2 value))
(setq value (car value))
(or (eq (car-safe value) 'calcFunc-evalto)
(and (eq (car-safe value) 'vec)
(eq (car-safe (nth 1 value)) 'calcFunc-evalto))))
(progn
(setq new-val (math-normalize value))
(or (equal new-val value)
(progn
(calc-push-list (list new-val) num)
(calc-pop-stack 1 (1+ num) t)))))
(setq num (1- num)))))
(and calc-embedded-active which-var
(calc-embedded-var-change which-var)))
2001-11-06 18:59:06 +00:00
(defun calc-push (&rest vals)
(calc-push-list vals))
2001-11-06 18:59:06 +00:00
(defun calc-pop-push (n &rest vals)
(calc-pop-push-list n vals))
2001-11-06 18:59:06 +00:00
(defun calc-pop-push-record (n prefix &rest vals)
(calc-pop-push-record-list n prefix vals))
2001-11-06 18:59:06 +00:00
(defun calc-evaluate (n)
(interactive "p")
(calc-slow-wrapper
(if (= n 0)
(setq n (calc-stack-size)))
(calc-with-default-simplification
(if (< n 0)
(calc-pop-push-record-list 1 "eval"
(math-evaluate-expr (calc-top (- n)))
(- n))
2018-11-20 16:09:35 -05:00
(calc-pop-push-record-list n "eval" (mapcar #'math-evaluate-expr
2001-11-06 18:59:06 +00:00
(calc-top-list n)))))
(calc-handle-whys)))
2001-11-06 18:59:06 +00:00
(defun calc-eval-num (n)
(interactive "P")
(calc-slow-wrapper
(let* ((nn (prefix-numeric-value n))
(calc-internal-prec (cond ((>= nn 3) nn)
((< nn 0) (max (+ calc-internal-prec nn)
3))
(t calc-internal-prec)))
(calc-symbolic-mode nil))
(calc-with-default-simplification
(calc-pop-push-record 1 "num" (math-evaluate-expr (calc-top 1)))))
(calc-handle-whys)))
2001-11-06 18:59:06 +00:00
(defvar calc-extended-command-history nil
"The history list for calc-execute-extended-command.")
2001-11-06 18:59:06 +00:00
(defun calc-execute-extended-command (n)
(interactive "P")
(let* ((prompt (concat (calc-num-prefix-name n) "M-x "))
(cmd (intern
(completing-read prompt obarray 'commandp t "calc-"
'calc-extended-command-history))))
2001-11-06 18:59:06 +00:00
(setq prefix-arg n)
(command-execute cmd)))
2001-11-06 18:59:06 +00:00
(defun calc-realign (&optional num)
(interactive "P")
(if (and num (eq major-mode 'calc-mode))
(progn
(calc-check-stack num)
(calc-cursor-stack-index num)
(and calc-line-numbering
(forward-char 4)))
(if (and calc-embedded-info
(eq (current-buffer) (aref calc-embedded-info 0)))
(progn
(goto-char (aref calc-embedded-info 2))
(if (with-current-buffer (aref calc-embedded-info 1)
calc-show-plain)
2001-11-06 18:59:06 +00:00
(forward-line 1)))
(calc-wrapper
(if (get-buffer-window (current-buffer))
(set-window-hscroll (get-buffer-window (current-buffer)) 0))))))
2001-11-06 18:59:06 +00:00
(defvar math-cache-list nil)
2001-11-06 18:59:06 +00:00
(defun calc-var-value (v)
(and (symbolp v)
(boundp v)
(symbol-value v)
(if (symbolp (symbol-value v))
(set v (funcall (symbol-value v)))
(if (stringp (symbol-value v))
(let ((val (math-read-expr (symbol-value v))))
(if (eq (car-safe val) 'error)
(error "Bad format in variable contents: %s" (nth 2 val))
(set v val)))
(symbol-value v)))))
2001-11-06 18:59:06 +00:00
;;; In the following table, ( OP LOPS ROPS ) means that if an OP
;;; term appears as the first argument to any LOPS term, or as the
;;; second argument to any ROPS term, then they should be treated
;;; as one large term for purposes of associative selection.
(defconst calc-assoc-ops '( ( + ( + - ) ( + ) )
( - ( + - ) ( + ) )
( * ( * ) ( * ) )
( / ( / ) ( ) )
( | ( | ) ( | ) )
2003-02-04 13:24:35 +00:00
( calcFunc-land ( calcFunc-land )
2001-11-06 18:59:06 +00:00
( calcFunc-land ) )
2003-02-04 13:24:35 +00:00
( calcFunc-lor ( calcFunc-lor )
2001-11-06 18:59:06 +00:00
( calcFunc-lor ) ) ))
(defvar var-CommuteRules 'calc-CommuteRules)
(defvar var-JumpRules 'calc-JumpRules)
(defvar var-DistribRules 'calc-DistribRules)
(defvar var-MergeRules 'calc-MergeRules)
(defvar var-NegateRules 'calc-NegateRules)
(defvar var-InvertRules 'calc-InvertRules)
(defconst calc-tweak-eqn-table '( ( calcFunc-eq calcFunc-eq calcFunc-neq )
( calcFunc-neq calcFunc-neq calcFunc-eq )
( calcFunc-lt calcFunc-gt calcFunc-geq )
( calcFunc-gt calcFunc-lt calcFunc-leq )
( calcFunc-leq calcFunc-geq calcFunc-gt )
( calcFunc-geq calcFunc-leq calcFunc-lt ) ))
(defun calc-float (arg)
(interactive "P")
(calc-slow-wrapper
(calc-unary-op "flt"
(if (calc-is-hyperbolic) 'calcFunc-float 'calcFunc-pfloat)
arg)))
2001-11-06 18:59:06 +00:00
(defvar calc-gnuplot-process nil)
(defvar calc-gnuplot-input)
(defvar calc-gnuplot-buffer)
2001-11-06 18:59:06 +00:00
(defun calc-gnuplot-alive ()
(and calc-gnuplot-process
calc-gnuplot-buffer
(buffer-name calc-gnuplot-buffer)
calc-gnuplot-input
(buffer-name calc-gnuplot-input)
(memq (process-status calc-gnuplot-process) '(run stop))))
2001-11-06 18:59:06 +00:00
(defun calc-load-everything ()
(interactive)
(require 'calc-aent)
(require 'calc-alg)
(require 'calc-arith)
(require 'calc-bin)
(require 'calc-comb)
(require 'calc-cplx)
(require 'calc-embed)
(require 'calc-fin)
(require 'calc-forms)
(require 'calc-frac)
(require 'calc-funcs)
(require 'calc-graph)
(require 'calc-help)
(require 'calc-incom)
(require 'calc-keypd)
(require 'calc-lang)
(require 'calc-macs)
(require 'calc-map)
(require 'calc-math)
(require 'calc-misc)
(require 'calc-mode)
(require 'calc-mtx)
(require 'calc-poly)
(require 'calc-prog)
(require 'calc-rewr)
(require 'calc-rules)
(require 'calc-sel)
(require 'calc-stat)
(require 'calc-store)
(require 'calc-stuff)
(require 'calc-trail)
(require 'calc-undo)
(require 'calc-units)
(require 'calc-vec)
(require 'calc-yank)
(require 'calcalg2)
(require 'calcalg3)
(require 'calccomp)
(require 'calcsel2)
2001-11-06 18:59:06 +00:00
(message "All parts of Calc are now loaded"))
2001-11-06 18:59:06 +00:00
;;; Vector commands.
(defun calc-concat (arg)
(interactive "P")
(calc-wrapper
(if (calc-is-inverse)
(if (calc-is-hyperbolic)
(calc-enter-result 2 "apnd" (list 'calcFunc-append
(calc-top 1) (calc-top 2)))
(calc-enter-result 2 "|" (list 'calcFunc-vconcat
(calc-top 1) (calc-top 2))))
(if (calc-is-hyperbolic)
(calc-binary-op "apnd" 'calcFunc-append arg '(vec))
(calc-binary-op "|" 'calcFunc-vconcat arg '(vec) nil '|)))))
2001-11-06 18:59:06 +00:00
(defun calc-append (arg)
(interactive "P")
(calc-hyperbolic-func)
(calc-concat arg))
2001-11-06 18:59:06 +00:00
(defconst calc-arg-values '( ( var ArgA var-ArgA ) ( var ArgB var-ArgB )
( var ArgC var-ArgC ) ( var ArgD var-ArgD )
( var ArgE var-ArgE ) ( var ArgF var-ArgF )
( var ArgG var-ArgG ) ( var ArgH var-ArgH )
( var ArgI var-ArgI ) ( var ArgJ var-ArgJ )
))
(defun calc-invent-args (n)
(nreverse (nthcdr (- (length calc-arg-values) n) (reverse calc-arg-values))))
2001-11-06 18:59:06 +00:00
;;; User menu.
(defun calc-user-key-map ()
(let ((res (cdr (lookup-key calc-mode-map "z"))))
(if (eq (car (car res)) 27)
(cdr res)
res)))
2001-11-06 18:59:06 +00:00
(defvar calc-z-prefix-buf nil)
(defvar calc-z-prefix-msgs nil)
2001-11-06 18:59:06 +00:00
(defun calc-z-prefix-help ()
(interactive)
(let* ((calc-z-prefix-msgs nil)
(calc-z-prefix-buf "")
2001-11-06 18:59:06 +00:00
(kmap (sort (copy-sequence (calc-user-key-map))
Don't quote lambdas with 'function' in calc/*.el * lisp/calc/calc-aent.el (calc-do-quick-calc) (calc-do-calc-eval, math-build-parse-table): * lisp/calc/calc-alg.el (math-polynomial-base): * lisp/calc/calc-alg.el (math-is-poly-rec): * lisp/calc/calc-arith.el (calcFunc-scf): * lisp/calc/calc-arith.el (math-ceiling, math-round): * lisp/calc/calc-arith.el (math-trunc-fancy, math-floor-fancy): * lisp/calc/calc-ext.el (calc-init-extensions, calc-reset) (calc-refresh-top, calc-z-prefix-help, calc-binary-op-fancy) (calc-unary-op-fancy): * lisp/calc/calc-forms.el (math-make-mod): * lisp/calc/calc-frac.el (calcFunc-frac): * lisp/calc/calc-funcs.el (calcFunc-euler): * lisp/calc/calc-help.el (calc-full-help): * lisp/calc/calc-lang.el (c, pascal, fortran, tex, latex, eqn) (yacas, maxima, giac, math, maple): * lisp/calc/calc-macs.el (calc-wrapper, calc-slow-wrapper): * lisp/calc/calc-map.el (calc-get-operator, calcFunc-mapeqr) (calcFunc-reducea, calcFunc-rreducea, calcFunc-reduced) (calcFunc-rreduced, calcFunc-outer): * lisp/calc/calc-misc.el (another-calc, calc-do-handle-whys): * lisp/calc/calc-mode.el (calc-save-modes): * lisp/calc/calc-mtx.el (math-col-matrix, math-mul-mat-vec): * lisp/calc/calc-poly.el (math-sort-terms, math-poly-div-list) (math-mul-list, math-sort-poly-base-list) (math-partial-fractions): * lisp/calc/calc-prog.el (calc-user-define-formula): * lisp/calc/calc-rewr.el (math-rewrite, math-compile-patterns) (math-compile-rewrites, math-parse-schedule) (math-rwcomp-pattern): * lisp/calc/calc-store.el (calc-var-name-map, calc-let) (calc-permanent-variable, calc-insert-variables): * lisp/calc/calc-stuff.el (calc-flush-caches, calcFunc-pclean) (calcFunc-pfrac): * lisp/calc/calc-units.el (math-build-units-table) (math-decompose-units): * lisp/calc/calc-vec.el (calcFunc-mrow, math-mat-col) (calcFunc-mcol, math-mat-less-col, math-mimic-ident): * lisp/calc/calc-yank.el (calc-edit): * lisp/calc/calc.el (calc-mode-var-list-restore-default-values) (calc-mode-var-list-restore-saved-values, calc-mode, calc-quit): * lisp/calc/calccomp.el (math-compose-expr) (math-compose-matrix, math-vector-to-string): Don't quote lambdas with 'function'.
2020-11-17 02:51:30 +01:00
(lambda (x y) (< (car x) (car y)))))
2018-11-20 16:09:35 -05:00
(flags (apply #'logior
Don't quote lambdas with 'function' in calc/*.el * lisp/calc/calc-aent.el (calc-do-quick-calc) (calc-do-calc-eval, math-build-parse-table): * lisp/calc/calc-alg.el (math-polynomial-base): * lisp/calc/calc-alg.el (math-is-poly-rec): * lisp/calc/calc-arith.el (calcFunc-scf): * lisp/calc/calc-arith.el (math-ceiling, math-round): * lisp/calc/calc-arith.el (math-trunc-fancy, math-floor-fancy): * lisp/calc/calc-ext.el (calc-init-extensions, calc-reset) (calc-refresh-top, calc-z-prefix-help, calc-binary-op-fancy) (calc-unary-op-fancy): * lisp/calc/calc-forms.el (math-make-mod): * lisp/calc/calc-frac.el (calcFunc-frac): * lisp/calc/calc-funcs.el (calcFunc-euler): * lisp/calc/calc-help.el (calc-full-help): * lisp/calc/calc-lang.el (c, pascal, fortran, tex, latex, eqn) (yacas, maxima, giac, math, maple): * lisp/calc/calc-macs.el (calc-wrapper, calc-slow-wrapper): * lisp/calc/calc-map.el (calc-get-operator, calcFunc-mapeqr) (calcFunc-reducea, calcFunc-rreducea, calcFunc-reduced) (calcFunc-rreduced, calcFunc-outer): * lisp/calc/calc-misc.el (another-calc, calc-do-handle-whys): * lisp/calc/calc-mode.el (calc-save-modes): * lisp/calc/calc-mtx.el (math-col-matrix, math-mul-mat-vec): * lisp/calc/calc-poly.el (math-sort-terms, math-poly-div-list) (math-mul-list, math-sort-poly-base-list) (math-partial-fractions): * lisp/calc/calc-prog.el (calc-user-define-formula): * lisp/calc/calc-rewr.el (math-rewrite, math-compile-patterns) (math-compile-rewrites, math-parse-schedule) (math-rwcomp-pattern): * lisp/calc/calc-store.el (calc-var-name-map, calc-let) (calc-permanent-variable, calc-insert-variables): * lisp/calc/calc-stuff.el (calc-flush-caches, calcFunc-pclean) (calcFunc-pfrac): * lisp/calc/calc-units.el (math-build-units-table) (math-decompose-units): * lisp/calc/calc-vec.el (calcFunc-mrow, math-mat-col) (calcFunc-mcol, math-mat-less-col, math-mimic-ident): * lisp/calc/calc-yank.el (calc-edit): * lisp/calc/calc.el (calc-mode-var-list-restore-default-values) (calc-mode-var-list-restore-saved-values, calc-mode, calc-quit): * lisp/calc/calccomp.el (math-compose-expr) (math-compose-matrix, math-vector-to-string): Don't quote lambdas with 'function'.
2020-11-17 02:51:30 +01:00
(mapcar (lambda (k)
(calc-user-function-classify (car k)))
2001-11-06 18:59:06 +00:00
kmap))))
(if (= (logand flags 8) 0)
(calc-user-function-list kmap 7)
(calc-user-function-list kmap 1)
(setq calc-z-prefix-msgs (cons calc-z-prefix-buf calc-z-prefix-msgs)
calc-z-prefix-buf "")
2001-11-06 18:59:06 +00:00
(calc-user-function-list kmap 6))
(if (/= flags 0)
(setq calc-z-prefix-msgs (cons calc-z-prefix-buf calc-z-prefix-msgs)))
(calc-do-prefix-help (nreverse calc-z-prefix-msgs) "user" ?z)))
2001-11-06 18:59:06 +00:00
(defun calc-user-function-classify (key)
(cond ((/= key (downcase key)) ; upper-case
(if (assq (downcase key) (calc-user-key-map)) 9 1))
((/= key (upcase key)) 2) ; lower-case
((= key ??) 0)
(t 4))) ; other
2001-11-06 18:59:06 +00:00
(defun calc-user-function-list (map flags)
(and map
(let* ((key (car (car map)))
(kind (calc-user-function-classify key))
(func (cdr (car map))))
(if (or (= (logand kind flags) 0)
(not (symbolp func)))
()
(let* ((name (symbol-name func))
(name (if (string-match "\\`calc-" name)
(substring name 5) name))
(pos (string-match (char-to-string key) name))
(desc
(if (symbolp func)
(if (= (logand kind 3) 0)
Go back to grave quoting in source-code docstrings etc. This reverts almost all my recent changes to use curved quotes in docstrings and/or strings used for error diagnostics. There are a few exceptions, e.g., Bahá’í proper names. * admin/unidata/unidata-gen.el (unidata-gen-table): * lisp/abbrev.el (expand-region-abbrevs): * lisp/align.el (align-region): * lisp/allout.el (allout-mode, allout-solicit-alternate-bullet) (outlineify-sticky): * lisp/apropos.el (apropos-library): * lisp/bookmark.el (bookmark-default-annotation-text): * lisp/button.el (button-category-symbol, button-put) (make-text-button): * lisp/calc/calc-aent.el (math-read-if, math-read-factor): * lisp/calc/calc-embed.el (calc-do-embedded): * lisp/calc/calc-ext.el (calc-user-function-list): * lisp/calc/calc-graph.el (calc-graph-show-dumb): * lisp/calc/calc-help.el (calc-describe-key) (calc-describe-thing, calc-full-help): * lisp/calc/calc-lang.el (calc-c-language) (math-parse-fortran-vector-end, math-parse-tex-sum) (math-parse-eqn-matrix, math-parse-eqn-prime) (calc-yacas-language, calc-maxima-language, calc-giac-language) (math-read-giac-subscr, math-read-math-subscr) (math-read-big-rec, math-read-big-balance): * lisp/calc/calc-misc.el (calc-help, report-calc-bug): * lisp/calc/calc-mode.el (calc-auto-why, calc-save-modes) (calc-auto-recompute): * lisp/calc/calc-prog.el (calc-fix-token-name) (calc-read-parse-table-part, calc-user-define-invocation) (math-do-arg-check): * lisp/calc/calc-store.el (calc-edit-variable): * lisp/calc/calc-units.el (math-build-units-table-buffer): * lisp/calc/calc-vec.el (math-read-brackets): * lisp/calc/calc-yank.el (calc-edit-mode): * lisp/calc/calc.el (calc, calc-do, calc-user-invocation): * lisp/calendar/appt.el (appt-display-message): * lisp/calendar/diary-lib.el (diary-check-diary-file) (diary-mail-entries, diary-from-outlook): * lisp/calendar/icalendar.el (icalendar-export-region) (icalendar--convert-float-to-ical) (icalendar--convert-date-to-ical) (icalendar--convert-ical-to-diary) (icalendar--convert-recurring-to-diary) (icalendar--add-diary-entry): * lisp/calendar/time-date.el (format-seconds): * lisp/calendar/timeclock.el (timeclock-mode-line-display) (timeclock-make-hours-explicit, timeclock-log-data): * lisp/calendar/todo-mode.el (todo-prefix, todo-delete-category) (todo-item-mark, todo-check-format) (todo-insert-item--next-param, todo-edit-item--next-key) (todo-mode): * lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules): * lisp/cedet/mode-local.el (describe-mode-local-overload) (mode-local-print-binding, mode-local-describe-bindings-2): * lisp/cedet/semantic/complete.el (semantic-displayor-show-request): * lisp/cedet/srecode/srt-mode.el (srecode-macro-help): * lisp/cus-start.el (standard): * lisp/cus-theme.el (describe-theme-1): * lisp/custom.el (custom-add-dependencies, custom-check-theme) (custom--sort-vars-1, load-theme): * lisp/descr-text.el (describe-text-properties-1, describe-char): * lisp/dired-x.el (dired-do-run-mail): * lisp/dired.el (dired-log): * lisp/emacs-lisp/advice.el (ad-read-advised-function) (ad-read-advice-class, ad-read-advice-name, ad-enable-advice) (ad-disable-advice, ad-remove-advice, ad-set-argument) (ad-set-arguments, ad--defalias-fset, ad-activate) (ad-deactivate): * lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand) (byte-compile-unfold-lambda, byte-optimize-form-code-walker) (byte-optimize-while, byte-optimize-apply): * lisp/emacs-lisp/byte-run.el (defun, defsubst): * lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode) (byte-compile-log-file, byte-compile-format-warn) (byte-compile-nogroup-warn, byte-compile-arglist-warn) (byte-compile-cl-warn) (byte-compile-warn-about-unresolved-functions) (byte-compile-file, byte-compile--declare-var) (byte-compile-file-form-defmumble, byte-compile-form) (byte-compile-normal-call, byte-compile-check-variable) (byte-compile-variable-ref, byte-compile-variable-set) (byte-compile-subr-wrong-args, byte-compile-setq-default) (byte-compile-negation-optimizer) (byte-compile-condition-case--old) (byte-compile-condition-case--new, byte-compile-save-excursion) (byte-compile-defvar, byte-compile-autoload) (byte-compile-lambda-form) (byte-compile-make-variable-buffer-local, display-call-tree) (batch-byte-compile): * lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use): * lisp/emacs-lisp/chart.el (chart-space-usage): * lisp/emacs-lisp/check-declare.el (check-declare-scan) (check-declare-warn, check-declare-file) (check-declare-directory): * lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine) (checkdoc-message-text-engine): * lisp/emacs-lisp/cl-extra.el (cl-parse-integer) (cl--describe-class): * lisp/emacs-lisp/cl-generic.el (cl-defgeneric) (cl--generic-describe, cl-generic-generalizers): * lisp/emacs-lisp/cl-macs.el (cl--parse-loop-clause, cl-tagbody) (cl-symbol-macrolet): * lisp/emacs-lisp/cl.el (cl-unload-function, flet): * lisp/emacs-lisp/copyright.el (copyright) (copyright-update-directory): * lisp/emacs-lisp/edebug.el (edebug-read-list): * lisp/emacs-lisp/eieio-base.el (eieio-persistent-read): * lisp/emacs-lisp/eieio-core.el (eieio--slot-override) (eieio-oref): * lisp/emacs-lisp/eieio-opt.el (eieio-help-constructor): * lisp/emacs-lisp/eieio-speedbar.el: (eieio-speedbar-child-make-tag-lines) (eieio-speedbar-child-description): * lisp/emacs-lisp/eieio.el (defclass, change-class): * lisp/emacs-lisp/elint.el (elint-file, elint-get-top-forms) (elint-init-form, elint-check-defalias-form) (elint-check-let-form): * lisp/emacs-lisp/ert.el (ert-get-test, ert-results-mode-menu) (ert-results-pop-to-backtrace-for-test-at-point) (ert-results-pop-to-messages-for-test-at-point) (ert-results-pop-to-should-forms-for-test-at-point) (ert-describe-test): * lisp/emacs-lisp/find-func.el (find-function-search-for-symbol) (find-function-library): * lisp/emacs-lisp/generator.el (iter-yield): * lisp/emacs-lisp/gv.el (gv-define-simple-setter): * lisp/emacs-lisp/lisp-mnt.el (lm-verify): * lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning): * lisp/emacs-lisp/map-ynp.el (map-y-or-n-p): * lisp/emacs-lisp/nadvice.el (advice--make-docstring) (advice--make, define-advice): * lisp/emacs-lisp/package-x.el (package-upload-file): * lisp/emacs-lisp/package.el (package-version-join) (package-disabled-p, package-activate-1, package-activate) (package--download-one-archive) (package--download-and-read-archives) (package-compute-transaction, package-install-from-archive) (package-install, package-install-selected-packages) (package-delete, package-autoremove, describe-package-1) (package-install-button-action, package-delete-button-action) (package-menu-hide-package, package-menu--list-to-prompt) (package-menu--perform-transaction) (package-menu--find-and-notify-upgrades): * lisp/emacs-lisp/pcase.el (pcase-exhaustive, pcase--u1): * lisp/emacs-lisp/re-builder.el (reb-enter-subexp-mode): * lisp/emacs-lisp/ring.el (ring-previous, ring-next): * lisp/emacs-lisp/rx.el (rx-check, rx-anything) (rx-check-any-string, rx-check-any, rx-check-not, rx-=) (rx-repeat, rx-check-backref, rx-syntax, rx-check-category) (rx-form): * lisp/emacs-lisp/smie.el (smie-config-save): * lisp/emacs-lisp/subr-x.el (internal--check-binding): * lisp/emacs-lisp/tabulated-list.el (tabulated-list-put-tag): * lisp/emacs-lisp/testcover.el (testcover-1value): * lisp/emacs-lisp/timer.el (timer-event-handler): * lisp/emulation/viper-cmd.el (viper-toggle-parse-sexp-ignore-comments) (viper-toggle-search-style, viper-kill-buffer) (viper-brac-function): * lisp/emulation/viper-macs.el (viper-record-kbd-macro): * lisp/env.el (setenv): * lisp/erc/erc-button.el (erc-nick-popup): * lisp/erc/erc.el (erc-cmd-LOAD, erc-handle-login, english): * lisp/eshell/em-dirs.el (eshell/cd): * lisp/eshell/em-glob.el (eshell-glob-regexp) (eshell-glob-entries): * lisp/eshell/em-pred.el (eshell-parse-modifiers): * lisp/eshell/esh-opt.el (eshell-show-usage): * lisp/facemenu.el (facemenu-add-new-face) (facemenu-add-new-color): * lisp/faces.el (read-face-name, read-face-font, describe-face) (x-resolve-font-name): * lisp/files-x.el (modify-file-local-variable): * lisp/files.el (locate-user-emacs-file, find-alternate-file) (set-auto-mode, hack-one-local-variable--obsolete) (dir-locals-set-directory-class, write-file, basic-save-buffer) (delete-directory, copy-directory, recover-session) (recover-session-finish, insert-directory) (file-modes-char-to-who, file-modes-symbolic-to-number) (move-file-to-trash): * lisp/filesets.el (filesets-add-buffer, filesets-remove-buffer): * lisp/find-cmd.el (find-generic, find-to-string): * lisp/finder.el (finder-commentary): * lisp/font-lock.el (font-lock-fontify-buffer): * lisp/format.el (format-write-file, format-find-file) (format-insert-file): * lisp/frame.el (get-device-terminal, select-frame-by-name): * lisp/fringe.el (fringe--check-style): * lisp/gnus/nnmairix.el (nnmairix-widget-create-query): * lisp/help-fns.el (help-fns--key-bindings) (help-fns--compiler-macro, help-fns--parent-mode) (help-fns--obsolete, help-fns--interactive-only) (describe-function-1, describe-variable): * lisp/help.el (describe-mode) (describe-minor-mode-from-indicator): * lisp/image.el (image-type): * lisp/international/ccl.el (ccl-dump): * lisp/international/fontset.el (x-must-resolve-font-name): * lisp/international/mule-cmds.el (prefer-coding-system) (select-safe-coding-system-interactively) (select-safe-coding-system, activate-input-method) (toggle-input-method, describe-current-input-method) (describe-language-environment): * lisp/international/mule-conf.el (code-offset): * lisp/international/mule-diag.el (describe-character-set) (list-input-methods-1): * lisp/mail/feedmail.el (feedmail-run-the-queue): * lisp/mouse.el (minor-mode-menu-from-indicator): * lisp/mpc.el (mpc-playlist-rename): * lisp/msb.el (msb--choose-menu): * lisp/net/ange-ftp.el (ange-ftp-shell-command): * lisp/net/imap.el (imap-interactive-login): * lisp/net/mairix.el (mairix-widget-create-query): * lisp/net/newst-backend.el (newsticker--sentinel-work): * lisp/net/newst-treeview.el (newsticker--treeview-load): * lisp/net/rlogin.el (rlogin): * lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer): * lisp/obsolete/otodo-mode.el (todo-more-important-p): * lisp/obsolete/pgg-gpg.el (pgg-gpg-process-region): * lisp/obsolete/pgg-pgp.el (pgg-pgp-process-region): * lisp/obsolete/pgg-pgp5.el (pgg-pgp5-process-region): * lisp/org/ob-core.el (org-babel-goto-named-src-block) (org-babel-goto-named-result): * lisp/org/ob-fortran.el (org-babel-fortran-ensure-main-wrap): * lisp/org/ob-ref.el (org-babel-ref-resolve): * lisp/org/org-agenda.el (org-agenda-prepare): * lisp/org/org-clock.el (org-clock-notify-once-if-expired) (org-clock-resolve): * lisp/org/org-ctags.el (org-ctags-ask-rebuild-tags-file-then-find-tag): * lisp/org/org-feed.el (org-feed-parse-atom-entry): * lisp/org/org-habit.el (org-habit-parse-todo): * lisp/org/org-mouse.el (org-mouse-popup-global-menu) (org-mouse-context-menu): * lisp/org/org-table.el (org-table-edit-formulas): * lisp/org/ox.el (org-export-async-start): * lisp/proced.el (proced-log): * lisp/progmodes/ada-mode.el (ada-get-indent-case) (ada-check-matching-start, ada-goto-matching-start): * lisp/progmodes/ada-prj.el (ada-prj-display-page): * lisp/progmodes/ada-xref.el (ada-find-executable): * lisp/progmodes/ebrowse.el (ebrowse-tags-apropos): * lisp/progmodes/etags.el (etags-tags-apropos-additional): * lisp/progmodes/flymake.el (flymake-parse-err-lines) (flymake-start-syntax-check-process): * lisp/progmodes/python.el (python-shell-get-process-or-error) (python-define-auxiliary-skeleton): * lisp/progmodes/sql.el (sql-comint): * lisp/progmodes/verilog-mode.el (verilog-load-file-at-point): * lisp/progmodes/vhdl-mode.el (vhdl-widget-directory-validate): * lisp/recentf.el (recentf-open-files): * lisp/replace.el (query-replace-read-from) (occur-after-change-function, occur-1): * lisp/scroll-bar.el (scroll-bar-columns): * lisp/server.el (server-get-auth-key): * lisp/simple.el (execute-extended-command) (undo-outer-limit-truncate, list-processes--refresh) (compose-mail, set-variable, choose-completion-string) (define-alternatives): * lisp/startup.el (site-run-file, tty-handle-args, command-line) (command-line-1): * lisp/subr.el (noreturn, define-error, add-to-list) (read-char-choice, version-to-list): * lisp/term/common-win.el (x-handle-xrm-switch) (x-handle-name-switch, x-handle-args): * lisp/term/x-win.el (x-handle-parent-id, x-handle-smid): * lisp/textmodes/reftex-ref.el (reftex-label): * lisp/textmodes/reftex-toc.el (reftex-toc-rename-label): * lisp/textmodes/two-column.el (2C-split): * lisp/tutorial.el (tutorial--describe-nonstandard-key) (tutorial--find-changed-keys): * lisp/type-break.el (type-break-noninteractive-query): * lisp/wdired.el (wdired-do-renames, wdired-do-symlink-changes) (wdired-do-perm-changes): * lisp/whitespace.el (whitespace-report-region): Prefer grave quoting in source-code strings used to generate help and diagnostics. * lisp/faces.el (face-documentation): No need to convert quotes, since the result is a docstring. * lisp/info.el (Info-virtual-index-find-node) (Info-virtual-index, info-apropos): Simplify by generating only curved quotes, since info files are typically that ways nowadays anyway. * lisp/international/mule-diag.el (list-input-methods): Don’t assume text quoting style is curved. * lisp/org/org-bibtex.el (org-bibtex-fields): Revert my recent changes, going back to the old quoting style.
2015-09-07 08:41:44 -07:00
(format-message "`%c' = %s" key name)
2001-11-06 18:59:06 +00:00
(if pos
(format "%s%c%s"
(downcase (substring name 0 pos))
(upcase key)
(downcase (substring name (1+ pos))))
(format "%c = %s"
(upcase key)
(downcase name))))
(char-to-string (upcase key)))))
(if (= (length calc-z-prefix-buf) 0)
(setq calc-z-prefix-buf (concat (if (= flags 1) "SHIFT + " "")
2001-11-06 18:59:06 +00:00
desc))
(if (> (+ (length calc-z-prefix-buf) (length desc)) 58)
(setq calc-z-prefix-msgs
(cons calc-z-prefix-buf calc-z-prefix-msgs)
calc-z-prefix-buf (concat (if (= flags 1) "SHIFT + " "")
2001-11-06 18:59:06 +00:00
desc))
(setq calc-z-prefix-buf (concat calc-z-prefix-buf ", " desc))))))
(calc-user-function-list (cdr map) flags))))
2001-11-06 18:59:06 +00:00
(defun calc-shift-Z-prefix-help ()
(interactive)
(calc-do-prefix-help
'("Define, Undefine, Formula, Kbd-macro, Edit, Get-defn"
"Composition, Syntax; Invocation; Permanent; Timing"
"kbd-macros: [ (if), : (else), | (else-if), ] (end-if)"
"kbd-macros: < > (repeat), ( ) (for), { } (loop)"
"kbd-macros: / (break)"
"kbd-macros: \\=` (save), \\=' (restore)")
"user" ?Z))
2001-11-06 18:59:06 +00:00
;;;; Caches.
(defmacro math-defcache (name init form)
2018-11-20 16:09:35 -05:00
(declare (indent 2) (debug (symbolp sexp form)))
2001-11-06 18:59:06 +00:00
(let ((cache-prec (intern (concat (symbol-name name) "-cache-prec")))
(cache-val (intern (concat (symbol-name name) "-cache")))
(last-prec (intern (concat (symbol-name name) "-last-prec")))
(last-val (intern (concat (symbol-name name) "-last"))))
`(progn
2018-11-20 16:09:35 -05:00
;; (defvar ,cache-prec ,(if init (math-numdigs (nth 1 init)) -100))
(defvar ,cache-prec (cond
((consp ,init) (math-numdigs (nth 1 ,init)))
(,init
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(nth 1 (math-numdigs (eval ,init t))))
(t
-100)))
(defvar ,cache-val (cond ((consp ,init) ,init)
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(,init (eval ,init t))
(t ,init)))
(defvar ,last-prec -100)
(defvar ,last-val nil)
(setq math-cache-list
(cons ',cache-prec
(cons ',last-prec
math-cache-list)))
(defun ,name ()
(or (= ,last-prec calc-internal-prec)
(setq ,last-val
(math-normalize
(progn (or (>= ,cache-prec calc-internal-prec)
(setq ,cache-val
(let ((calc-internal-prec
(+ calc-internal-prec 4)))
,form)
,cache-prec (+ calc-internal-prec 2)))
,cache-val))
,last-prec calc-internal-prec))
,last-val))))
2001-11-06 18:59:06 +00:00
;;; Betcha didn't know that pi = 16 atan(1/5) - 4 atan(1/239). [F] [Public]
(defconst math-approx-pi
(math-read-number-simple "3.141592653589793238463")
"An approximation for pi.")
(math-defcache math-pi math-approx-pi
2001-11-06 18:59:06 +00:00
(math-add-float (math-mul-float '(float 16 0)
(math-arctan-raw '(float 2 -1)))
(math-mul-float '(float -4 0)
(math-arctan-raw
(math-float '(frac 1 239))))))
(math-defcache math-two-pi nil
(math-mul-float (math-pi) '(float 2 0)))
(math-defcache math-pi-over-2 nil
(math-mul-float (math-pi) '(float 5 -1)))
(math-defcache math-pi-over-4 nil
(math-mul-float (math-pi) '(float 25 -2)))
(math-defcache math-pi-over-180 nil
(math-div-float (math-pi) '(float 18 1)))
(math-defcache math-sqrt-pi nil
(math-sqrt-float (math-pi)))
(math-defcache math-sqrt-2 nil
(math-sqrt-float '(float 2 0)))
(math-defcache math-sqrt-12 nil
(math-sqrt-float '(float 12 0)))
(math-defcache math-sqrt-two-pi nil
(math-sqrt-float (math-two-pi)))
(defconst math-approx-sqrt-e
(math-read-number-simple "1.648721270700128146849")
"An approximation for sqrt(3).")
(math-defcache math-sqrt-e math-approx-sqrt-e
2001-11-06 18:59:06 +00:00
(math-add-float '(float 1 0) (math-exp-minus-1-raw '(float 5 -1))))
(math-defcache math-e nil
(math-pow (math-sqrt-e) 2))
(math-defcache math-phi nil
(math-mul-float (math-add-float (math-sqrt-raw '(float 5 0)) '(float 1 0))
'(float 5 -1)))
(defconst math-approx-gamma-const
(math-read-number-simple
"0.5772156649015328606065120900824024310421593359399235988057672348848677267776646709369470632917467495")
"An approximation for gamma.")
(math-defcache math-gamma-const nil
math-approx-gamma-const)
2001-11-06 18:59:06 +00:00
(defun math-half-circle (symb)
(if (eq calc-angle-mode 'rad)
(if symb
'(var pi var-pi)
(math-pi))
180))
2001-11-06 18:59:06 +00:00
(defun math-full-circle (symb)
(math-mul 2 (math-half-circle symb)))
2001-11-06 18:59:06 +00:00
(defun math-quarter-circle (symb)
(math-div (math-half-circle symb) 2))
2001-11-06 18:59:06 +00:00
(defvar math-expand-formulas nil)
2001-11-06 18:59:06 +00:00
;;;; Miscellaneous math routines.
;;; True if A is an odd integer. [P R R] [Public]
(defun math-oddp (a)
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(and (integerp a) (cl-oddp a)))
2001-11-06 18:59:06 +00:00
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
;;; True if A is an integer. [P x] [Public]
(defalias 'math-integerp #'integerp)
2001-11-06 18:59:06 +00:00
;;; True if A is (numerically) a non-negative integer. [P N] [Public]
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(defalias 'math-natnump #'natnump)
2001-11-06 18:59:06 +00:00
;;; True if A is a rational (or integer). [P x] [Public]
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(defalias 'math-ratp #'Math-ratp)
2001-11-06 18:59:06 +00:00
;;; True if A is a real (or rational). [P x] [Public]
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(defalias 'math-realp #'Math-realp)
2001-11-06 18:59:06 +00:00
;;; True if A is a real or HMS form. [P x] [Public]
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(defalias 'math-anglep #'Math-anglep)
2001-11-06 18:59:06 +00:00
;;; True if A is a number of any kind. [P x] [Public]
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(defalias 'math-numberp #'Math-numberp)
2001-11-06 18:59:06 +00:00
;;; True if A is a complex number or angle. [P x] [Public]
(defalias 'math-scalarp #'Math-scalarp)
2001-11-06 18:59:06 +00:00
;;; True if A is a vector. [P x] [Public]
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(defalias 'math-vectorp #'Math-vectorp)
2001-11-06 18:59:06 +00:00
;;; True if A is any vector or scalar data object. [P x]
(defun math-objvecp (a) ; [Public]
(or (integerp a)
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(memq (car-safe a) '(frac float cplx polar
hms date sdev intv mod vec
;; FIXME: Math-objvecp does not include this one!
incomplete))))
2001-11-06 18:59:06 +00:00
;;; True if A is an object not composed of sub-formulas . [P x] [Public]
(defun math-primp (a)
(or (integerp a)
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(memq (car-safe a) '(frac float cplx polar
hms date mod var))))
2001-11-06 18:59:06 +00:00
;;; True if A is numerically (but not literally) an integer. [P x] [Public]
(defun math-messy-integerp (a)
(cond
((eq (car-safe a) 'float) (>= (nth 2 a) 0))
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
;; FIXME: Math-messy-integerp does not include this case!
((eq (car-safe a) 'frac) (Math-integerp (math-normalize a)))))
2001-11-06 18:59:06 +00:00
;;; True if A is numerically an integer. [P x] [Public]
(defun math-num-integerp (a)
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(or (integerp a)
(Math-messy-integerp a)))
2001-11-06 18:59:06 +00:00
;;; True if A is (numerically) a non-negative integer. [P N] [Public]
(defun math-num-natnump (a)
(or (natnump a)
(and (eq (car-safe a) 'float)
(Math-natnump (nth 1 a))
(>= (nth 2 a) 0))))
2001-11-06 18:59:06 +00:00
;;; True if A is an integer or will evaluate to an integer. [P x] [Public]
(defun math-provably-integerp (a)
(or (Math-integerp a)
(and (memq (car-safe a) '(calcFunc-trunc
calcFunc-round
calcFunc-rounde
calcFunc-roundu
calcFunc-floor
calcFunc-ceil))
(= (length a) 2))))
2001-11-06 18:59:06 +00:00
;;; True if A is a real or will evaluate to a real. [P x] [Public]
(defun math-provably-realp (a)
(or (Math-realp a)
2007-11-27 04:53:27 +00:00
(math-provably-integerp a)
(memq (car-safe a) '(abs arg))))
2001-11-06 18:59:06 +00:00
;;; True if A is a non-real, complex number. [P x] [Public]
(defun math-complexp (a)
(memq (car-safe a) '(cplx polar)))
2001-11-06 18:59:06 +00:00
;;; True if A is a non-real, rectangular complex number. [P x] [Public]
(defun math-rect-complexp (a)
(eq (car-safe a) 'cplx))
2001-11-06 18:59:06 +00:00
;;; True if A is a non-real, polar complex number. [P x] [Public]
(defun math-polar-complexp (a)
(eq (car-safe a) 'polar))
2001-11-06 18:59:06 +00:00
;;; True if A is a matrix. [P x] [Public]
(defun math-matrixp (a)
(and (Math-vectorp a)
(Math-vectorp (nth 1 a))
(cdr (nth 1 a))
(let ((len (length (nth 1 a))))
(setq a (cdr a))
(while (and (setq a (cdr a))
(Math-vectorp (car a))
(= (length (car a)) len)))
(null a))))
2001-11-06 18:59:06 +00:00
(defun math-matrixp-step (a len) ; [P L]
(or (null a)
(and (Math-vectorp (car a))
(= (length (car a)) len)
(math-matrixp-step (cdr a) len))))
2001-11-06 18:59:06 +00:00
;;; True if A is a square matrix. [P V] [Public]
(defun math-square-matrixp (a)
(let ((dims (math-mat-dimens a)))
(and (cdr dims)
(= (car dims) (nth 1 dims)))))
2001-11-06 18:59:06 +00:00
;;; True if MAT is an identity matrix.
(defun math-identity-matrix-p (mat &optional mul)
(if (math-square-matrixp mat)
(let ((a (if mul
(nth 1 (nth 1 mat))
1))
(n (1- (length mat)))
(i 1))
(while (and (<= i n)
(math-ident-row-p (nth i mat) i a))
(setq i (1+ i)))
(if (> i n)
a
nil))))
(defun math-ident-row-p (row n &optional a)
(unless a
(setq a 1))
(and
(not (memq nil (mapcar
(lambda (x) (eq x 0))
(nthcdr (1+ n) row))))
(not (memq nil (mapcar
(lambda (x) (eq x 0))
(butlast
(cdr row)
(- (length row) n)))))
(eq (elt row n) a)))
2001-11-06 18:59:06 +00:00
;;; True if A is any scalar data object. [P x]
(defun math-objectp (a) ; [Public]
(or (integerp a)
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(memq (car-safe a) '(frac float cplx
polar hms date sdev intv mod))))
2001-11-06 18:59:06 +00:00
;;; Verify that A is an integer and return A in integer form. [I N; - x]
(defun math-check-integer (a) ; [Public]
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(cond ((integerp a) a)
2001-11-06 18:59:06 +00:00
((math-messy-integerp a)
(math-trunc a))
(t (math-reject-arg a 'integerp))))
2001-11-06 18:59:06 +00:00
;;; Verify that A is a small integer and return A in integer form. [S N; - x]
(defun math-check-fixnum (a &optional allow-inf) ; [Public]
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(cond ((fixnump a) a) ; for speed
2001-11-06 18:59:06 +00:00
((Math-num-integerp a)
(let ((a (math-trunc a)))
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(if (fixnump a)
2001-11-06 18:59:06 +00:00
a
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(math-reject-arg a 'fixnump))))
2001-11-06 18:59:06 +00:00
((and allow-inf (equal a '(var inf var-inf)))
Audit use of lsh and fix glitches I audited use of lsh in the Lisp source code, and fixed the glitches that I found. While I was at it, I replaced uses of lsh with ash when either will do. Replacement is OK when either argument is known to be nonnegative, or when only the low-order bits of the result matter, and is a (minor) win since ash is a bit more solid than lsh nowadays, and is a bit faster. * lisp/calc/calc-ext.el (math-check-fixnum): Prefer most-positive-fixnum to (lsh -1 -1). * lisp/vc/vc-hg.el (vc-hg-state-fast): When testing fixnum width, prefer (zerop (ash most-positive-fixnum -32)) to (zerop (lsh -1 32)) (Bug#32485#11). * lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode): Tighten sanity-check for bytecode overflow, by checking that the result of (ash pc -8) is nonnegative. Formerly this check was not needed since lsh was used and the number overflowed differently. * lisp/net/dns.el (dns-write): Fix some obvious sign typos in shift counts. Evidently this part of the code has never been exercised. * lisp/progmodes/hideif.el (hif-shiftleft, hif-shiftright): * lisp/term/common-win.el (x-setup-function-keys): Simplify. * admin/unidata/unidata-gen.el, admin/unidata/uvs.el: * doc/lispref/keymaps.texi, doc/lispref/syntax.texi: * doc/misc/calc.texi, doc/misc/cl.texi, etc/NEWS.19: * lisp/arc-mode.el, lisp/calc/calc-bin.el, lisp/calc/calc-comb.el: * lisp/calc/calc-ext.el, lisp/calc/calc-math.el: * lisp/cedet/semantic/wisent/comp.el, lisp/composite.el: * lisp/disp-table.el, lisp/dos-fns.el, lisp/edmacro.el: * lisp/emacs-lisp/bindat.el, lisp/emacs-lisp/byte-opt.el: * lisp/emacs-lisp/bytecomp.el, lisp/emacs-lisp/cl-extra.el: * lisp/erc/erc-dcc.el, lisp/facemenu.el, lisp/gnus/message.el: * lisp/gnus/nndoc.el, lisp/gnus/nnmaildir.el, lisp/image.el: * lisp/international/ccl.el, lisp/international/fontset.el: * lisp/international/mule-cmds.el, lisp/international/mule.el: * lisp/json.el, lisp/mail/binhex.el, lisp/mail/rmail.el: * lisp/mail/uudecode.el, lisp/md4.el, lisp/net/dns.el: * lisp/net/ntlm.el, lisp/net/sasl.el, lisp/net/socks.el: * lisp/net/tramp.el, lisp/obsolete/levents.el: * lisp/obsolete/pgg-parse.el, lisp/org/org.el: * lisp/org/ox-publish.el, lisp/progmodes/cc-defs.el: * lisp/progmodes/ebnf2ps.el, lisp/progmodes/hideif.el: * lisp/ps-bdf.el, lisp/ps-print.el, lisp/simple.el: * lisp/tar-mode.el, lisp/term/common-win.el: * lisp/term/tty-colors.el, lisp/term/xterm.el, lisp/vc/vc-git.el: * lisp/vc/vc-hg.el, lisp/x-dnd.el, test/src/data-tests.el: Prefer ash to lsh when either will do.
2018-08-21 13:44:03 -07:00
most-positive-fixnum)
2001-11-06 18:59:06 +00:00
((and allow-inf (equal a '(neg (var inf var-inf))))
Audit use of lsh and fix glitches I audited use of lsh in the Lisp source code, and fixed the glitches that I found. While I was at it, I replaced uses of lsh with ash when either will do. Replacement is OK when either argument is known to be nonnegative, or when only the low-order bits of the result matter, and is a (minor) win since ash is a bit more solid than lsh nowadays, and is a bit faster. * lisp/calc/calc-ext.el (math-check-fixnum): Prefer most-positive-fixnum to (lsh -1 -1). * lisp/vc/vc-hg.el (vc-hg-state-fast): When testing fixnum width, prefer (zerop (ash most-positive-fixnum -32)) to (zerop (lsh -1 32)) (Bug#32485#11). * lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode): Tighten sanity-check for bytecode overflow, by checking that the result of (ash pc -8) is nonnegative. Formerly this check was not needed since lsh was used and the number overflowed differently. * lisp/net/dns.el (dns-write): Fix some obvious sign typos in shift counts. Evidently this part of the code has never been exercised. * lisp/progmodes/hideif.el (hif-shiftleft, hif-shiftright): * lisp/term/common-win.el (x-setup-function-keys): Simplify. * admin/unidata/unidata-gen.el, admin/unidata/uvs.el: * doc/lispref/keymaps.texi, doc/lispref/syntax.texi: * doc/misc/calc.texi, doc/misc/cl.texi, etc/NEWS.19: * lisp/arc-mode.el, lisp/calc/calc-bin.el, lisp/calc/calc-comb.el: * lisp/calc/calc-ext.el, lisp/calc/calc-math.el: * lisp/cedet/semantic/wisent/comp.el, lisp/composite.el: * lisp/disp-table.el, lisp/dos-fns.el, lisp/edmacro.el: * lisp/emacs-lisp/bindat.el, lisp/emacs-lisp/byte-opt.el: * lisp/emacs-lisp/bytecomp.el, lisp/emacs-lisp/cl-extra.el: * lisp/erc/erc-dcc.el, lisp/facemenu.el, lisp/gnus/message.el: * lisp/gnus/nndoc.el, lisp/gnus/nnmaildir.el, lisp/image.el: * lisp/international/ccl.el, lisp/international/fontset.el: * lisp/international/mule-cmds.el, lisp/international/mule.el: * lisp/json.el, lisp/mail/binhex.el, lisp/mail/rmail.el: * lisp/mail/uudecode.el, lisp/md4.el, lisp/net/dns.el: * lisp/net/ntlm.el, lisp/net/sasl.el, lisp/net/socks.el: * lisp/net/tramp.el, lisp/obsolete/levents.el: * lisp/obsolete/pgg-parse.el, lisp/org/org.el: * lisp/org/ox-publish.el, lisp/progmodes/cc-defs.el: * lisp/progmodes/ebnf2ps.el, lisp/progmodes/hideif.el: * lisp/ps-bdf.el, lisp/ps-print.el, lisp/simple.el: * lisp/tar-mode.el, lisp/term/common-win.el: * lisp/term/tty-colors.el, lisp/term/xterm.el, lisp/vc/vc-git.el: * lisp/vc/vc-hg.el, lisp/x-dnd.el, test/src/data-tests.el: Prefer ash to lsh when either will do.
2018-08-21 13:44:03 -07:00
(- most-positive-fixnum))
(t (math-reject-arg a 'fixnump))))
2001-11-06 18:59:06 +00:00
;;; Verify that A is an integer >= 0 and return A in integer form. [I N; - x]
(defun math-check-natnum (a) ; [Public]
(cond ((natnump a) a)
((and (not (math-negp a))
(Math-num-integerp a))
(math-trunc a))
(t (math-reject-arg a 'natnump))))
2001-11-06 18:59:06 +00:00
;;; Verify that A is in floating-point form, or force it to be a float. [F N]
(defun math-check-float (a) ; [Public]
(cond ((eq (car-safe a) 'float) a)
((Math-vectorp a) (math-map-vec 'math-check-float a))
((Math-objectp a) (math-float a))
(t a)))
2001-11-06 18:59:06 +00:00
;;; Verify that A is a constant.
(defun math-check-const (a &optional exp-ok)
(if (or (math-constp a)
(and exp-ok math-expand-formulas))
a
(math-reject-arg a 'constp)))
2001-11-06 18:59:06 +00:00
;;; Some functions for working with error forms.
(defun math-get-value (x)
"Get the mean value of the error form X.
If X is not an error form, return X."
(if (eq (car-safe x) 'sdev)
(nth 1 x)
x))
(defun math-get-sdev (x &optional one)
"Get the standard deviation of the error form X.
If X is not an error form, return 1."
(if (eq (car-safe x) 'sdev)
(nth 2 x)
(if one 1 0)))
(defun math-contains-sdev-p (ls)
"Non-nil if the list LS contains an error form."
(let ((ls (if (eq (car-safe ls) 'vec) (cdr ls) ls)))
(memq t (mapcar (lambda (x) (eq (car-safe x) 'sdev)) ls))))
2001-11-06 18:59:06 +00:00
;;; Coerce integer A to be a small integer. [S I]
(defvar math-simplify-only nil)
2001-11-06 18:59:06 +00:00
(defun math-normalize-fancy (a)
(cond ((eq (car a) 'frac)
(math-make-frac (math-normalize (nth 1 a))
(math-normalize (nth 2 a))))
((eq (car a) 'cplx)
(let ((real (math-normalize (nth 1 a)))
(imag (math-normalize (nth 2 a))))
(if (and (math-zerop imag)
(not math-simplify-only)) ; oh, what a kludge!
real
(list 'cplx real imag))))
((eq (car a) 'polar)
(math-normalize-polar a))
((eq (car a) 'hms)
(math-normalize-hms a))
((eq (car a) 'date)
(list 'date (math-normalize (nth 1 a))))
((eq (car a) 'mod)
(math-normalize-mod a))
((eq (car a) 'sdev)
(let ((x (math-normalize (nth 1 a)))
(s (math-normalize (nth 2 a))))
(if (or (and (Math-objectp x) (not (Math-scalarp x)))
(and (Math-objectp s) (not (Math-scalarp s))))
(list 'calcFunc-sdev x s)
(math-make-sdev x s))))
((eq (car a) 'intv)
(let ((mask (math-normalize (nth 1 a)))
(lo (math-normalize (nth 2 a)))
(hi (math-normalize (nth 3 a))))
(if (if (eq (car-safe lo) 'date)
(not (eq (car-safe hi) 'date))
(or (and (Math-objectp lo) (not (Math-anglep lo)))
(and (Math-objectp hi) (not (Math-anglep hi)))))
(list 'calcFunc-intv mask lo hi)
(math-make-intv mask lo hi))))
((eq (car a) 'vec)
2018-11-20 16:09:35 -05:00
(cons 'vec (mapcar #'math-normalize (cdr a))))
2001-11-06 18:59:06 +00:00
((eq (car a) 'quote)
(math-normalize (nth 1 a)))
((eq (car a) 'special-const)
(calc-with-default-simplification
(math-normalize (nth 1 a))))
((eq (car a) 'var)
(cons 'var (cdr a))) ; need to re-cons for selection routines
((eq (car a) 'calcFunc-if)
(math-normalize-logical-op a))
((memq (car a) '(calcFunc-lambda calcFunc-quote calcFunc-condition))
(let ((calc-simplify-mode 'none))
2018-11-20 16:09:35 -05:00
(cons (car a) (mapcar #'math-normalize (cdr a)))))
2001-11-06 18:59:06 +00:00
((eq (car a) 'calcFunc-evalto)
(setq a (or (nth 1 a) 0))
(or calc-refreshing-evaltos
(setq a (let ((calc-simplify-mode 'none)) (math-normalize a))))
(let ((b (if (and (eq (car-safe a) 'calcFunc-assign)
(= (length a) 3))
(nth 2 a)
a)))
(list 'calcFunc-evalto
a
(if (eq calc-simplify-mode 'none)
(math-normalize b)
(calc-with-default-simplification
(math-evaluate-expr b))))))
((or (integerp (car a)) (consp (car a)))
(if (null (cdr a))
(math-normalize (car a))
(error "Can't use multi-valued function in an expression")))))
2001-11-06 18:59:06 +00:00
;; The variable math-normalize-a is local to math-normalize in calc.el,
;; but is used by math-normalize-nonstandard, which is called by
;; math-normalize.
2018-11-20 16:09:35 -05:00
(defun math-normalize-nonstandard (a)
2001-11-06 18:59:06 +00:00
(if (consp calc-simplify-mode)
(progn
(setq calc-simplify-mode 'none
2018-11-20 16:09:35 -05:00
math-simplify-only (car-safe (cdr-safe a)))
2001-11-06 18:59:06 +00:00
nil)
2018-11-20 16:09:35 -05:00
(and (symbolp (car a))
2001-11-06 18:59:06 +00:00
(or (eq calc-simplify-mode 'none)
(and (eq calc-simplify-mode 'num)
2018-11-20 16:09:35 -05:00
(let ((aptr (setq a
(cons
2018-11-20 16:09:35 -05:00
(car a)
(mapcar #'math-normalize
(cdr a))))))
2001-11-06 18:59:06 +00:00
(while (and aptr (math-constp (car aptr)))
(setq aptr (cdr aptr)))
aptr)))
2018-11-20 16:09:35 -05:00
(cons (car a)
(mapcar #'math-normalize (cdr a))))))
2001-11-06 18:59:06 +00:00
;;; Return 0 for zero, -1 for negative, 1 for positive. [S n] [Public]
(defun calcFunc-sign (a &optional x)
(let ((signs (math-possible-signs a)))
(cond ((eq signs 4) (or x 1))
((eq signs 2) 0)
((eq signs 1) (if x (math-neg x) -1))
((math-looks-negp a) (math-neg (calcFunc-sign (math-neg a))))
(t (calc-record-why 'realp a)
(if x
(list 'calcFunc-sign a x)
(list 'calcFunc-sign a))))))
2001-11-06 18:59:06 +00:00
;;; Return 0 if A is numerically equal to B, <0 if less, >0 if more.
;;; Arguments must be normalized! [S N N]
(defun math-compare (a b)
(cond ((equal a b)
(if (and (consp a)
(memq (car a) '(var neg * /))
(math-infinitep a))
2
0))
((and (integerp a) (Math-integerp b))
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(if (< a b) -1 1))
2001-11-06 18:59:06 +00:00
((eq (car-safe a) 'frac)
(if (eq (car-safe b) 'frac)
(math-compare (math-mul (nth 1 a) (nth 2 b))
(math-mul (nth 1 b) (nth 2 a)))
(math-compare (nth 1 a) (math-mul b (nth 2 a)))))
((eq (car-safe b) 'frac)
(math-compare (math-mul a (nth 2 b)) (nth 1 b)))
((and (eq (car-safe a) 'float) (eq (car-safe b) 'float))
(if (math-lessp-float a b) -1 1))
((and (eq (car-safe a) 'date) (eq (car-safe b) 'date))
(math-compare (nth 1 a) (nth 1 b)))
((and (or (Math-anglep a)
(and (eq (car a) 'cplx) (eq (nth 2 a) 0)))
(or (Math-anglep b)
(and (eq (car b) 'cplx) (eq (nth 2 b) 0))))
(calcFunc-sign (math-add a (math-neg b))))
((and (eq (car-safe a) 'intv)
(or (Math-anglep b) (eq (car-safe b) 'date)))
(let ((res (math-compare (nth 2 a) b)))
(cond ((eq res 1) 1)
((and (eq res 0) (memq (nth 1 a) '(0 1))) 1)
((eq (setq res (math-compare (nth 3 a) b)) -1) -1)
((and (eq res 0) (memq (nth 1 a) '(0 2))) -1)
(t 2))))
((and (eq (car-safe b) 'intv)
(or (Math-anglep a) (eq (car-safe a) 'date)))
(let ((res (math-compare a (nth 2 b))))
(cond ((eq res -1) -1)
((and (eq res 0) (memq (nth 1 b) '(0 1))) -1)
((eq (setq res (math-compare a (nth 3 b))) 1) 1)
((and (eq res 0) (memq (nth 1 b) '(0 2))) 1)
(t 2))))
((and (eq (car-safe a) 'intv) (eq (car-safe b) 'intv))
(let ((res (math-compare (nth 3 a) (nth 2 b))))
(cond ((eq res -1) -1)
((and (eq res 0) (or (memq (nth 1 a) '(0 2))
(memq (nth 1 b) '(0 1)))) -1)
((eq (setq res (math-compare (nth 2 a) (nth 3 b))) 1) 1)
((and (eq res 0) (or (memq (nth 1 a) '(0 1))
(memq (nth 1 b) '(0 2)))) 1)
(t 2))))
((math-infinitep a)
(if (or (equal a '(var uinf var-uinf))
(equal a '(var nan var-nan)))
2
(let ((dira (math-infinite-dir a)))
(if (math-infinitep b)
(if (or (equal b '(var uinf var-uinf))
(equal b '(var nan var-nan)))
2
(let ((dirb (math-infinite-dir b)))
(cond ((and (eq dira 1) (eq dirb -1)) 1)
((and (eq dira -1) (eq dirb 1)) -1)
(t 2))))
(cond ((eq dira 1) 1)
((eq dira -1) -1)
(t 2))))))
((math-infinitep b)
(if (or (equal b '(var uinf var-uinf))
(equal b '(var nan var-nan)))
2
(let ((dirb (math-infinite-dir b)))
(cond ((eq dirb 1) -1)
((eq dirb -1) 1)
(t 2)))))
((and (eq (car-safe a) 'calcFunc-exp)
(eq (car-safe b) '^)
(equal (nth 1 b) '(var e var-e)))
(math-compare (nth 1 a) (nth 2 b)))
((and (eq (car-safe b) 'calcFunc-exp)
(eq (car-safe a) '^)
(equal (nth 1 a) '(var e var-e)))
(math-compare (nth 2 a) (nth 1 b)))
((or (and (eq (car-safe a) 'calcFunc-sqrt)
(eq (car-safe b) '^)
(or (equal (nth 2 b) '(frac 1 2))
(equal (nth 2 b) '(float 5 -1))))
(and (eq (car-safe b) 'calcFunc-sqrt)
(eq (car-safe a) '^)
(or (equal (nth 2 a) '(frac 1 2))
(equal (nth 2 a) '(float 5 -1)))))
(math-compare (nth 1 a) (nth 1 b)))
((eq (car-safe a) 'var)
2)
(t
(if (and (consp a) (consp b)
(eq (car a) (car b))
(math-compare-lists (cdr a) (cdr b)))
0
2))))
2001-11-06 18:59:06 +00:00
(defun math-compare-lists (a b)
(cond ((null a) (null b))
((null b) nil)
(t (and (Math-equal (car a) (car b))
(math-compare-lists (cdr a) (cdr b))))))
2001-11-06 18:59:06 +00:00
(defun math-lessp-float (a b) ; [P F F]
(let ((ediff (- (nth 2 a) (nth 2 b))))
(if (>= ediff 0)
(if (>= ediff (+ calc-internal-prec calc-internal-prec))
(if (eq (nth 1 a) 0)
(Math-integer-posp (nth 1 b))
(Math-integer-negp (nth 1 a)))
(Math-lessp (math-scale-int (nth 1 a) ediff)
(nth 1 b)))
(if (>= (setq ediff (- ediff))
(+ calc-internal-prec calc-internal-prec))
(if (eq (nth 1 b) 0)
(Math-integer-negp (nth 1 a))
(Math-integer-posp (nth 1 b)))
(Math-lessp (nth 1 a)
(math-scale-int (nth 1 b) ediff))))))
2001-11-06 18:59:06 +00:00
;;; True if A is numerically equal to B. [P N N] [Public]
(defun math-equal (a b)
(= (math-compare a b) 0))
2001-11-06 18:59:06 +00:00
;;; True if A is numerically less than B. [P R R] [Public]
(defun math-lessp (a b)
(= (math-compare a b) -1))
2001-11-06 18:59:06 +00:00
;;; True if A is numerically equal to the integer B. [P N S] [Public]
;;; B must not be a multiple of 10.
(defun math-equal-int (a b)
(or (eql a b)
2001-11-06 18:59:06 +00:00
(and (eq (car-safe a) 'float)
(eql (nth 1 a) b)
(= (nth 2 a) 0))))
2001-11-06 18:59:06 +00:00
;;; Return the dimensions of a matrix as a list. [l x] [Public]
(defun math-mat-dimens (m)
(if (math-vectorp m)
(if (math-matrixp m)
(cons (1- (length m))
(math-mat-dimens (nth 1 m)))
(list (1- (length m))))
nil))
2001-11-06 18:59:06 +00:00
(defun calc-binary-op-fancy (name func arg ident unary)
(let ((n (prefix-numeric-value arg)))
(cond ((> n 1)
(calc-enter-result n
name
(list 'calcFunc-reduce
(math-calcFunc-to-var func)
(cons 'vec (calc-top-list-n n)))))
((= n 1)
(if unary
(calc-enter-result 1 name (list unary (calc-top-n 1)))))
((= n 0)
(if ident
(calc-enter-result 0 name ident)
(error "Argument must be nonzero")))
(t
(let ((rhs (calc-top-n 1)))
(calc-enter-result (- 1 n)
name
Don't quote lambdas with 'function' in calc/*.el * lisp/calc/calc-aent.el (calc-do-quick-calc) (calc-do-calc-eval, math-build-parse-table): * lisp/calc/calc-alg.el (math-polynomial-base): * lisp/calc/calc-alg.el (math-is-poly-rec): * lisp/calc/calc-arith.el (calcFunc-scf): * lisp/calc/calc-arith.el (math-ceiling, math-round): * lisp/calc/calc-arith.el (math-trunc-fancy, math-floor-fancy): * lisp/calc/calc-ext.el (calc-init-extensions, calc-reset) (calc-refresh-top, calc-z-prefix-help, calc-binary-op-fancy) (calc-unary-op-fancy): * lisp/calc/calc-forms.el (math-make-mod): * lisp/calc/calc-frac.el (calcFunc-frac): * lisp/calc/calc-funcs.el (calcFunc-euler): * lisp/calc/calc-help.el (calc-full-help): * lisp/calc/calc-lang.el (c, pascal, fortran, tex, latex, eqn) (yacas, maxima, giac, math, maple): * lisp/calc/calc-macs.el (calc-wrapper, calc-slow-wrapper): * lisp/calc/calc-map.el (calc-get-operator, calcFunc-mapeqr) (calcFunc-reducea, calcFunc-rreducea, calcFunc-reduced) (calcFunc-rreduced, calcFunc-outer): * lisp/calc/calc-misc.el (another-calc, calc-do-handle-whys): * lisp/calc/calc-mode.el (calc-save-modes): * lisp/calc/calc-mtx.el (math-col-matrix, math-mul-mat-vec): * lisp/calc/calc-poly.el (math-sort-terms, math-poly-div-list) (math-mul-list, math-sort-poly-base-list) (math-partial-fractions): * lisp/calc/calc-prog.el (calc-user-define-formula): * lisp/calc/calc-rewr.el (math-rewrite, math-compile-patterns) (math-compile-rewrites, math-parse-schedule) (math-rwcomp-pattern): * lisp/calc/calc-store.el (calc-var-name-map, calc-let) (calc-permanent-variable, calc-insert-variables): * lisp/calc/calc-stuff.el (calc-flush-caches, calcFunc-pclean) (calcFunc-pfrac): * lisp/calc/calc-units.el (math-build-units-table) (math-decompose-units): * lisp/calc/calc-vec.el (calcFunc-mrow, math-mat-col) (calcFunc-mcol, math-mat-less-col, math-mimic-ident): * lisp/calc/calc-yank.el (calc-edit): * lisp/calc/calc.el (calc-mode-var-list-restore-default-values) (calc-mode-var-list-restore-saved-values, calc-mode, calc-quit): * lisp/calc/calccomp.el (math-compose-expr) (math-compose-matrix, math-vector-to-string): Don't quote lambdas with 'function'.
2020-11-17 02:51:30 +01:00
(mapcar (lambda (x)
(list func x rhs))
(calc-top-list-n (- n) 2))))))))
2001-11-06 18:59:06 +00:00
(defun calc-unary-op-fancy (name func arg)
(let ((n (prefix-numeric-value arg)))
(if (= n 0) (setq n (calc-stack-size)))
(cond ((> n 0)
(calc-enter-result n
name
Don't quote lambdas with 'function' in calc/*.el * lisp/calc/calc-aent.el (calc-do-quick-calc) (calc-do-calc-eval, math-build-parse-table): * lisp/calc/calc-alg.el (math-polynomial-base): * lisp/calc/calc-alg.el (math-is-poly-rec): * lisp/calc/calc-arith.el (calcFunc-scf): * lisp/calc/calc-arith.el (math-ceiling, math-round): * lisp/calc/calc-arith.el (math-trunc-fancy, math-floor-fancy): * lisp/calc/calc-ext.el (calc-init-extensions, calc-reset) (calc-refresh-top, calc-z-prefix-help, calc-binary-op-fancy) (calc-unary-op-fancy): * lisp/calc/calc-forms.el (math-make-mod): * lisp/calc/calc-frac.el (calcFunc-frac): * lisp/calc/calc-funcs.el (calcFunc-euler): * lisp/calc/calc-help.el (calc-full-help): * lisp/calc/calc-lang.el (c, pascal, fortran, tex, latex, eqn) (yacas, maxima, giac, math, maple): * lisp/calc/calc-macs.el (calc-wrapper, calc-slow-wrapper): * lisp/calc/calc-map.el (calc-get-operator, calcFunc-mapeqr) (calcFunc-reducea, calcFunc-rreducea, calcFunc-reduced) (calcFunc-rreduced, calcFunc-outer): * lisp/calc/calc-misc.el (another-calc, calc-do-handle-whys): * lisp/calc/calc-mode.el (calc-save-modes): * lisp/calc/calc-mtx.el (math-col-matrix, math-mul-mat-vec): * lisp/calc/calc-poly.el (math-sort-terms, math-poly-div-list) (math-mul-list, math-sort-poly-base-list) (math-partial-fractions): * lisp/calc/calc-prog.el (calc-user-define-formula): * lisp/calc/calc-rewr.el (math-rewrite, math-compile-patterns) (math-compile-rewrites, math-parse-schedule) (math-rwcomp-pattern): * lisp/calc/calc-store.el (calc-var-name-map, calc-let) (calc-permanent-variable, calc-insert-variables): * lisp/calc/calc-stuff.el (calc-flush-caches, calcFunc-pclean) (calcFunc-pfrac): * lisp/calc/calc-units.el (math-build-units-table) (math-decompose-units): * lisp/calc/calc-vec.el (calcFunc-mrow, math-mat-col) (calcFunc-mcol, math-mat-less-col, math-mimic-ident): * lisp/calc/calc-yank.el (calc-edit): * lisp/calc/calc.el (calc-mode-var-list-restore-default-values) (calc-mode-var-list-restore-saved-values, calc-mode, calc-quit): * lisp/calc/calccomp.el (math-compose-expr) (math-compose-matrix, math-vector-to-string): Don't quote lambdas with 'function'.
2020-11-17 02:51:30 +01:00
(mapcar (lambda (x)
(list func x))
2001-11-06 18:59:06 +00:00
(calc-top-list-n n))))
((< n 0)
(calc-enter-result 1
name
(list func (calc-top-n (- n)))
(- n))))))
2001-11-06 18:59:06 +00:00
(defvar var-Holidays '(vec (var sat var-sat) (var sun var-sun)))
(defvar var-Decls (list 'vec))
(defun math-inexact-result ()
(and calc-symbolic-mode
(signal 'inexact-result nil)))
2001-11-06 18:59:06 +00:00
(defun math-overflow (&optional exp)
(if (and exp (math-negp exp))
(math-underflow)
(signal 'math-overflow nil)))
2001-11-06 18:59:06 +00:00
(defun math-underflow ()
(signal 'math-underflow nil))
2001-11-06 18:59:06 +00:00
;;; Compute the greatest common divisor of A and B. [I I I] [Public]
(defun math-gcd (a b)
(cond ((not (or (consp a) (consp b)))
(if (< a 0) (setq a (- a)))
(if (< b 0) (setq b (- b)))
(let (c)
(if (< a b)
(setq c b b a a c))
(while (> b 0)
(setq c b
b (% a b)
a c))
a))
((eq a 0) b)
((eq b 0) a)
(t
(if (Math-integer-negp a) (setq a (math-neg a)))
(if (Math-integer-negp b) (setq b (math-neg b)))
(let (c)
(if (< a b)
2001-11-06 18:59:06 +00:00
(setq c b b a a c))
(while (and (consp a) (not (eq b 0)))
(setq c b
b (math-imod a b)
a c))
(while (> b 0)
(setq c b
b (% a b)
a c))
a))))
2001-11-06 18:59:06 +00:00
;;;; Algebra.
;;; Evaluate variables in an expression.
(defun math-evaluate-expr (x) ; [Public]
(if calc-embedded-info
(calc-embedded-evaluate-expr x)
(calc-normalize (math-evaluate-expr-rec x))))
(defalias 'calcFunc-evalv 'math-evaluate-expr)
2001-11-06 18:59:06 +00:00
(defun calcFunc-evalvn (x &optional prec)
(if prec
(progn
(or (math-num-integerp prec)
(if (and (math-vectorp prec)
(= (length prec) 2)
(math-num-integerp (nth 1 prec)))
(setq prec (math-add (nth 1 prec) calc-internal-prec))
(math-reject-arg prec 'integerp)))
(setq prec (math-trunc prec))
(if (< prec 3) (setq prec 3))
(if (> prec calc-internal-prec)
(math-normalize
(let ((calc-internal-prec prec))
(calcFunc-evalvn x)))
(let ((calc-internal-prec prec))
(calcFunc-evalvn x))))
(let ((calc-symbolic-mode nil))
(math-evaluate-expr x))))
2001-11-06 18:59:06 +00:00
(defun math-evaluate-expr-rec (x)
(if (consp x)
(if (memq (car x) '(calcFunc-quote calcFunc-condition
calcFunc-evalto calcFunc-assign))
(if (and (eq (car x) 'calcFunc-assign)
(= (length x) 3))
(list (car x) (nth 1 x) (math-evaluate-expr-rec (nth 2 x)))
x)
(if (eq (car x) 'var)
(if (and (calc-var-value (nth 2 x))
(not (eq (car-safe (symbol-value (nth 2 x)))
'incomplete)))
(let ((val (symbol-value (nth 2 x))))
(if (eq (car-safe val) 'special-const)
(if calc-symbolic-mode
x
val)
val))
x)
(if (Math-primp x)
x
2018-11-20 16:09:35 -05:00
(cons (car x) (mapcar #'math-evaluate-expr-rec (cdr x))))))
x))
2001-11-06 18:59:06 +00:00
(defun math-any-floats (expr)
(if (Math-primp expr)
(math-floatp expr)
(while (and (setq expr (cdr expr)) (not (math-any-floats (car expr)))))
expr))
2001-11-06 18:59:06 +00:00
(defvar var-FactorRules 'calc-FactorRules)
(defvar math-mt-many nil)
(defvar math-mt-func nil)
2018-11-20 16:09:35 -05:00
(defun math-map-tree (func mmt-expr &optional many)
(let ((math-mt-func func)
(math-mt-many (or many 1000000)))
(math-map-tree-rec mmt-expr)))
2001-11-06 18:59:06 +00:00
(defun math-map-tree-rec (mmt-expr)
(or (= math-mt-many 0)
2001-11-06 18:59:06 +00:00
(let ((mmt-done nil)
mmt-nextval)
(while (not mmt-done)
(while (and (/= math-mt-many 0)
(setq mmt-nextval (funcall math-mt-func mmt-expr))
2001-11-06 18:59:06 +00:00
(not (equal mmt-expr mmt-nextval)))
(setq mmt-expr mmt-nextval
math-mt-many (if (> math-mt-many 0)
(1- math-mt-many)
(1+ math-mt-many))))
2001-11-06 18:59:06 +00:00
(if (or (Math-primp mmt-expr)
(<= math-mt-many 0))
2001-11-06 18:59:06 +00:00
(setq mmt-done t)
(setq mmt-nextval (cons (car mmt-expr)
2018-11-20 16:09:35 -05:00
(mapcar #'math-map-tree-rec
2001-11-06 18:59:06 +00:00
(cdr mmt-expr))))
(if (equal mmt-nextval mmt-expr)
(setq mmt-done t)
(setq mmt-expr mmt-nextval))))))
mmt-expr)
2001-11-06 18:59:06 +00:00
(defun math-is-true (expr)
(if (Math-numberp expr)
(not (Math-zerop expr))
(math-known-nonzerop expr)))
2001-11-06 18:59:06 +00:00
(defun math-const-var (expr)
(and (consp expr)
(eq (car expr) 'var)
(or (and (symbolp (nth 2 expr))
(boundp (nth 2 expr))
(eq (car-safe (symbol-value (nth 2 expr))) 'special-const))
(memq (nth 2 expr) '(var-inf var-uinf var-nan)))))
2001-11-06 18:59:06 +00:00
;; The variable math-integral-cache is originally declared in calcalg2.el,
2011-11-17 01:09:20 -08:00
;; but is set by math-defintegral and math-defintegral-2.
(defvar math-integral-cache)
2001-11-06 18:59:06 +00:00
(defmacro math-defintegral (funcs &rest code)
2018-11-20 16:09:35 -05:00
(declare (indent 1) (debug (sexp body)))
2001-11-06 18:59:06 +00:00
(setq math-integral-cache nil)
(cons 'progn
(mapcar (lambda (func)
`(put ',func 'math-integral
(nconc
(get ',func 'math-integral)
(list
(lambda (u) ,@code)))))
(if (symbolp funcs) (list funcs) funcs))))
2001-11-06 18:59:06 +00:00
(defmacro math-defintegral-2 (funcs &rest code)
2018-11-20 16:09:35 -05:00
(declare (indent 1) (debug (sexp body)))
2001-11-06 18:59:06 +00:00
(setq math-integral-cache nil)
(cons 'progn
(mapcar (lambda (func)
`(put ',func 'math-integral-2
(nconc
(get ',func 'math-integral-2)
(list (lambda (u v) ,@code)))))
(if (symbolp funcs) (list funcs) funcs))))
2001-11-06 18:59:06 +00:00
(defvar var-IntegAfterRules 'calc-IntegAfterRules)
(defvar var-FitRules 'calc-FitRules)
(defvar math-poly-base-variable nil)
(defvar math-poly-neg-powers nil)
(defvar math-poly-mult-powers 1)
(defvar math-poly-frac-powers nil)
(defvar math-poly-exp-base nil)
2001-11-06 18:59:06 +00:00
(defun math-build-var-name (name)
(if (stringp name)
(setq name (intern name)))
(if (string-match "\\`var-." (symbol-name name))
(list 'var (intern (substring (symbol-name name) 4)) name)
(list 'var name (intern (concat "var-" (symbol-name name))))))
2001-11-06 18:59:06 +00:00
(defvar math-simplifying-units nil)
(defvar math-combining-units t)
2001-11-06 18:59:06 +00:00
;;; Nontrivial number parsing.
(defun math-read-number-fancy (s)
(cond
;; Integer+fractions
((string-match "^\\([0-9]*\\)[:/]\\([0-9]*\\)[:/]\\([0-9]*\\)$" s)
(let ((int (math-match-substring s 1))
(num (math-match-substring s 2))
(den (math-match-substring s 3)))
(let ((int (if (> (length int) 0) (math-read-number int) 0))
(num (if (> (length num) 0) (math-read-number num) 1))
(den (if (> (length num) 0) (math-read-number den) 1)))
(and int num den
(math-integerp int) (math-integerp num) (math-integerp den)
(not (math-zerop den))
(list 'frac (math-add num (math-mul int den)) den)))))
2003-02-04 13:24:35 +00:00
2001-11-06 18:59:06 +00:00
;; Fractions
((string-match "^\\([0-9]*\\)[:/]\\([0-9]*\\)$" s)
(let ((num (math-match-substring s 1))
(den (math-match-substring s 2)))
(let ((num (if (> (length num) 0) (math-read-number num) 1))
(den (if (> (length num) 0) (math-read-number den) 1)))
(and num den (math-integerp num) (math-integerp den)
(not (math-zerop den))
(list 'frac num den)))))
2003-02-04 13:24:35 +00:00
2001-11-06 18:59:06 +00:00
;; Modulo forms
((string-match "^\\(.*\\) *mod *\\(.*\\)$" s)
(let* ((n (math-match-substring s 1))
(m (math-match-substring s 2))
(n (math-read-number n))
(m (math-read-number m)))
(and n m (math-anglep n) (math-anglep m)
(list 'mod n m))))
;; Error forms
((string-match "^\\(.*\\) *\\+/- *\\(.*\\)$" s)
(let* ((x (math-match-substring s 1))
(sigma (math-match-substring s 2))
(x (math-read-number x))
(sigma (math-read-number sigma)))
(and x sigma (math-scalarp x) (math-anglep sigma)
(list 'sdev x sigma))))
;; Integer+fraction with explicit radix
((string-match "^\\([0-9]+\\)\\(#\\|\\^\\^\\)\\([0-9a-zA-Z]*\\)[:/]\\([0-9a-zA-Z]*\\)[:/]\\([0-9a-zA-Z]\\)$" s)
(let ((radix (string-to-number (math-match-substring s 1)))
2001-11-06 18:59:06 +00:00
(int (math-match-substring s 3))
(num (math-match-substring s 4))
(den (math-match-substring s 5)))
(let ((int (if (> (length int) 0) (math-read-radix int radix) 0))
(num (if (> (length num) 0) (math-read-radix num radix) 1))
(den (if (> (length den) 0) (math-read-radix den radix) 1)))
(and int num den (not (math-zerop den))
(list 'frac
(math-add num (math-mul int den))
den)))))
2003-02-04 13:24:35 +00:00
2001-11-06 18:59:06 +00:00
;; Fraction with explicit radix
((string-match "^\\([0-9]+\\)\\(#\\|\\^\\^\\)\\([0-9a-zA-Z]*\\)[:/]\\([0-9a-zA-Z]*\\)$" s)
(let ((radix (string-to-number (math-match-substring s 1)))
2001-11-06 18:59:06 +00:00
(num (math-match-substring s 3))
(den (math-match-substring s 4)))
(let ((num (if (> (length num) 0) (math-read-radix num radix) 1))
(den (if (> (length den) 0) (math-read-radix den radix) 1)))
(and num den (not (math-zerop den)) (list 'frac num den)))))
2003-02-04 13:24:35 +00:00
2001-11-06 18:59:06 +00:00
;; Float with explicit radix and exponent
((or (string-match "^0*\\(\\([2-9]\\|1[0-4]\\)\\(#\\|\\^\\^\\)[0-9a-dA-D.]+\\)[eE]\\([-+]?[0-9]+\\)$" s)
(string-match "^\\(\\([0-9]+\\)\\(#\\|\\^\\^\\)[0-9a-zA-Z.]+\\) *\\* *\\2\\.? *\\^ *\\([-+]?[0-9]+\\)$" s))
(let ((radix (string-to-number (math-match-substring s 2)))
2001-11-06 18:59:06 +00:00
(mant (math-match-substring s 1))
(exp (math-match-substring s 4)))
(let ((mant (math-read-number mant))
(exp (math-read-number exp)))
(and mant exp
(math-mul mant (math-pow (math-float radix) exp))))))
;; Float with explicit radix, no exponent
((string-match "^\\([0-9]+\\)\\(#\\|\\^\\^\\)\\([0-9a-zA-Z]*\\)\\.\\([0-9a-zA-Z]*\\)$" s)
(let ((radix (string-to-number (math-match-substring s 1)))
2001-11-06 18:59:06 +00:00
(int (math-match-substring s 3))
(fracs (math-match-substring s 4)))
(let ((int (if (> (length int) 0) (math-read-radix int radix) 0))
(frac (if (> (length fracs) 0) (math-read-radix fracs radix) 0))
(calc-prefer-frac nil))
(and int frac
(math-add int (math-div frac (math-pow radix (length fracs))))))))
;; Integer with explicit radix
((string-match "^\\([0-9]+\\)\\(#&?\\|\\^\\^\\)\\([0-9a-zA-Z]+\\)$" s)
2001-11-06 18:59:06 +00:00
(math-read-radix (math-match-substring s 3)
(string-to-number (math-match-substring s 1))))
2001-11-06 18:59:06 +00:00
;; Two's complement with explicit radix
((string-match "^\\([0-9]+\\)\\(##\\)\\([0-9a-zA-Z]+\\)$" s)
(let ((num (math-read-radix (math-match-substring s 3)
(string-to-number (math-match-substring s 1)))))
(if (and
(Math-lessp num math-2-word-size)
(<= (math-compare math-half-2-word-size num) 0))
(math-sub num math-2-word-size)
num)))
2001-11-06 18:59:06 +00:00
;; C language hexadecimal notation
((and (eq calc-language 'c)
Replace manually crafted hex regexes with [:xdigit:] * admin/charsets/mapconv: * build-aux/gitlog-to-changelog (parse_amend_file, git_dir_option): * lisp/progmodes/verilog-mode.el (verilog-delay-re): (verilog-type-font-keywords, verilog-read-always-signals-recurse): (verilog-is-number): * lisp/progmodes/vera-mode.el (vera-font-lock-keywords): * test/src/emacs-module-tests.el (mod-test-sum-test): * lisp/xml.el: (xml--entity-replacement-text): * lisp/version.el (emacs-repository-version-git): * lisp/textmodes/sgml-mode.el (sgml-quote): * lisp/textmodes/css-mode.el (css-escapes-re) (css--colors-regexp): * lisp/progmodes/prolog.el (prolog-syntax-propertize-function): * lisp/progmodes/hideif.el (hif-token-regexp, hif-tokenize): * lisp/progmodes/ebnf-dtd.el: (ebnf-dtd-attlistdecl) (ebnf-dtd-entitydecl, ebnf-dtd-lex): * lisp/progmodes/ebnf-ebx.el (ebnf-ebx-hex-character): * lisp/progmodes/ebnf-abn.el (ebnf-abn-character): * lisp/progmodes/cperl-mode.el (cperl-highlight-charclass) (cperl-find-pods-heres): * lisp/progmodes/cc-mode.el (c-maybe-quoted-number-head) (c-maybe-quoted-number, c-parse-quotes-before-change) (c-parse-quotes-after-change, c-quoted-number-head-before-point) (c-quoted-number-straddling-point): * lisp/progmodes/ada-mode.el (featurep, ada-in-numeric-literal-p) (ada-font-lock-keywords): * lisp/org/org-mobile.el (org-mobile-copy-agenda-files) * lisp/org/org-table.el (org-table-number-regexp): (org-mobile-update-checksum-for-capture-file): * lisp/nxml/xsd-regexp.el (xsdre-gen-categories): * lisp/nxml/xmltok.el (let*): * lisp/nxml/rng-xsd.el (rng-xsd-convert-hex-binary) (rng-xsd-convert-any-uri): * lisp/nxml/rng-uri.el (rng-uri-file-name-1) (rng-uri-unescape-multibyte, rng-uri-unescape-unibyte) (rng-uri-unescape-unibyte-match) (rng-uri-unescape-unibyte-replace): * lisp/nxml/rng-cmpct.el (rng-c-process-escapes): * lisp/nxml/nxml-maint.el (nxml-insert-target-repertoire-glyph-set): * lisp/net/shr-color.el (shr-color->hexadecimal): * lisp/mail/rfc2231.el (rfc2231-decode-encoded-string): * lisp/international/mule-cmds.el (read-char-by-name): * lisp/htmlfontify.el (hfy-hex-regex): * lisp/gnus/nneething.el (nneething-decode-file-name): * lisp/gnus/mml-sec.el (mml-secure-find-usable-keys): * lisp/gnus/gnus-art.el (gnus-button-mid-or-mail-heuristic-alist): * lisp/faces.el (read-color): * lisp/epg.el (epg--status-ERRSIG, epg--status-VALIDSIG) (epg--status-SIG_CREATED, epg--decode-percent-escape) (epg--decode-hexstring, epg--decode-quotedstring) (epg-dn-from-string): * lisp/emulation/cua-rect.el (cua-incr-rectangle): * lisp/dnd.el (dnd-unescape-uri): * lisp/cedet/semantic/lex.el (semantic-lex-number-expression): * lisp/cedet/semantic/java.el (semantic-java-number-regexp): * lisp/calc/calc-lang.el (pascal): * lisp/calc/calc-ext.el (math-read-number-fancy): * lisp/calc/calc-aent.el (math-read-token): Replace various combinations of [0-9a-fA-F] with [[:xdigit:]]. (Bug#36167)
2019-06-13 03:18:43 +03:00
(string-match "^0[xX]\\([[:xdigit:]]+\\)$" s))
2001-11-06 18:59:06 +00:00
(let ((digs (math-match-substring s 1)))
(math-read-radix digs 16)))
;; Pascal language hexadecimal notation
((and (eq calc-language 'pascal)
Replace manually crafted hex regexes with [:xdigit:] * admin/charsets/mapconv: * build-aux/gitlog-to-changelog (parse_amend_file, git_dir_option): * lisp/progmodes/verilog-mode.el (verilog-delay-re): (verilog-type-font-keywords, verilog-read-always-signals-recurse): (verilog-is-number): * lisp/progmodes/vera-mode.el (vera-font-lock-keywords): * test/src/emacs-module-tests.el (mod-test-sum-test): * lisp/xml.el: (xml--entity-replacement-text): * lisp/version.el (emacs-repository-version-git): * lisp/textmodes/sgml-mode.el (sgml-quote): * lisp/textmodes/css-mode.el (css-escapes-re) (css--colors-regexp): * lisp/progmodes/prolog.el (prolog-syntax-propertize-function): * lisp/progmodes/hideif.el (hif-token-regexp, hif-tokenize): * lisp/progmodes/ebnf-dtd.el: (ebnf-dtd-attlistdecl) (ebnf-dtd-entitydecl, ebnf-dtd-lex): * lisp/progmodes/ebnf-ebx.el (ebnf-ebx-hex-character): * lisp/progmodes/ebnf-abn.el (ebnf-abn-character): * lisp/progmodes/cperl-mode.el (cperl-highlight-charclass) (cperl-find-pods-heres): * lisp/progmodes/cc-mode.el (c-maybe-quoted-number-head) (c-maybe-quoted-number, c-parse-quotes-before-change) (c-parse-quotes-after-change, c-quoted-number-head-before-point) (c-quoted-number-straddling-point): * lisp/progmodes/ada-mode.el (featurep, ada-in-numeric-literal-p) (ada-font-lock-keywords): * lisp/org/org-mobile.el (org-mobile-copy-agenda-files) * lisp/org/org-table.el (org-table-number-regexp): (org-mobile-update-checksum-for-capture-file): * lisp/nxml/xsd-regexp.el (xsdre-gen-categories): * lisp/nxml/xmltok.el (let*): * lisp/nxml/rng-xsd.el (rng-xsd-convert-hex-binary) (rng-xsd-convert-any-uri): * lisp/nxml/rng-uri.el (rng-uri-file-name-1) (rng-uri-unescape-multibyte, rng-uri-unescape-unibyte) (rng-uri-unescape-unibyte-match) (rng-uri-unescape-unibyte-replace): * lisp/nxml/rng-cmpct.el (rng-c-process-escapes): * lisp/nxml/nxml-maint.el (nxml-insert-target-repertoire-glyph-set): * lisp/net/shr-color.el (shr-color->hexadecimal): * lisp/mail/rfc2231.el (rfc2231-decode-encoded-string): * lisp/international/mule-cmds.el (read-char-by-name): * lisp/htmlfontify.el (hfy-hex-regex): * lisp/gnus/nneething.el (nneething-decode-file-name): * lisp/gnus/mml-sec.el (mml-secure-find-usable-keys): * lisp/gnus/gnus-art.el (gnus-button-mid-or-mail-heuristic-alist): * lisp/faces.el (read-color): * lisp/epg.el (epg--status-ERRSIG, epg--status-VALIDSIG) (epg--status-SIG_CREATED, epg--decode-percent-escape) (epg--decode-hexstring, epg--decode-quotedstring) (epg-dn-from-string): * lisp/emulation/cua-rect.el (cua-incr-rectangle): * lisp/dnd.el (dnd-unescape-uri): * lisp/cedet/semantic/lex.el (semantic-lex-number-expression): * lisp/cedet/semantic/java.el (semantic-java-number-regexp): * lisp/calc/calc-lang.el (pascal): * lisp/calc/calc-ext.el (math-read-number-fancy): * lisp/calc/calc-aent.el (math-read-token): Replace various combinations of [0-9a-fA-F] with [[:xdigit:]]. (Bug#36167)
2019-06-13 03:18:43 +03:00
(string-match "^\\$\\([[:xdigit:]]+\\)$" s))
2001-11-06 18:59:06 +00:00
(let ((digs (math-match-substring s 1)))
(math-read-radix digs 16)))
;; Hours (or degrees)
((or (string-match "^\\([^#^]+\\)[@oOhH]\\(.*\\)$" s)
(string-match "^\\([^#^]+\\)[dD][eE]?[gG]?\\(.*\\)$" s))
(let* ((hours (math-match-substring s 1))
(minsec (math-match-substring s 2))
(hours (math-read-number hours))
(minsec (if (> (length minsec) 0) (math-read-number minsec) 0)))
(and hours minsec
(math-num-integerp hours)
(not (math-negp hours)) (not (math-negp minsec))
(cond ((math-num-integerp minsec)
(and (Math-lessp minsec 60)
(list 'hms hours minsec 0)))
((and (eq (car-safe minsec) 'hms)
(math-zerop (nth 1 minsec)))
(math-add (list 'hms hours 0 0) minsec))
(t nil)))))
;; Minutes
((string-match "^\\([^'#^]+\\)[mM']\\(.*\\)$" s)
(let* ((minutes (math-match-substring s 1))
(seconds (math-match-substring s 2))
(minutes (math-read-number minutes))
(seconds (if (> (length seconds) 0) (math-read-number seconds) 0)))
(and minutes seconds
(math-num-integerp minutes)
(not (math-negp minutes)) (not (math-negp seconds))
(cond ((math-realp seconds)
(and (Math-lessp minutes 60)
(list 'hms 0 minutes seconds)))
((and (eq (car-safe seconds) 'hms)
(math-zerop (nth 1 seconds))
(math-zerop (nth 2 seconds)))
(math-add (list 'hms 0 minutes 0) seconds))
(t nil)))))
;; Seconds
((string-match "^\\([^\"#^]+\\)[sS\"]$" s)
(let ((seconds (math-read-number (math-match-substring s 1))))
(and seconds (math-realp seconds)
(not (math-negp seconds))
(Math-lessp seconds 60)
(list 'hms 0 0 seconds))))
2001-11-06 18:59:06 +00:00
;; Fraction using "/" instead of ":"
((string-match "^\\([0-9]+\\)/\\([0-9/]+\\)$" s)
(math-read-number (concat (math-match-substring s 1) ":"
(math-match-substring s 2))))
;; Syntax error!
(t nil)))
2001-11-06 18:59:06 +00:00
(defun math-read-radix (s r) ; [I X D]
(setq s (upcase s))
(let ((i 0)
(res 0)
dig)
(while (and (< i (length s))
(setq dig (math-read-radix-digit (elt s i)))
(< dig r))
(setq res (math-add (math-mul res r) dig)
i (1+ i)))
(and (= i (length s))
res)))
2001-11-06 18:59:06 +00:00
;;; Expression parsing.
(defvar math-expr-data)
2018-11-20 16:09:35 -05:00
(defvar math-exp-pos)
(defvar math-exp-old-pos)
(defvar math-exp-keep-spaces)
(defvar math-exp-token)
(defvar math-expr-data)
(defvar math-exp-str)
2018-11-20 16:09:35 -05:00
(defun math-read-expr (str)
(let ((math-exp-pos 0)
2018-11-20 16:09:35 -05:00
(math-exp-str str)
(math-exp-old-pos 0)
(math-exp-keep-spaces nil)
math-exp-token math-expr-data)
(setq math-exp-str (math-read-preprocess-string math-exp-str))
(while (setq math-exp-token (string-match "\\.\\.\\([^.]\\|.[^.]\\)" math-exp-str))
(setq math-exp-str (concat (substring math-exp-str 0 math-exp-token) "\\dots"
(substring math-exp-str (+ math-exp-token 2)))))
2001-11-06 18:59:06 +00:00
(math-build-parse-table)
(math-read-token)
(let ((val (catch 'syntax (math-read-expr-level 0))))
(if (stringp val)
(list 'error math-exp-old-pos val)
(if (equal math-exp-token 'end)
2001-11-06 18:59:06 +00:00
val
(list 'error math-exp-old-pos "Syntax error"))))))
2001-11-06 18:59:06 +00:00
(defun math-read-plain-expr (exp-str &optional error-check)
(let* ((calc-language nil)
(math-expr-opers (math-standard-ops))
2001-11-06 18:59:06 +00:00
(val (math-read-expr exp-str)))
(and error-check
(eq (car-safe val) 'error)
(error "%s: %s" (nth 2 val) exp-str))
val))
2001-11-06 18:59:06 +00:00
(defun math-read-string ()
(let ((str (read-from-string (concat math-expr-data "\""))))
(or (and (= (cdr str) (1+ (length math-expr-data)))
2001-11-06 18:59:06 +00:00
(stringp (car str)))
(throw 'syntax "Error in string constant"))
(math-read-token)
(append '(vec) (car str) nil)))
2001-11-06 18:59:06 +00:00
;;; They said it couldn't be done...
2018-11-20 16:09:35 -05:00
(defvar math-read-big-baseline)
(defvar math-read-big-h2)
(defvar math-read-big-err-msg)
(defvar math-read-big-lines)
2018-11-20 16:09:35 -05:00
2001-11-06 18:59:06 +00:00
(defun math-read-big-expr (str)
(and (> (length calc-left-label) 0)
(string-match (concat "^" (regexp-quote calc-left-label)) str)
(setq str (concat (substring str 0 (match-beginning 0))
(substring str (match-end 0)))))
(and (> (length calc-right-label) 0)
(string-match (concat (regexp-quote calc-right-label) " *$") str)
(setq str (concat (substring str 0 (match-beginning 0))
(substring str (match-end 0)))))
(if (string-match "\\\\[^ \n|]" str)
(if (eq calc-language 'latex)
2001-11-06 18:59:06 +00:00
(math-read-expr str)
(let ((calc-language 'latex)
2001-11-06 18:59:06 +00:00
(calc-language-option nil)
(math-expr-opers (get 'latex 'math-oper-table))
(math-expr-function-mapping (get 'latex 'math-function-table))
(math-expr-variable-mapping (get 'latex 'math-variable-table)))
2001-11-06 18:59:06 +00:00
(math-read-expr str)))
(let ((math-read-big-lines nil)
2001-11-06 18:59:06 +00:00
(pos 0)
(width 0)
(math-read-big-err-msg nil)
math-read-big-baseline math-read-big-h2
2001-11-06 18:59:06 +00:00
new-pos p)
Use string-search instead of string-match[-p] `string-search` is easier to understand, less error-prone, much faster, does not pollute the regexp cache, and does not mutate global state. Use it where applicable and obviously safe (erring on the conservative side). * admin/authors.el (authors-canonical-file-name) (authors-scan-change-log): * lisp/apropos.el (apropos-command) (apropos-documentation-property, apropos-symbols-internal): * lisp/arc-mode.el (archive-arc-summarize) (archive-zoo-summarize): * lisp/calc/calc-aent.el (math-read-factor): * lisp/calc/calc-ext.el (math-read-big-expr) (math-format-nice-expr, math-format-number-fancy): * lisp/calc/calc-forms.el (math-read-angle-brackets): * lisp/calc/calc-graph.el (calc-graph-set-range): * lisp/calc/calc-keypd.el (calc-keypad-press): * lisp/calc/calc-lang.el (tex, latex, math-read-big-rec): * lisp/calc/calc-prog.el (calc-fix-token-name) (calc-user-define-permanent, math-define-exp): * lisp/calc/calc.el (calc-record, calcDigit-key) (calc-count-lines): * lisp/calc/calcalg2.el (calc-solve-for, calc-poly-roots) (math-do-integral): * lisp/calc/calcalg3.el (calc-find-root, calc-find-minimum) (calc-get-fit-variables): * lisp/cedet/ede/speedbar.el (ede-tag-expand): * lisp/cedet/semantic/java.el (semantic-java-expand-tag): * lisp/cedet/semantic/sb.el (semantic-sb-show-extra) (semantic-sb-expand-group): * lisp/cedet/semantic/wisent/python.el (semantic-python-instance-variable-p): * lisp/cus-edit.el (get): * lisp/descr-text.el (describe-text-sexp): * lisp/dired-aux.el (dired-compress-file): * lisp/dired-x.el (dired-make-relative-symlink): * lisp/dired.el (dired-glob-regexp): * lisp/dos-fns.el (dos-convert-standard-filename, dos-8+3-filename): * lisp/edmacro.el (edmacro-format-keys): * lisp/emacs-lisp/eieio-opt.el (eieio-sb-expand): * lisp/emacs-lisp/eieio-speedbar.el (eieio-speedbar-object-expand): * lisp/emacs-lisp/lisp-mnt.el (lm-keywords-list): * lisp/emacs-lisp/warnings.el (display-warning): * lisp/emulation/viper-ex.el (viper-ex-read-file-name) (ex-print-display-lines): * lisp/env.el (read-envvar-name, setenv): * lisp/epa-mail.el (epa-mail-encrypt): * lisp/epg.el (epg--start): * lisp/erc/erc-backend.el (erc-parse-server-response): * lisp/erc/erc-dcc.el (erc-dcc-member): * lisp/erc/erc-speedbar.el (erc-speedbar-expand-server) (erc-speedbar-expand-channel, erc-speedbar-expand-user): * lisp/erc/erc.el (erc-send-input): * lisp/eshell/em-glob.el (eshell-glob-entries): * lisp/eshell/esh-proc.el (eshell-needs-pipe-p): * lisp/eshell/esh-util.el (eshell-convert): * lisp/eshell/esh-var.el (eshell-envvar-names): * lisp/faces.el (x-resolve-font-name): * lisp/ffap.el (ffap-file-at-point): * lisp/files.el (wildcard-to-regexp, shell-quote-wildcard-pattern): * lisp/forms.el (forms--update): * lisp/frameset.el (frameset-filter-unshelve-param): * lisp/gnus/gnus-art.el (article-decode-charset): * lisp/gnus/gnus-kill.el (gnus-kill-parse-rn-kill-file): * lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy): * lisp/gnus/gnus-msg.el (gnus-summary-resend-message-insert-gcc) (gnus-inews-insert-gcc): * lisp/gnus/gnus-rfc1843.el (rfc1843-decode-article-body): * lisp/gnus/gnus-search.el (gnus-search-indexed-parse-output) (gnus-search--complete-key-data): * lisp/gnus/gnus-spec.el (gnus-parse-simple-format): * lisp/gnus/gnus-sum.el (gnus-summary-refer-article): * lisp/gnus/gnus-util.el (gnus-extract-address-components) (gnus-newsgroup-directory-form): * lisp/gnus/gnus-uu.el (gnus-uu-grab-view): * lisp/gnus/gnus.el (gnus-group-native-p, gnus-short-group-name): * lisp/gnus/message.el (message-check-news-header-syntax) (message-make-message-id, message-user-mail-address) (message-make-fqdn, message-get-reply-headers, message-followup): * lisp/gnus/mm-decode.el (mm-dissect-buffer): * lisp/gnus/nnheader.el (nnheader-insert): * lisp/gnus/nnimap.el (nnimap-process-quirk) (nnimap-imap-ranges-to-gnus-ranges): * lisp/gnus/nnmaildir.el (nnmaildir--ensure-suffix): * lisp/gnus/nnmairix.el (nnmairix-determine-original-group-from-path): * lisp/gnus/nnrss.el (nnrss-match-macro): * lisp/gnus/nntp.el (nntp-find-group-and-number): * lisp/help-fns.el (help--symbol-completion-table-affixation): * lisp/help.el (help-function-arglist): * lisp/hippie-exp.el (he-concat-directory-file-name): * lisp/htmlfontify.el (hfy-relstub): * lisp/ido.el (ido-make-prompt, ido-complete, ido-copy-current-word) (ido-exhibit): * lisp/image/image-converter.el (image-convert-p): * lisp/info-xref.el (info-xref-docstrings): * lisp/info.el (Info-toc-build, Info-follow-reference) (Info-backward-node, Info-finder-find-node) (Info-speedbar-expand-node): * lisp/international/mule-diag.el (print-fontset-element): * lisp/language/korea-util.el (default-korean-keyboard): * lisp/linum.el (linum-after-change): * lisp/mail/ietf-drums.el (ietf-drums-parse-address): * lisp/mail/mail-utils.el (mail-dont-reply-to): * lisp/mail/rfc2047.el (rfc2047-encode-1, rfc2047-decode-string): * lisp/mail/rfc2231.el (rfc2231-parse-string): * lisp/mail/rmailkwd.el (rmail-set-label): * lisp/mail/rmailsum.el (rmail-header-summary): * lisp/mail/smtpmail.el (smtpmail-maybe-append-domain) (smtpmail-user-mail-address): * lisp/mail/uce.el (uce-reply-to-uce): * lisp/man.el (Man-default-man-entry): * lisp/mh-e/mh-alias.el (mh-alias-gecos-name) (mh-alias-minibuffer-confirm-address): * lisp/mh-e/mh-comp.el (mh-forwarded-letter-subject): * lisp/mh-e/mh-speed.el (mh-speed-parse-flists-output): * lisp/mh-e/mh-utils.el (mh-collect-folder-names-filter) (mh-folder-completion-function): * lisp/minibuffer.el (completion--make-envvar-table) (completion-file-name-table, completion-flex-try-completion) (completion-flex-all-completions): * lisp/mpc.el (mpc--proc-quote-string, mpc-cmd-special-tag-p) (mpc-constraints-tag-lookup): * lisp/net/ange-ftp.el (ange-ftp-send-cmd) (ange-ftp-allow-child-lookup): * lisp/net/mailcap.el (mailcap-mime-types): * lisp/net/mairix.el (mairix-search-thread-this-article): * lisp/net/pop3.el (pop3-open-server): * lisp/net/soap-client.el (soap-decode-xs-complex-type): * lisp/net/socks.el (socks-filter): * lisp/nxml/nxml-outln.el (nxml-highlighted-qname): * lisp/nxml/rng-cmpct.el (rng-c-expand-name, rng-c-expand-datatype): * lisp/nxml/rng-uri.el (rng-uri-file-name-1): * lisp/obsolete/complete.el (partial-completion-mode) (PC-do-completion): * lisp/obsolete/longlines.el (longlines-encode-string): * lisp/obsolete/nnir.el (nnir-compose-result): * lisp/obsolete/terminal.el (te-quote-arg-for-sh): * lisp/obsolete/tpu-edt.el (tpu-check-search-case): * lisp/obsolete/url-ns.el (isPlainHostName): * lisp/pcmpl-unix.el (pcomplete/scp): * lisp/play/dunnet.el (dun-listify-string2, dun-get-path) (dun-unix-parse, dun-doassign, dun-cat, dun-batch-unix-interface): * lisp/progmodes/ebnf2ps.el: (ebnf-eps-header-footer-comment): * lisp/progmodes/gdb-mi.el (gdb-var-delete) (gdb-speedbar-expand-node, gdbmi-bnf-incomplete-record-result): * lisp/progmodes/gud.el (gud-find-expr): * lisp/progmodes/idlw-help.el (idlwave-do-context-help1): * lisp/progmodes/idlw-shell.el (idlwave-shell-mode) (idlwave-shell-filter-hidden-output, idlwave-shell-filter): * lisp/progmodes/idlwave.el (idlwave-skip-label-or-case) (idlwave-routine-info): * lisp/progmodes/octave.el (inferior-octave-completion-at-point): * lisp/progmodes/sh-script.el (sh-add-completer): * lisp/progmodes/sql.el (defun): * lisp/progmodes/xscheme.el (xscheme-process-filter): * lisp/replace.el (query-replace-compile-replacement) (map-query-replace-regexp): * lisp/shell.el (shell--command-completion-data) (shell-environment-variable-completion): * lisp/simple.el (display-message-or-buffer): * lisp/speedbar.el (speedbar-dired, speedbar-tag-file) (speedbar-tag-expand): * lisp/subr.el (split-string-and-unquote): * lisp/tar-mode.el (tar-extract): * lisp/term.el (term-command-hook, serial-read-name): * lisp/textmodes/bibtex.el (bibtex-print-help-message): * lisp/textmodes/ispell.el (ispell-lookup-words, ispell-filter) (ispell-parse-output, ispell-buffer-local-parsing): * lisp/textmodes/reftex-cite.el (reftex-do-citation): * lisp/textmodes/reftex-parse.el (reftex-notice-new): * lisp/textmodes/reftex-ref.el (reftex-show-entry): * lisp/textmodes/reftex.el (reftex-compile-variables): * lisp/textmodes/tex-mode.el (tex-send-command) (tex-start-tex, tex-append): * lisp/thingatpt.el (thing-at-point-url-at-point): * lisp/tmm.el (tmm-add-one-shortcut): * lisp/transient.el (transient-format-key): * lisp/url/url-auth.el (url-basic-auth) (url-digest-auth-directory-id-assoc): * lisp/url/url-news.el (url-news): * lisp/url/url-util.el (url-parse-query-string): * lisp/vc/vc-cvs.el (vc-cvs-parse-entry): * lisp/wid-browse.el (widget-browse-sexp): * lisp/woman.el (woman-parse-colon-path, woman-mini-help) (WoMan-getpage-in-background, woman-negative-vertical-space): * lisp/xml.el: * test/lisp/emacs-lisp/check-declare-tests.el (check-declare-tests-warn): * test/lisp/files-tests.el (files-tests-file-name-non-special-dired-compress-handler): * test/lisp/net/network-stream-tests.el (server-process-filter): * test/src/coding-tests.el (ert-test-unibyte-buffer-dos-eol-decode): Use `string-search` instead of `string-match` and `string-match-p`.
2021-08-09 11:20:00 +02:00
(while (setq new-pos (string-search "\n" str pos))
(setq math-read-big-lines
(cons (substring str pos new-pos) math-read-big-lines)
2001-11-06 18:59:06 +00:00
pos (1+ new-pos)))
(setq math-read-big-lines
(nreverse (cons (substring str pos) math-read-big-lines))
p math-read-big-lines)
2001-11-06 18:59:06 +00:00
(while p
(setq width (max width (length (car p)))
p (cdr p)))
(if (math-read-big-bigp math-read-big-lines)
2001-11-06 18:59:06 +00:00
(or (catch 'syntax
(math-read-big-rec 0 0 width (length math-read-big-lines)))
math-read-big-err-msg
2001-11-06 18:59:06 +00:00
'(error 0 "Syntax error"))
(math-read-expr str)))))
2001-11-06 18:59:06 +00:00
2018-11-20 16:09:35 -05:00
(defvar math-rb-h2)
(defun math-read-big-bigp (read-big-lines)
(when (cdr read-big-lines)
(let ((math-read-big-lines read-big-lines)
(matrix nil)
(v 0)
(height (if (> (length (car read-big-lines)) 0) 1 0)))
(while (and (cdr math-read-big-lines)
(let* ((i 0)
j
(l1 (car math-read-big-lines))
(l2 (nth 1 math-read-big-lines))
(len (min (length l1) (length l2))))
(if (> (length l2) 0)
(setq height (1+ height)))
(while (and (< i len)
(or (memq (aref l1 i) '(?\ ?\- ?\_))
(memq (aref l2 i) '(?\ ?\-))
(and (memq (aref l1 i) '(?\| ?\,))
(= (aref l2 i) (aref l1 i)))
(and (eq (aref l1 i) ?\[)
(eq (aref l2 i) ?\[)
(let ((math-rb-h2 (length l1)))
(setq j (math-read-big-balance
(1+ i) v "[")))
(setq i (1- j)))))
(setq i (1+ i)))
(or (= i len)
(and (eq (aref l1 i) ?\[)
(eq (aref l2 i) ?\[)
(setq matrix t)
nil))))
(setq math-read-big-lines (cdr math-read-big-lines)
v (1+ v)))
(or (and (> height 1)
(not (cdr math-read-big-lines)))
matrix))))
2001-11-06 18:59:06 +00:00
;;; Nontrivial "flat" formatting.
(defvar math-format-hash-args nil)
(defvar calc-can-abbrev-vectors nil)
2001-11-06 18:59:06 +00:00
(defun math-format-flat-expr-fancy (a prec)
(cond
((eq (car a) 'incomplete)
(format "<incomplete %s>" (nth 1 a)))
((eq (car a) 'vec)
(if (or calc-full-trail-vectors (not calc-can-abbrev-vectors)
(< (length a) 7))
(concat "[" (math-format-flat-vector (cdr a) ", "
(if (cdr (cdr a)) 0 1000)) "]")
(concat "["
(math-format-flat-expr (nth 1 a) 0) ", "
(math-format-flat-expr (nth 2 a) 0) ", "
(math-format-flat-expr (nth 3 a) 0) ", ..., "
(math-format-flat-expr (nth (1- (length a)) a) 0) "]")))
((eq (car a) 'intv)
(concat (if (memq (nth 1 a) '(0 1)) "(" "[")
(math-format-flat-expr (nth 2 a) 1000)
" .. "
(math-format-flat-expr (nth 3 a) 1000)
(if (memq (nth 1 a) '(0 2)) ")" "]")))
((eq (car a) 'date)
(concat "<" (math-format-date a) ">"))
((and (eq (car a) 'calcFunc-lambda) (> (length a) 2))
(let ((p (cdr a))
(ap calc-arg-values)
(math-format-hash-args (if (= (length a) 3) 1 t)))
(while (and (cdr p) (equal (car p) (car ap)))
(setq p (cdr p) ap (cdr ap)))
(concat "<"
(if (cdr p)
(concat (math-format-flat-vector
(nreverse (cdr (reverse (cdr a)))) ", " 0)
" : ")
"")
(math-format-flat-expr (nth (1- (length a)) a) 0)
">")))
((eq (car a) 'var)
(or (and math-format-hash-args
(let ((p calc-arg-values) (v 1))
(while (and p (not (equal (car p) a)))
(setq p (and (eq math-format-hash-args t) (cdr p))
v (1+ v)))
(and p
(if (eq math-format-hash-args 1)
"#"
(format "#%d" v)))))
(symbol-name (nth 1 a))))
((and (memq (car a) '(calcFunc-string calcFunc-bstring))
(= (length a) 2)
(math-vectorp (nth 1 a))
(math-vector-is-string (nth 1 a)))
(concat (substring (symbol-name (car a)) 9)
"(" (math-vector-to-string (nth 1 a) t) ")"))
(t
(let ((op (math-assq2 (car a) (math-standard-ops))))
2001-11-06 18:59:06 +00:00
(cond ((and op (= (length a) 3))
(if (> prec (min (nth 2 op) (nth 3 op)))
(concat "(" (math-format-flat-expr a 0) ")")
(let ((lhs (math-format-flat-expr (nth 1 a) (nth 2 op)))
(rhs (math-format-flat-expr (nth 2 a) (nth 3 op))))
(setq op (car op))
(if (or (equal op "^") (equal op "_"))
(if (= (aref lhs 0) ?-)
(setq lhs (concat "(" lhs ")")))
(setq op (concat " " op " ")))
(concat lhs op rhs))))
((eq (car a) 'neg)
(concat "-" (math-format-flat-expr (nth 1 a) 1000)))
(t
(concat (math-remove-dashes
(if (string-match "\\`calcFunc-\\([a-zA-Zα-ωΑ-Ω0-9']+\\)\\'"
2001-11-06 18:59:06 +00:00
(symbol-name (car a)))
(math-match-substring (symbol-name (car a)) 1)
(symbol-name (car a))))
"("
(math-format-flat-vector (cdr a) ", " 0)
")")))))))
2001-11-06 18:59:06 +00:00
(defun math-format-flat-vector (vec sep prec)
(if vec
(let ((buf (math-format-flat-expr (car vec) prec)))
(while (setq vec (cdr vec))
(setq buf (concat buf sep (math-format-flat-expr (car vec) prec))))
buf)
""))
2001-11-06 18:59:06 +00:00
(defun math-format-nice-expr (x w)
(cond ((and (eq (car-safe x) 'vec)
(cdr (cdr x))
(let ((ops '(vec calcFunc-assign calcFunc-condition
calcFunc-schedule calcFunc-iterations
calcFunc-phase)))
(or (memq (car-safe (nth 1 x)) ops)
(memq (car-safe (nth 2 x)) ops)
(memq (car-safe (nth 3 x)) ops)
calc-break-vectors)))
(concat "[ " (math-format-flat-vector (cdr x) ",\n " 0) " ]"))
(t
(let ((str (math-format-flat-expr x 0))
(pos 0) p)
Use string-search instead of string-match[-p] `string-search` is easier to understand, less error-prone, much faster, does not pollute the regexp cache, and does not mutate global state. Use it where applicable and obviously safe (erring on the conservative side). * admin/authors.el (authors-canonical-file-name) (authors-scan-change-log): * lisp/apropos.el (apropos-command) (apropos-documentation-property, apropos-symbols-internal): * lisp/arc-mode.el (archive-arc-summarize) (archive-zoo-summarize): * lisp/calc/calc-aent.el (math-read-factor): * lisp/calc/calc-ext.el (math-read-big-expr) (math-format-nice-expr, math-format-number-fancy): * lisp/calc/calc-forms.el (math-read-angle-brackets): * lisp/calc/calc-graph.el (calc-graph-set-range): * lisp/calc/calc-keypd.el (calc-keypad-press): * lisp/calc/calc-lang.el (tex, latex, math-read-big-rec): * lisp/calc/calc-prog.el (calc-fix-token-name) (calc-user-define-permanent, math-define-exp): * lisp/calc/calc.el (calc-record, calcDigit-key) (calc-count-lines): * lisp/calc/calcalg2.el (calc-solve-for, calc-poly-roots) (math-do-integral): * lisp/calc/calcalg3.el (calc-find-root, calc-find-minimum) (calc-get-fit-variables): * lisp/cedet/ede/speedbar.el (ede-tag-expand): * lisp/cedet/semantic/java.el (semantic-java-expand-tag): * lisp/cedet/semantic/sb.el (semantic-sb-show-extra) (semantic-sb-expand-group): * lisp/cedet/semantic/wisent/python.el (semantic-python-instance-variable-p): * lisp/cus-edit.el (get): * lisp/descr-text.el (describe-text-sexp): * lisp/dired-aux.el (dired-compress-file): * lisp/dired-x.el (dired-make-relative-symlink): * lisp/dired.el (dired-glob-regexp): * lisp/dos-fns.el (dos-convert-standard-filename, dos-8+3-filename): * lisp/edmacro.el (edmacro-format-keys): * lisp/emacs-lisp/eieio-opt.el (eieio-sb-expand): * lisp/emacs-lisp/eieio-speedbar.el (eieio-speedbar-object-expand): * lisp/emacs-lisp/lisp-mnt.el (lm-keywords-list): * lisp/emacs-lisp/warnings.el (display-warning): * lisp/emulation/viper-ex.el (viper-ex-read-file-name) (ex-print-display-lines): * lisp/env.el (read-envvar-name, setenv): * lisp/epa-mail.el (epa-mail-encrypt): * lisp/epg.el (epg--start): * lisp/erc/erc-backend.el (erc-parse-server-response): * lisp/erc/erc-dcc.el (erc-dcc-member): * lisp/erc/erc-speedbar.el (erc-speedbar-expand-server) (erc-speedbar-expand-channel, erc-speedbar-expand-user): * lisp/erc/erc.el (erc-send-input): * lisp/eshell/em-glob.el (eshell-glob-entries): * lisp/eshell/esh-proc.el (eshell-needs-pipe-p): * lisp/eshell/esh-util.el (eshell-convert): * lisp/eshell/esh-var.el (eshell-envvar-names): * lisp/faces.el (x-resolve-font-name): * lisp/ffap.el (ffap-file-at-point): * lisp/files.el (wildcard-to-regexp, shell-quote-wildcard-pattern): * lisp/forms.el (forms--update): * lisp/frameset.el (frameset-filter-unshelve-param): * lisp/gnus/gnus-art.el (article-decode-charset): * lisp/gnus/gnus-kill.el (gnus-kill-parse-rn-kill-file): * lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy): * lisp/gnus/gnus-msg.el (gnus-summary-resend-message-insert-gcc) (gnus-inews-insert-gcc): * lisp/gnus/gnus-rfc1843.el (rfc1843-decode-article-body): * lisp/gnus/gnus-search.el (gnus-search-indexed-parse-output) (gnus-search--complete-key-data): * lisp/gnus/gnus-spec.el (gnus-parse-simple-format): * lisp/gnus/gnus-sum.el (gnus-summary-refer-article): * lisp/gnus/gnus-util.el (gnus-extract-address-components) (gnus-newsgroup-directory-form): * lisp/gnus/gnus-uu.el (gnus-uu-grab-view): * lisp/gnus/gnus.el (gnus-group-native-p, gnus-short-group-name): * lisp/gnus/message.el (message-check-news-header-syntax) (message-make-message-id, message-user-mail-address) (message-make-fqdn, message-get-reply-headers, message-followup): * lisp/gnus/mm-decode.el (mm-dissect-buffer): * lisp/gnus/nnheader.el (nnheader-insert): * lisp/gnus/nnimap.el (nnimap-process-quirk) (nnimap-imap-ranges-to-gnus-ranges): * lisp/gnus/nnmaildir.el (nnmaildir--ensure-suffix): * lisp/gnus/nnmairix.el (nnmairix-determine-original-group-from-path): * lisp/gnus/nnrss.el (nnrss-match-macro): * lisp/gnus/nntp.el (nntp-find-group-and-number): * lisp/help-fns.el (help--symbol-completion-table-affixation): * lisp/help.el (help-function-arglist): * lisp/hippie-exp.el (he-concat-directory-file-name): * lisp/htmlfontify.el (hfy-relstub): * lisp/ido.el (ido-make-prompt, ido-complete, ido-copy-current-word) (ido-exhibit): * lisp/image/image-converter.el (image-convert-p): * lisp/info-xref.el (info-xref-docstrings): * lisp/info.el (Info-toc-build, Info-follow-reference) (Info-backward-node, Info-finder-find-node) (Info-speedbar-expand-node): * lisp/international/mule-diag.el (print-fontset-element): * lisp/language/korea-util.el (default-korean-keyboard): * lisp/linum.el (linum-after-change): * lisp/mail/ietf-drums.el (ietf-drums-parse-address): * lisp/mail/mail-utils.el (mail-dont-reply-to): * lisp/mail/rfc2047.el (rfc2047-encode-1, rfc2047-decode-string): * lisp/mail/rfc2231.el (rfc2231-parse-string): * lisp/mail/rmailkwd.el (rmail-set-label): * lisp/mail/rmailsum.el (rmail-header-summary): * lisp/mail/smtpmail.el (smtpmail-maybe-append-domain) (smtpmail-user-mail-address): * lisp/mail/uce.el (uce-reply-to-uce): * lisp/man.el (Man-default-man-entry): * lisp/mh-e/mh-alias.el (mh-alias-gecos-name) (mh-alias-minibuffer-confirm-address): * lisp/mh-e/mh-comp.el (mh-forwarded-letter-subject): * lisp/mh-e/mh-speed.el (mh-speed-parse-flists-output): * lisp/mh-e/mh-utils.el (mh-collect-folder-names-filter) (mh-folder-completion-function): * lisp/minibuffer.el (completion--make-envvar-table) (completion-file-name-table, completion-flex-try-completion) (completion-flex-all-completions): * lisp/mpc.el (mpc--proc-quote-string, mpc-cmd-special-tag-p) (mpc-constraints-tag-lookup): * lisp/net/ange-ftp.el (ange-ftp-send-cmd) (ange-ftp-allow-child-lookup): * lisp/net/mailcap.el (mailcap-mime-types): * lisp/net/mairix.el (mairix-search-thread-this-article): * lisp/net/pop3.el (pop3-open-server): * lisp/net/soap-client.el (soap-decode-xs-complex-type): * lisp/net/socks.el (socks-filter): * lisp/nxml/nxml-outln.el (nxml-highlighted-qname): * lisp/nxml/rng-cmpct.el (rng-c-expand-name, rng-c-expand-datatype): * lisp/nxml/rng-uri.el (rng-uri-file-name-1): * lisp/obsolete/complete.el (partial-completion-mode) (PC-do-completion): * lisp/obsolete/longlines.el (longlines-encode-string): * lisp/obsolete/nnir.el (nnir-compose-result): * lisp/obsolete/terminal.el (te-quote-arg-for-sh): * lisp/obsolete/tpu-edt.el (tpu-check-search-case): * lisp/obsolete/url-ns.el (isPlainHostName): * lisp/pcmpl-unix.el (pcomplete/scp): * lisp/play/dunnet.el (dun-listify-string2, dun-get-path) (dun-unix-parse, dun-doassign, dun-cat, dun-batch-unix-interface): * lisp/progmodes/ebnf2ps.el: (ebnf-eps-header-footer-comment): * lisp/progmodes/gdb-mi.el (gdb-var-delete) (gdb-speedbar-expand-node, gdbmi-bnf-incomplete-record-result): * lisp/progmodes/gud.el (gud-find-expr): * lisp/progmodes/idlw-help.el (idlwave-do-context-help1): * lisp/progmodes/idlw-shell.el (idlwave-shell-mode) (idlwave-shell-filter-hidden-output, idlwave-shell-filter): * lisp/progmodes/idlwave.el (idlwave-skip-label-or-case) (idlwave-routine-info): * lisp/progmodes/octave.el (inferior-octave-completion-at-point): * lisp/progmodes/sh-script.el (sh-add-completer): * lisp/progmodes/sql.el (defun): * lisp/progmodes/xscheme.el (xscheme-process-filter): * lisp/replace.el (query-replace-compile-replacement) (map-query-replace-regexp): * lisp/shell.el (shell--command-completion-data) (shell-environment-variable-completion): * lisp/simple.el (display-message-or-buffer): * lisp/speedbar.el (speedbar-dired, speedbar-tag-file) (speedbar-tag-expand): * lisp/subr.el (split-string-and-unquote): * lisp/tar-mode.el (tar-extract): * lisp/term.el (term-command-hook, serial-read-name): * lisp/textmodes/bibtex.el (bibtex-print-help-message): * lisp/textmodes/ispell.el (ispell-lookup-words, ispell-filter) (ispell-parse-output, ispell-buffer-local-parsing): * lisp/textmodes/reftex-cite.el (reftex-do-citation): * lisp/textmodes/reftex-parse.el (reftex-notice-new): * lisp/textmodes/reftex-ref.el (reftex-show-entry): * lisp/textmodes/reftex.el (reftex-compile-variables): * lisp/textmodes/tex-mode.el (tex-send-command) (tex-start-tex, tex-append): * lisp/thingatpt.el (thing-at-point-url-at-point): * lisp/tmm.el (tmm-add-one-shortcut): * lisp/transient.el (transient-format-key): * lisp/url/url-auth.el (url-basic-auth) (url-digest-auth-directory-id-assoc): * lisp/url/url-news.el (url-news): * lisp/url/url-util.el (url-parse-query-string): * lisp/vc/vc-cvs.el (vc-cvs-parse-entry): * lisp/wid-browse.el (widget-browse-sexp): * lisp/woman.el (woman-parse-colon-path, woman-mini-help) (WoMan-getpage-in-background, woman-negative-vertical-space): * lisp/xml.el: * test/lisp/emacs-lisp/check-declare-tests.el (check-declare-tests-warn): * test/lisp/files-tests.el (files-tests-file-name-non-special-dired-compress-handler): * test/lisp/net/network-stream-tests.el (server-process-filter): * test/src/coding-tests.el (ert-test-unibyte-buffer-dos-eol-decode): Use `string-search` instead of `string-match` and `string-match-p`.
2021-08-09 11:20:00 +02:00
(or (string-search "\"" str)
2001-11-06 18:59:06 +00:00
(while (<= (setq p (+ pos w)) (length str))
(while (and (> (setq p (1- p)) pos)
(not (= (aref str p) ? ))))
(if (> p (+ pos 5))
(setq str (concat (substring str 0 p)
"\n "
(substring str p))
pos (1+ p))
(setq pos (+ pos w)))))
str))))
2001-11-06 18:59:06 +00:00
(defun math-assq2 (v a)
(while (and a (not (eq v (nth 1 (car a)))))
(setq a (cdr a)))
(car a))
2001-11-06 18:59:06 +00:00
(defun math-format-number-fancy (a prec)
(cond
((eq (car a) 'float) ; non-decimal radix
(if (Math-integer-negp (nth 1 a))
(concat "-" (math-format-number (math-neg a)))
(let ((str (if (and calc-radix-formatter
(not (memq calc-language '(c pascal))))
(funcall calc-radix-formatter
calc-number-radix
(math-format-radix-float a prec))
(format "%d#%s" calc-number-radix
(math-format-radix-float a prec)))))
Use string-search instead of string-match[-p] `string-search` is easier to understand, less error-prone, much faster, does not pollute the regexp cache, and does not mutate global state. Use it where applicable and obviously safe (erring on the conservative side). * admin/authors.el (authors-canonical-file-name) (authors-scan-change-log): * lisp/apropos.el (apropos-command) (apropos-documentation-property, apropos-symbols-internal): * lisp/arc-mode.el (archive-arc-summarize) (archive-zoo-summarize): * lisp/calc/calc-aent.el (math-read-factor): * lisp/calc/calc-ext.el (math-read-big-expr) (math-format-nice-expr, math-format-number-fancy): * lisp/calc/calc-forms.el (math-read-angle-brackets): * lisp/calc/calc-graph.el (calc-graph-set-range): * lisp/calc/calc-keypd.el (calc-keypad-press): * lisp/calc/calc-lang.el (tex, latex, math-read-big-rec): * lisp/calc/calc-prog.el (calc-fix-token-name) (calc-user-define-permanent, math-define-exp): * lisp/calc/calc.el (calc-record, calcDigit-key) (calc-count-lines): * lisp/calc/calcalg2.el (calc-solve-for, calc-poly-roots) (math-do-integral): * lisp/calc/calcalg3.el (calc-find-root, calc-find-minimum) (calc-get-fit-variables): * lisp/cedet/ede/speedbar.el (ede-tag-expand): * lisp/cedet/semantic/java.el (semantic-java-expand-tag): * lisp/cedet/semantic/sb.el (semantic-sb-show-extra) (semantic-sb-expand-group): * lisp/cedet/semantic/wisent/python.el (semantic-python-instance-variable-p): * lisp/cus-edit.el (get): * lisp/descr-text.el (describe-text-sexp): * lisp/dired-aux.el (dired-compress-file): * lisp/dired-x.el (dired-make-relative-symlink): * lisp/dired.el (dired-glob-regexp): * lisp/dos-fns.el (dos-convert-standard-filename, dos-8+3-filename): * lisp/edmacro.el (edmacro-format-keys): * lisp/emacs-lisp/eieio-opt.el (eieio-sb-expand): * lisp/emacs-lisp/eieio-speedbar.el (eieio-speedbar-object-expand): * lisp/emacs-lisp/lisp-mnt.el (lm-keywords-list): * lisp/emacs-lisp/warnings.el (display-warning): * lisp/emulation/viper-ex.el (viper-ex-read-file-name) (ex-print-display-lines): * lisp/env.el (read-envvar-name, setenv): * lisp/epa-mail.el (epa-mail-encrypt): * lisp/epg.el (epg--start): * lisp/erc/erc-backend.el (erc-parse-server-response): * lisp/erc/erc-dcc.el (erc-dcc-member): * lisp/erc/erc-speedbar.el (erc-speedbar-expand-server) (erc-speedbar-expand-channel, erc-speedbar-expand-user): * lisp/erc/erc.el (erc-send-input): * lisp/eshell/em-glob.el (eshell-glob-entries): * lisp/eshell/esh-proc.el (eshell-needs-pipe-p): * lisp/eshell/esh-util.el (eshell-convert): * lisp/eshell/esh-var.el (eshell-envvar-names): * lisp/faces.el (x-resolve-font-name): * lisp/ffap.el (ffap-file-at-point): * lisp/files.el (wildcard-to-regexp, shell-quote-wildcard-pattern): * lisp/forms.el (forms--update): * lisp/frameset.el (frameset-filter-unshelve-param): * lisp/gnus/gnus-art.el (article-decode-charset): * lisp/gnus/gnus-kill.el (gnus-kill-parse-rn-kill-file): * lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy): * lisp/gnus/gnus-msg.el (gnus-summary-resend-message-insert-gcc) (gnus-inews-insert-gcc): * lisp/gnus/gnus-rfc1843.el (rfc1843-decode-article-body): * lisp/gnus/gnus-search.el (gnus-search-indexed-parse-output) (gnus-search--complete-key-data): * lisp/gnus/gnus-spec.el (gnus-parse-simple-format): * lisp/gnus/gnus-sum.el (gnus-summary-refer-article): * lisp/gnus/gnus-util.el (gnus-extract-address-components) (gnus-newsgroup-directory-form): * lisp/gnus/gnus-uu.el (gnus-uu-grab-view): * lisp/gnus/gnus.el (gnus-group-native-p, gnus-short-group-name): * lisp/gnus/message.el (message-check-news-header-syntax) (message-make-message-id, message-user-mail-address) (message-make-fqdn, message-get-reply-headers, message-followup): * lisp/gnus/mm-decode.el (mm-dissect-buffer): * lisp/gnus/nnheader.el (nnheader-insert): * lisp/gnus/nnimap.el (nnimap-process-quirk) (nnimap-imap-ranges-to-gnus-ranges): * lisp/gnus/nnmaildir.el (nnmaildir--ensure-suffix): * lisp/gnus/nnmairix.el (nnmairix-determine-original-group-from-path): * lisp/gnus/nnrss.el (nnrss-match-macro): * lisp/gnus/nntp.el (nntp-find-group-and-number): * lisp/help-fns.el (help--symbol-completion-table-affixation): * lisp/help.el (help-function-arglist): * lisp/hippie-exp.el (he-concat-directory-file-name): * lisp/htmlfontify.el (hfy-relstub): * lisp/ido.el (ido-make-prompt, ido-complete, ido-copy-current-word) (ido-exhibit): * lisp/image/image-converter.el (image-convert-p): * lisp/info-xref.el (info-xref-docstrings): * lisp/info.el (Info-toc-build, Info-follow-reference) (Info-backward-node, Info-finder-find-node) (Info-speedbar-expand-node): * lisp/international/mule-diag.el (print-fontset-element): * lisp/language/korea-util.el (default-korean-keyboard): * lisp/linum.el (linum-after-change): * lisp/mail/ietf-drums.el (ietf-drums-parse-address): * lisp/mail/mail-utils.el (mail-dont-reply-to): * lisp/mail/rfc2047.el (rfc2047-encode-1, rfc2047-decode-string): * lisp/mail/rfc2231.el (rfc2231-parse-string): * lisp/mail/rmailkwd.el (rmail-set-label): * lisp/mail/rmailsum.el (rmail-header-summary): * lisp/mail/smtpmail.el (smtpmail-maybe-append-domain) (smtpmail-user-mail-address): * lisp/mail/uce.el (uce-reply-to-uce): * lisp/man.el (Man-default-man-entry): * lisp/mh-e/mh-alias.el (mh-alias-gecos-name) (mh-alias-minibuffer-confirm-address): * lisp/mh-e/mh-comp.el (mh-forwarded-letter-subject): * lisp/mh-e/mh-speed.el (mh-speed-parse-flists-output): * lisp/mh-e/mh-utils.el (mh-collect-folder-names-filter) (mh-folder-completion-function): * lisp/minibuffer.el (completion--make-envvar-table) (completion-file-name-table, completion-flex-try-completion) (completion-flex-all-completions): * lisp/mpc.el (mpc--proc-quote-string, mpc-cmd-special-tag-p) (mpc-constraints-tag-lookup): * lisp/net/ange-ftp.el (ange-ftp-send-cmd) (ange-ftp-allow-child-lookup): * lisp/net/mailcap.el (mailcap-mime-types): * lisp/net/mairix.el (mairix-search-thread-this-article): * lisp/net/pop3.el (pop3-open-server): * lisp/net/soap-client.el (soap-decode-xs-complex-type): * lisp/net/socks.el (socks-filter): * lisp/nxml/nxml-outln.el (nxml-highlighted-qname): * lisp/nxml/rng-cmpct.el (rng-c-expand-name, rng-c-expand-datatype): * lisp/nxml/rng-uri.el (rng-uri-file-name-1): * lisp/obsolete/complete.el (partial-completion-mode) (PC-do-completion): * lisp/obsolete/longlines.el (longlines-encode-string): * lisp/obsolete/nnir.el (nnir-compose-result): * lisp/obsolete/terminal.el (te-quote-arg-for-sh): * lisp/obsolete/tpu-edt.el (tpu-check-search-case): * lisp/obsolete/url-ns.el (isPlainHostName): * lisp/pcmpl-unix.el (pcomplete/scp): * lisp/play/dunnet.el (dun-listify-string2, dun-get-path) (dun-unix-parse, dun-doassign, dun-cat, dun-batch-unix-interface): * lisp/progmodes/ebnf2ps.el: (ebnf-eps-header-footer-comment): * lisp/progmodes/gdb-mi.el (gdb-var-delete) (gdb-speedbar-expand-node, gdbmi-bnf-incomplete-record-result): * lisp/progmodes/gud.el (gud-find-expr): * lisp/progmodes/idlw-help.el (idlwave-do-context-help1): * lisp/progmodes/idlw-shell.el (idlwave-shell-mode) (idlwave-shell-filter-hidden-output, idlwave-shell-filter): * lisp/progmodes/idlwave.el (idlwave-skip-label-or-case) (idlwave-routine-info): * lisp/progmodes/octave.el (inferior-octave-completion-at-point): * lisp/progmodes/sh-script.el (sh-add-completer): * lisp/progmodes/sql.el (defun): * lisp/progmodes/xscheme.el (xscheme-process-filter): * lisp/replace.el (query-replace-compile-replacement) (map-query-replace-regexp): * lisp/shell.el (shell--command-completion-data) (shell-environment-variable-completion): * lisp/simple.el (display-message-or-buffer): * lisp/speedbar.el (speedbar-dired, speedbar-tag-file) (speedbar-tag-expand): * lisp/subr.el (split-string-and-unquote): * lisp/tar-mode.el (tar-extract): * lisp/term.el (term-command-hook, serial-read-name): * lisp/textmodes/bibtex.el (bibtex-print-help-message): * lisp/textmodes/ispell.el (ispell-lookup-words, ispell-filter) (ispell-parse-output, ispell-buffer-local-parsing): * lisp/textmodes/reftex-cite.el (reftex-do-citation): * lisp/textmodes/reftex-parse.el (reftex-notice-new): * lisp/textmodes/reftex-ref.el (reftex-show-entry): * lisp/textmodes/reftex.el (reftex-compile-variables): * lisp/textmodes/tex-mode.el (tex-send-command) (tex-start-tex, tex-append): * lisp/thingatpt.el (thing-at-point-url-at-point): * lisp/tmm.el (tmm-add-one-shortcut): * lisp/transient.el (transient-format-key): * lisp/url/url-auth.el (url-basic-auth) (url-digest-auth-directory-id-assoc): * lisp/url/url-news.el (url-news): * lisp/url/url-util.el (url-parse-query-string): * lisp/vc/vc-cvs.el (vc-cvs-parse-entry): * lisp/wid-browse.el (widget-browse-sexp): * lisp/woman.el (woman-parse-colon-path, woman-mini-help) (WoMan-getpage-in-background, woman-negative-vertical-space): * lisp/xml.el: * test/lisp/emacs-lisp/check-declare-tests.el (check-declare-tests-warn): * test/lisp/files-tests.el (files-tests-file-name-non-special-dired-compress-handler): * test/lisp/net/network-stream-tests.el (server-process-filter): * test/src/coding-tests.el (ert-test-unibyte-buffer-dos-eol-decode): Use `string-search` instead of `string-match` and `string-match-p`.
2021-08-09 11:20:00 +02:00
(if (and prec (> prec 191) (string-search "*" str))
2001-11-06 18:59:06 +00:00
(concat "(" str ")")
str))))
((eq (car a) 'frac)
(setq a (math-adjust-fraction a))
(if (> (length (car calc-frac-format)) 1)
(if (Math-integer-negp (nth 1 a))
(concat "-" (math-format-number (math-neg a)))
(let ((q (math-idivmod (nth 1 a) (nth 2 a))))
(concat (let ((calc-frac-format nil))
(math-format-number (car q)))
(substring (car calc-frac-format) 0 1)
(let ((math-radix-explicit-format nil)
(calc-frac-format nil))
(math-format-number (cdr q)))
(substring (car calc-frac-format) 1 2)
(let ((math-radix-explicit-format nil)
(calc-frac-format nil))
(math-format-number (nth 2 a))))))
(concat (let ((calc-frac-format nil))
(math-format-number (nth 1 a)))
(car calc-frac-format)
(let ((math-radix-explicit-format nil)
(calc-frac-format nil))
(math-format-number (nth 2 a))))))
((eq (car a) 'cplx)
(if (math-zerop (nth 2 a))
(math-format-number (nth 1 a))
(if (null calc-complex-format)
(concat "(" (math-format-number (nth 1 a))
", " (math-format-number (nth 2 a)) ")")
(if (math-zerop (nth 1 a))
(if (math-equal-int (nth 2 a) 1)
(symbol-name calc-complex-format)
(if (math-equal-int (nth 2 a) -1)
(concat "-" (symbol-name calc-complex-format))
(if prec
(math-compose-expr (list '* (nth 2 a) '(cplx 0 1)) prec)
(concat (math-format-number (nth 2 a)) " "
(symbol-name calc-complex-format)))))
(if prec
(math-compose-expr (list (if (math-negp (nth 2 a)) '- '+)
(nth 1 a)
(list 'cplx 0 (math-abs (nth 2 a))))
prec)
(concat (math-format-number (nth 1 a))
(if (math-negp (nth 2 a)) " - " " + ")
(math-format-number
(list 'cplx 0 (math-abs (nth 2 a))))))))))
((eq (car a) 'polar)
(concat "(" (math-format-number (nth 1 a))
"; " (math-format-number (nth 2 a)) ")"))
((eq (car a) 'hms)
(if (math-negp a)
(concat "-" (math-format-number (math-neg a)))
(let ((calc-number-radix 10)
(calc-twos-complement-mode nil)
2001-11-06 18:59:06 +00:00
(calc-leading-zeros nil)
(calc-group-digits nil))
(format calc-hms-format
(let ((calc-frac-format '(":" nil)))
(math-format-number (nth 1 a)))
(let ((calc-frac-format '(":" nil)))
(math-format-number (nth 2 a)))
(math-format-number (nth 3 a))))))
((eq (car a) 'intv)
(concat (if (memq (nth 1 a) '(0 1)) "(" "[")
(math-format-number (nth 2 a))
" .. "
(math-format-number (nth 3 a))
(if (memq (nth 1 a) '(0 2)) ")" "]")))
((eq (car a) 'sdev)
(concat (math-format-number (nth 1 a))
" +/- "
(math-format-number (nth 2 a))))
((eq (car a) 'vec)
(math-format-flat-expr a 0))
(t (format "%s" a))))
2001-11-06 18:59:06 +00:00
(defun math-adjust-fraction (a)
(if (nth 1 calc-frac-format)
(progn
(if (Math-integerp a) (setq a (list 'frac a 1)))
(let ((g (math-quotient (nth 1 calc-frac-format)
(math-gcd (nth 2 a)
(nth 1 calc-frac-format)))))
(list 'frac (math-mul (nth 1 a) g) (math-mul (nth 2 a) g))))
a))
2001-11-06 18:59:06 +00:00
* lisp/calc/calc.el: Take advantage of native bignums. Remove redundant :group args. (calc-trail-mode): Use inhibit-read-only. (math-bignum-digit-length, math-bignum-digit-size) (math-small-integer-size): Delete constants. (math-normalize): Use native bignums. (math-bignum, math-bignum-big): Delete functions. (math-make-float): The mantissa can't be a calc bignum any more. (math-neg, math-scale-left, math-scale-right, math-scale-rounding) (math-add, math-sub, math-mul, math-idivmod, math-quotient) (math-format-number, math-read-number, math-read-number-simple): Don't bother handling calc bignums. (math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum) (math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit) (math-div-bignum, math-div-bignum-digit, math-div-bignum-big) (math-div-bignum-part, math-div-bignum-try, math-format-bignum) (math-format-bignum-decimal, math-read-bignum): Delete functions. (math-numdigs): Don't presume that native ints are small enough to use a slow algorithm. * lisp/calc/calc-aent.el (calc-do-quick-calc): * lisp/calc/calc-vec.el (calcFunc-vunpack): * lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums. * lisp/calc/calc-bin.el (math-bignum-logb-digit-size) (math-bignum-digit-power-of-two): Remove constants. (calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor) (calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement): Use Emacs's builtin bignums. (math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum) (math-not-bignum, math-clip-bignum) (math-format-bignum-radix, math-format-bignum-binary) (math-format-bignum-octal, math-format-bignum-hex): Delete functions. (math-format-binary): Fix old copy&paste error. * lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg. (math-prime-test): math-fixnum is now the identity. * lisp/calc/calc-ext.el: Require cl-lib. (math-oddp): Use cl-oddp. Don't bother with calc bignums. (math-integerp, math-natnump, math-ratp, math-realp, math-anglep) (math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp) (math-num-natnump, math-objectp, math-check-integer, math-compare): Don't bother handling calc bignums. (math-check-fixnum): Use fixnump. (math-fixnum, math-fixnum-big, math-bignum-test): Remove functions. (math--format-integer-fancy): Rename from math-format-bignum-fancy. Adjust for internal bignums. * lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt. * lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp) (Math-integer-posp, Math-negp, Math-posp, Math-integerp) (Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp) (Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp) (Math-integer-neg, Math-primp, Math-num-integerp): Don't bother handling calc bignums. (Math-bignum-test): Delete function. * lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`. (math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums. (math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small): Delete function. * lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump. (math-evenp): Use cl-evenp. (math-zerop, math-negp, math-posp, math-div2): Don't bother handling calc bignums. (math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
(defun math--format-integer-fancy (a) ; [I]
(let ((str (if (= calc-number-radix 10)
(number-to-string a)
(math-format-radix a))))
2001-11-06 18:59:06 +00:00
(if calc-leading-zeros
(let* ((calc-internal-prec 6)
(digs (math-compute-max-digits (math-abs calc-word-size)
calc-number-radix))
(len (length str)))
(if (< len digs)
(setq str (concat (make-string (- digs len) ?0) str)))))
(if calc-group-digits
(let ((i (length str))
(g (if (integerp calc-group-digits)
(math-abs calc-group-digits)
(if (memq calc-number-radix '(2 16)) 4 3))))
(while (> i g)
(setq i (- i g)
str (concat (substring str 0 i)
calc-group-char
(substring str i))))
str))
(if (and (/= calc-number-radix 10)
math-radix-explicit-format)
(if calc-radix-formatter
(funcall calc-radix-formatter calc-number-radix str)
(format "%d#%s" calc-number-radix str))
str)))
2001-11-06 18:59:06 +00:00
(defun math-group-float (str) ; [X X]
(let* ((pt (or (string-match "[^0-9a-zA-Z]" str) (length str)))
(g (if (integerp calc-group-digits) (math-abs calc-group-digits)
(if (memq calc-number-radix '(2 16)) 4 3)))
2001-11-06 18:59:06 +00:00
(i pt))
(if (and (integerp calc-group-digits) (< calc-group-digits 0))
(while (< (setq i (+ (1+ i) g)) (length str))
(setq str (concat (substring str 0 i)
calc-group-char
(substring str i))
i (+ i (1- (length calc-group-char))))))
(setq i pt)
(while (> i g)
(setq i (- i g)
str (concat (substring str 0 i)
calc-group-char
(substring str i))))
str))
2001-11-06 18:59:06 +00:00
Update docstrings and comments to use "init file" terminology. * bookmark.el (bookmark-bmenu-toggle-filenames): Doc fixes. * comint.el (comint-prompt-read-only): * custom.el (defcustom): * hi-lock.el (hi-lock-mode): * ibuffer.el (ibuffer-formats): * ielm.el (ielm-prompt-read-only): * novice.el (disable-command): * saveplace.el (toggle-save-place): * speedbar.el (speedbar-supported-extension-expressions): * startup.el (auto-save-list-file-prefix, init-file-user) (after-init-hook, inhibit-startup-echo-area-message): * strokes.el (strokes-help): * time-stamp.el (time-stamp): * calendar/calendar.el (calendar, diary-file): * calendar/diary-lib.el (diary-mail-entries, diary) (diary-list-entries-hook): * calendar/holidays.el (holidays, calendar-holidays): * calendar/lunar.el (lunar-phases): * calendar/solar.el (sunrise-sunset): * emulation/edt.el (edt-load-keys): * emulation/viper.el (viper-mode): * eshell/em-alias.el (eshell-command-aliases-list): * eshell/esh-util.el (eshell-convert-numeric-arguments): * international/ogonek.el (ogonek-information): * net/tramp-cmds.el (tramp-bug): * net/quickurl.el (quickurl-reread-hook-postfix): * play/decipher.el (decipher-font-lock-keywords): * progmodes/cc-styles.el (c-set-style): * progmodes/idlw-shell.el (idlwave-shell-prompt-pattern): * progmodes/inf-lisp.el (inferior-lisp-prompt): * progmodes/octave-mod.el (octave-mode): * progmodes/sql.el (sql-mode, sql-interactive-mode, sql-password): * progmodes/verilog-mode.el (verilog-read-defines): * textmodes/two-column.el (2C-mode): Likewise.
2012-09-17 13:41:04 +08:00
;;; Users can redefine this in their init files.
2001-11-06 18:59:06 +00:00
(defvar calc-keypad-user-menu nil
"If non-nil, this describes an additional menu for `calc-keypad'.
2001-11-06 18:59:06 +00:00
It should contain a list of three rows.
Each row should be a list of six keys.
Each key should be a list of a label string, plus a Calc command name spec.
A command spec is a command name symbol, a keyboard macro string, a
list containing a numeric entry string, or nil.
A key may contain additional specs for Inverse, Hyperbolic, and Inv+Hyp.")
(make-obsolete-variable 'calc-ext-load-hook
"use `with-eval-after-load' instead." "28.1")
2001-11-06 18:59:06 +00:00
(run-hooks 'calc-ext-load-hook)
(provide 'calc-ext)
;;; calc-ext.el ends here