2020-10-10 16:00:51 -04:00
|
|
|
;;; calc-misc.el --- miscellaneous functions for Calc -*- lexical-binding:t -*-
|
2001-11-19 07:36:42 +00:00
|
|
|
|
2021-01-01 01:13:56 -08:00
|
|
|
;; Copyright (C) 1990-1993, 2001-2021 Free Software Foundation, Inc.
|
2001-11-19 07:36:42 +00:00
|
|
|
|
|
|
|
;; Author: David Gillespie <daveg@synaptics.com>
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 03:16:00 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2007-03-19 20:59:53 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 03:16:00 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
2007-03-19 20:59:53 +00:00
|
|
|
|
2001-11-06 18:59:06 +00:00
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
2007-03-19 20:59:53 +00:00
|
|
|
;; 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
|
2017-09-13 15:52:52 -07:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2001-11-19 07:36:42 +00:00
|
|
|
;;; Commentary:
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2001-11-19 07:36:42 +00:00
|
|
|
;;; Code:
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
;; This file is autoloaded from calc.el.
|
|
|
|
|
2004-11-30 17:17:35 +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
|
|
|
|
(calc-do-keypad, calc-inv-hyp-prefix-help)
(calc-inverse-prefix-help, calc-hyperbolic-prefix-help)
(calc-explain-why, calc-clear-command-flag)
(calc-roll-down-with-selections, calc-roll-up-with-selections)
(calc-last-args, calc-is-inverse, calc-do-prefix-help)
(math-objvecp, math-known-scalarp, math-vectorp, math-matrixp)
(math-trunc-special, math-trunc-fancy, math-floor-special)
(math-floor-fancy, math-square-matrixp, math-matrix-inv-raw)
(math-known-matrixp, math-mod-fancy, math-pow-of-zero)
(math-pow-zero, math-pow-fancy): Declare as functions.
2007-11-27 04:06:31 +00:00
|
|
|
;; Declare functions which are defined elsewhere.
|
|
|
|
(declare-function calc-do-keypad "calc-keypd" (&optional full-display interactive))
|
|
|
|
(declare-function calc-inv-hyp-prefix-help "calc-help" ())
|
|
|
|
(declare-function calc-inverse-prefix-help "calc-help" ())
|
|
|
|
(declare-function calc-hyperbolic-prefix-help "calc-help" ())
|
2010-04-16 21:47:25 -05:00
|
|
|
(declare-function calc-option-prefix-help "calc-help" ())
|
(calc-do-keypad, calc-inv-hyp-prefix-help)
(calc-inverse-prefix-help, calc-hyperbolic-prefix-help)
(calc-explain-why, calc-clear-command-flag)
(calc-roll-down-with-selections, calc-roll-up-with-selections)
(calc-last-args, calc-is-inverse, calc-do-prefix-help)
(math-objvecp, math-known-scalarp, math-vectorp, math-matrixp)
(math-trunc-special, math-trunc-fancy, math-floor-special)
(math-floor-fancy, math-square-matrixp, math-matrix-inv-raw)
(math-known-matrixp, math-mod-fancy, math-pow-of-zero)
(math-pow-zero, math-pow-fancy): Declare as functions.
2007-11-27 04:06:31 +00:00
|
|
|
(declare-function calc-explain-why "calc-stuff" (why &optional more))
|
|
|
|
(declare-function calc-clear-command-flag "calc-ext" (f))
|
|
|
|
(declare-function calc-roll-down-with-selections "calc-sel" (n m))
|
|
|
|
(declare-function calc-roll-up-with-selections "calc-sel" (n m))
|
|
|
|
(declare-function calc-last-args "calc-undo" (n))
|
|
|
|
(declare-function calc-is-inverse "calc-ext" ())
|
|
|
|
(declare-function calc-do-prefix-help "calc-ext" (msgs group key))
|
|
|
|
(declare-function math-objvecp "calc-ext" (a))
|
|
|
|
(declare-function math-known-scalarp "calc-arith" (a &optional assume-scalar))
|
|
|
|
(declare-function math-vectorp "calc-ext" (a))
|
|
|
|
(declare-function math-matrixp "calc-ext" (a))
|
|
|
|
(declare-function math-trunc-special "calc-arith" (a prec))
|
|
|
|
(declare-function math-trunc-fancy "calc-arith" (a))
|
|
|
|
(declare-function math-floor-special "calc-arith" (a prec))
|
|
|
|
(declare-function math-floor-fancy "calc-arith" (a))
|
|
|
|
(declare-function math-square-matrixp "calc-ext" (a))
|
|
|
|
(declare-function math-matrix-inv-raw "calc-mtx" (m))
|
|
|
|
(declare-function math-known-matrixp "calc-arith" (a))
|
|
|
|
(declare-function math-mod-fancy "calc-arith" (a b))
|
|
|
|
(declare-function math-pow-of-zero "calc-arith" (a b))
|
|
|
|
(declare-function math-pow-zero "calc-arith" (a b))
|
|
|
|
(declare-function math-pow-fancy "calc-arith" (a b))
|
2009-07-29 03:42:19 +00:00
|
|
|
(declare-function calc-locate-cursor-element "calc-yank" (pt))
|
(calc-do-keypad, calc-inv-hyp-prefix-help)
(calc-inverse-prefix-help, calc-hyperbolic-prefix-help)
(calc-explain-why, calc-clear-command-flag)
(calc-roll-down-with-selections, calc-roll-up-with-selections)
(calc-last-args, calc-is-inverse, calc-do-prefix-help)
(math-objvecp, math-known-scalarp, math-vectorp, math-matrixp)
(math-trunc-special, math-trunc-fancy, math-floor-special)
(math-floor-fancy, math-square-matrixp, math-matrix-inv-raw)
(math-known-matrixp, math-mod-fancy, math-pow-of-zero)
(math-pow-zero, math-pow-fancy): Declare as functions.
2007-11-27 04:06:31 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-dispatch-help (arg)
|
2005-11-28 22:13:37 +00:00
|
|
|
"C-x* is a prefix key sequence; follow it with one of these letters:
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
For turning Calc on and off:
|
|
|
|
C calc. Start the Calculator in a window at the bottom of the screen.
|
|
|
|
O calc-other-window. Start the Calculator but don't select its window.
|
|
|
|
B calc-big-or-small. Control whether to use the full Emacs screen for Calc.
|
|
|
|
Q quick-calc. Use the Calculator in the minibuffer.
|
|
|
|
K calc-keypad. Start the Calculator in keypad mode (X window system only).
|
|
|
|
E calc-embedded. Use the Calculator on a formula in this editing buffer.
|
|
|
|
J calc-embedded-select. Like E, but select appropriate half of => or :=.
|
|
|
|
W calc-embedded-word. Like E, but activate a single word, i.e., a number.
|
|
|
|
Z calc-user-invocation. Invoke Calc in the way you defined with `Z I' cmd.
|
|
|
|
X calc-quit. Turn Calc off.
|
|
|
|
|
|
|
|
For moving data into and out of Calc:
|
|
|
|
G calc-grab-region. Grab the region defined by mark and point into Calc.
|
|
|
|
R calc-grab-rectangle. Grab the rectangle defined by mark, point into Calc.
|
|
|
|
: calc-grab-sum-down. Grab a rectangle and sum the columns.
|
|
|
|
_ calc-grab-sum-across. Grab a rectangle and sum the rows.
|
|
|
|
Y calc-copy-to-buffer. Copy a value from the stack into the editing buffer.
|
|
|
|
|
|
|
|
For use with Embedded mode:
|
|
|
|
A calc-embedded-activate. Find and activate all :='s and =>'s in buffer.
|
|
|
|
D calc-embedded-duplicate. Make a copy of this formula and select it.
|
|
|
|
F calc-embedded-new-formula. Insert a new formula at current point.
|
|
|
|
N calc-embedded-next. Advance cursor to next known formula in buffer.
|
|
|
|
P calc-embedded-previous. Advance cursor to previous known formula.
|
|
|
|
U calc-embedded-update-formula. Re-evaluate formula at point.
|
2015-05-28 00:06:14 -07:00
|
|
|
\\=` calc-embedded-edit. Use calc-edit to edit formula at point.
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
Documentation:
|
|
|
|
I calc-info. Read the Calculator manual in the Emacs Info system.
|
|
|
|
T calc-tutorial. Run the Calculator Tutorial using the Emacs Info system.
|
|
|
|
S calc-summary. Read the Summary from the Calculator manual in Info.
|
|
|
|
|
|
|
|
Miscellaneous:
|
|
|
|
L calc-load-everything. Load all parts of the Calculator into memory.
|
|
|
|
M read-kbd-macro. Read a region of keystroke names as a keyboard macro.
|
|
|
|
0 (zero) calc-reset. Reset Calc stack and modes to default state.
|
|
|
|
|
2005-11-28 22:13:37 +00:00
|
|
|
Press `*' twice (`C-x * *') to turn Calc on or off using the same
|
|
|
|
Calc user interface as before (either C-x * C or C-x * K; initially C-x * C).
|
|
|
|
"
|
2001-11-06 18:59:06 +00:00
|
|
|
(interactive "P")
|
|
|
|
(calc-check-defines)
|
|
|
|
(if calc-dispatch-help
|
|
|
|
(progn
|
|
|
|
(save-window-excursion
|
|
|
|
(describe-function 'calc-dispatch-help)
|
|
|
|
(let ((win (get-buffer-window "*Help*")))
|
|
|
|
(if win
|
|
|
|
(let (key)
|
|
|
|
(select-window win)
|
|
|
|
(while (progn
|
|
|
|
(message "Calc options: Calc, Keypad, ... %s"
|
|
|
|
"press SPC, DEL to scroll, C-g to cancel")
|
2019-06-19 22:56:26 +02:00
|
|
|
(memq (setq key (read-event))
|
2001-11-06 18:59:06 +00:00
|
|
|
'(? ?\C-h ?\C-? ?\C-v ?\M-v)))
|
* 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
|
|
|
(condition-case nil
|
2019-06-19 22:56:26 +02:00
|
|
|
(if (memq key '(? ?\C-v))
|
2001-11-06 18:59:06 +00:00
|
|
|
(scroll-up)
|
|
|
|
(scroll-down))
|
|
|
|
(error (beep))))
|
2019-06-19 22:56:26 +02:00
|
|
|
(calc-unread-command key)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
(calc-do-dispatch nil))
|
|
|
|
(let ((calc-dispatch-help t))
|
2001-11-14 09:06:05 +00:00
|
|
|
(calc-do-dispatch arg))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-big-or-small (arg)
|
|
|
|
"Toggle Calc between full-screen and regular mode."
|
|
|
|
(interactive "P")
|
|
|
|
(let ((cwin (get-buffer-window "*Calculator*"))
|
|
|
|
(twin (get-buffer-window "*Calc Trail*"))
|
|
|
|
(kwin (get-buffer-window "*Calc Keypad*")))
|
|
|
|
(if cwin
|
|
|
|
(setq calc-full-mode
|
|
|
|
(if kwin
|
2009-10-06 02:42:29 +00:00
|
|
|
(and twin (window-full-width-p twin))
|
|
|
|
(window-full-height-p cwin))))
|
2001-11-06 18:59:06 +00:00
|
|
|
(setq calc-full-mode (if arg
|
|
|
|
(> (prefix-numeric-value arg) 0)
|
|
|
|
(not calc-full-mode)))
|
|
|
|
(if kwin
|
|
|
|
(progn
|
|
|
|
(calc-quit)
|
|
|
|
(calc-do-keypad calc-full-mode nil))
|
|
|
|
(if cwin
|
|
|
|
(progn
|
|
|
|
(calc-quit)
|
|
|
|
(calc nil calc-full-mode nil))))
|
|
|
|
(message (if calc-full-mode
|
2001-11-19 07:36:42 +00:00
|
|
|
"Now using full screen for Calc"
|
|
|
|
"Now using partial screen for Calc"))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2004-10-26 19:06:24 +00:00
|
|
|
(defun calc-other-window (&optional interactive)
|
2001-11-06 18:59:06 +00:00
|
|
|
"Invoke the Calculator in another window."
|
2004-10-26 19:06:24 +00:00
|
|
|
(interactive "p")
|
2001-11-06 18:59:06 +00:00
|
|
|
(if (memq major-mode '(calc-mode calc-trail-mode))
|
|
|
|
(progn
|
|
|
|
(other-window 1)
|
|
|
|
(if (memq major-mode '(calc-mode calc-trail-mode))
|
|
|
|
(other-window 1)))
|
|
|
|
(if (get-buffer-window "*Calculator*")
|
|
|
|
(calc-quit)
|
|
|
|
(let ((win (selected-window)))
|
2004-10-26 19:06:24 +00:00
|
|
|
(calc nil win interactive)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun another-calc ()
|
|
|
|
"Create another, independent Calculator buffer."
|
|
|
|
(interactive)
|
|
|
|
(if (eq major-mode 'calc-mode)
|
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-default v (symbol-value v)))
|
|
|
|
calc-local-var-list))
|
2001-11-06 18:59:06 +00:00
|
|
|
(set-buffer (generate-new-buffer "*Calculator*"))
|
|
|
|
(pop-to-buffer (current-buffer))
|
2001-11-14 09:06:05 +00:00
|
|
|
(calc-mode))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-info ()
|
|
|
|
"Run the Emacs Info system on the Calculator documentation."
|
|
|
|
(interactive)
|
|
|
|
(select-window (get-largest-window))
|
2001-11-22 06:03:24 +00:00
|
|
|
(info "Calc"))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2004-10-11 03:27:24 +00:00
|
|
|
(defun calc-info-goto-node (node)
|
|
|
|
"Go to a node in the Calculator info documentation."
|
|
|
|
(interactive)
|
|
|
|
(select-window (get-largest-window))
|
2005-05-27 21:45:14 +00:00
|
|
|
(info (concat "(Calc)" node)))
|
2004-10-11 03:27:24 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-tutorial ()
|
|
|
|
"Run the Emacs Info system on the Calculator Tutorial."
|
|
|
|
(interactive)
|
|
|
|
(if (get-buffer-window "*Calculator*")
|
|
|
|
(calc-quit))
|
2004-10-11 03:27:24 +00:00
|
|
|
(calc-info-goto-node "Interactive Tutorial")
|
2001-11-06 18:59:06 +00:00
|
|
|
(calc-other-window)
|
2001-11-14 09:06:05 +00:00
|
|
|
(message "Welcome to the Calc Tutorial!"))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-info-summary ()
|
|
|
|
"Run the Emacs Info system on the Calculator Summary."
|
|
|
|
(interactive)
|
2004-10-11 03:27:24 +00:00
|
|
|
(calc-info-goto-node "Summary"))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-help ()
|
|
|
|
(interactive)
|
2008-08-14 18:34:05 +00:00
|
|
|
(let ((msgs
|
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
|
|
|
'("Press `h' for complete help; press `?' repeatedly for a summary"
|
2001-11-06 18:59:06 +00:00
|
|
|
"Letter keys: Negate; Precision; Yank; Why; Xtended cmd; Quit"
|
2011-12-16 14:32:35 +01:00
|
|
|
"Letter keys: SHIFT + Undo, reDo; Inverse, Hyperbolic, Option"
|
2001-11-06 18:59:06 +00:00
|
|
|
"Letter keys: SHIFT + sQrt; Sin, Cos, Tan; Exp, Ln, logB"
|
|
|
|
"Letter keys: SHIFT + Floor, Round; Abs, conJ, arG; Pi"
|
2011-12-16 14:32:35 +01:00
|
|
|
"Letter keys: SHIFT + Num-eval; More-recn; eXec-kbd-macro; Keep-args"
|
2001-11-06 18:59:06 +00:00
|
|
|
"Other keys: +, -, *, /, ^, \\ (int div), : (frac div)"
|
|
|
|
"Other keys: & (1/x), | (concat), % (modulo), ! (factorial)"
|
2015-08-28 22:24:10 -07:00
|
|
|
"Other keys: \\=' (alg-entry), = (eval), \\=` (edit); M-RET (last-args)"
|
2001-11-06 18:59:06 +00:00
|
|
|
"Other keys: SPC/RET (enter/dup), LFD (over); < > (scroll horiz)"
|
|
|
|
"Other keys: DEL (drop), M-DEL (drop-above); { } (scroll vert)"
|
|
|
|
"Other keys: TAB (swap/roll-dn), M-TAB (roll-up)"
|
|
|
|
"Other keys: [ , ; ] (vector), ( , ) (complex), ( ; ) (polar)"
|
|
|
|
"Prefix keys: Algebra, Binary/business, Convert, Display"
|
|
|
|
"Prefix keys: Functions, Graphics, Help, J (select)"
|
|
|
|
"Prefix keys: Kombinatorics/statistics, Modes, Store/recall"
|
|
|
|
"Prefix keys: Trail/time, Units/statistics, Vector/matrix"
|
|
|
|
"Prefix keys: Z (user), SHIFT + Z (define)"
|
2008-08-14 18:34:05 +00:00
|
|
|
"Prefix keys: prefix + ? gives further help for that prefix"
|
|
|
|
" Calc by Dave Gillespie, daveg@synaptics.com")))
|
2001-11-06 18:59:06 +00:00
|
|
|
(if calc-full-help-flag
|
|
|
|
msgs
|
|
|
|
(if (or calc-inverse-flag calc-hyperbolic-flag)
|
|
|
|
(if calc-inverse-flag
|
|
|
|
(if calc-hyperbolic-flag
|
|
|
|
(calc-inv-hyp-prefix-help)
|
|
|
|
(calc-inverse-prefix-help))
|
|
|
|
(calc-hyperbolic-prefix-help))
|
2010-04-16 21:47:25 -05:00
|
|
|
(if calc-option-flag
|
|
|
|
(calc-option-prefix-help)
|
|
|
|
(setq calc-help-phase
|
|
|
|
(if (eq this-command last-command)
|
|
|
|
(% (1+ calc-help-phase) (1+ (length msgs)))
|
|
|
|
0))
|
|
|
|
(let ((msg (nth calc-help-phase msgs)))
|
|
|
|
(message "%s" (if msg
|
2015-08-28 22:24:10 -07:00
|
|
|
(concat (substitute-command-keys msg) ":"
|
2010-04-16 21:47:25 -05:00
|
|
|
(make-string (- (apply 'max
|
|
|
|
(mapcar 'length
|
|
|
|
msgs))
|
2015-08-28 22:24:10 -07:00
|
|
|
(length msg))
|
|
|
|
?\ )
|
2010-04-16 21:47:25 -05:00
|
|
|
" [?=MORE]")
|
|
|
|
""))))))))
|
2011-11-18 00:31:02 -08:00
|
|
|
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Stack and buffer management.
|
|
|
|
|
2011-11-18 00:31:02 -08:00
|
|
|
;; The variable calc-last-why-command is set in calc-do-handle-whys
|
2004-11-26 22:33:19 +00:00
|
|
|
;; and used in calc-why (in calc-stuff.el).
|
|
|
|
(defvar calc-last-why-command)
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-do-handle-whys ()
|
|
|
|
(setq calc-why (sort calc-next-why
|
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)
|
|
|
|
(and (eq (car x) '*) (not (eq (car y) '*)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
calc-next-why nil)
|
|
|
|
(if (and calc-why (or (eq calc-auto-why t)
|
|
|
|
(and (eq (car (car calc-why)) '*)
|
|
|
|
calc-auto-why)))
|
|
|
|
(progn
|
2004-11-29 05:57:46 +00:00
|
|
|
(require 'calc-ext)
|
2001-11-06 18:59:06 +00:00
|
|
|
(calc-explain-why (car calc-why)
|
|
|
|
(if (eq calc-auto-why t)
|
|
|
|
(cdr calc-why)
|
|
|
|
(if calc-auto-why
|
|
|
|
(eq (car (nth 1 calc-why)) '*))))
|
|
|
|
(setq calc-last-why-command this-command)
|
2001-11-14 09:06:05 +00:00
|
|
|
(calc-clear-command-flag 'clear-message))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-record-why (&rest stuff)
|
|
|
|
(if (eq (car stuff) 'quiet)
|
|
|
|
(setq stuff (cdr stuff))
|
|
|
|
(if (and (symbolp (car stuff))
|
|
|
|
(cdr stuff)
|
|
|
|
(or (Math-objectp (nth 1 stuff))
|
|
|
|
(and (Math-vectorp (nth 1 stuff))
|
|
|
|
(math-constp (nth 1 stuff)))
|
|
|
|
(math-infinitep (nth 1 stuff))))
|
|
|
|
(setq stuff (cons '* stuff))
|
|
|
|
(if (and (stringp (car stuff))
|
|
|
|
(string-match "\\`\\*" (car stuff)))
|
|
|
|
(setq stuff (cons '* (cons (substring (car stuff) 1)
|
|
|
|
(cdr stuff)))))))
|
2012-08-07 20:30:58 -05:00
|
|
|
(unless (member stuff calc-next-why)
|
|
|
|
(setq calc-next-why (cons stuff calc-next-why)))
|
2001-11-14 09:06:05 +00:00
|
|
|
nil)
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;; True if A is a constant or vector of constants. [P x] [Public]
|
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun math-constp (a)
|
|
|
|
(or (Math-scalarp a)
|
|
|
|
(and (memq (car a) '(sdev intv mod vec))
|
|
|
|
(progn
|
|
|
|
(while (and (setq a (cdr a))
|
|
|
|
(or (Math-scalarp (car a)) ; optimization
|
|
|
|
(math-constp (car a)))))
|
2001-11-14 09:06:05 +00:00
|
|
|
(null a)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-roll-down-stack (n &optional m)
|
|
|
|
(if (< n 0)
|
|
|
|
(calc-roll-up-stack (- n) m)
|
|
|
|
(if (or (= n 0) (> n (calc-stack-size))) (setq n (calc-stack-size)))
|
|
|
|
(or m (setq m 1))
|
|
|
|
(and (> n 1)
|
|
|
|
(< m n)
|
|
|
|
(if (and calc-any-selections
|
|
|
|
(not calc-use-selections))
|
|
|
|
(calc-roll-down-with-selections n m)
|
|
|
|
(calc-pop-push-list n
|
|
|
|
(append (calc-top-list m 1)
|
2001-11-14 09:06:05 +00:00
|
|
|
(calc-top-list (- n m) (1+ m))))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-roll-up-stack (n &optional m)
|
|
|
|
(if (< n 0)
|
|
|
|
(calc-roll-down-stack (- n) m)
|
|
|
|
(if (or (= n 0) (> n (calc-stack-size))) (setq n (calc-stack-size)))
|
|
|
|
(or m (setq m 1))
|
|
|
|
(and (> n 1)
|
|
|
|
(< m n)
|
|
|
|
(if (and calc-any-selections
|
|
|
|
(not calc-use-selections))
|
|
|
|
(calc-roll-up-with-selections n m)
|
|
|
|
(calc-pop-push-list n
|
|
|
|
(append (calc-top-list (- n m) 1)
|
2001-11-14 09:06:05 +00:00
|
|
|
(calc-top-list m (- n m -1))))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-do-refresh ()
|
|
|
|
(if calc-hyperbolic-flag
|
|
|
|
(progn
|
|
|
|
(setq calc-display-dirty t)
|
|
|
|
nil)
|
|
|
|
(calc-refresh)
|
2001-11-14 09:06:05 +00:00
|
|
|
t))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-record-list (vals &optional prefix)
|
|
|
|
(while vals
|
|
|
|
(or (eq (car vals) 'top-of-stack)
|
|
|
|
(progn
|
|
|
|
(calc-record (car vals) prefix)
|
|
|
|
(setq prefix "...")))
|
2001-11-14 09:06:05 +00:00
|
|
|
(setq vals (cdr vals))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-last-args-stub (arg)
|
|
|
|
(interactive "p")
|
2004-11-29 05:57:46 +00:00
|
|
|
(require 'calc-ext)
|
2001-11-14 09:06:05 +00:00
|
|
|
(calc-last-args arg))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-power (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-slow-wrapper
|
2004-11-29 05:57:46 +00:00
|
|
|
(if (and (featurep 'calc-ext)
|
2001-11-06 18:59:06 +00:00
|
|
|
(calc-is-inverse))
|
|
|
|
(calc-binary-op "root" 'calcFunc-nroot arg nil nil)
|
2001-11-14 09:06:05 +00:00
|
|
|
(calc-binary-op "^" 'calcFunc-pow arg nil nil '^))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-mod (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-slow-wrapper
|
2001-11-14 09:06:05 +00:00
|
|
|
(calc-binary-op "%" 'calcFunc-mod arg nil nil '%)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-inv (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-slow-wrapper
|
2001-11-14 09:06:05 +00:00
|
|
|
(calc-unary-op "inv" 'calcFunc-inv arg)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-percent ()
|
|
|
|
(interactive)
|
|
|
|
(calc-slow-wrapper
|
|
|
|
(calc-pop-push-record-list
|
2001-11-14 09:06:05 +00:00
|
|
|
1 "%" (list (list 'calcFunc-percent (calc-top-n 1))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-over (n)
|
|
|
|
(interactive "P")
|
|
|
|
(if n
|
|
|
|
(calc-enter (- (prefix-numeric-value n)))
|
2001-11-14 09:06:05 +00:00
|
|
|
(calc-enter -2)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-pop-above (n)
|
|
|
|
(interactive "P")
|
|
|
|
(if n
|
|
|
|
(calc-pop (- (prefix-numeric-value n)))
|
2001-11-14 09:06:05 +00:00
|
|
|
(calc-pop -2)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-roll-down (n)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
|
|
|
(let ((nn (prefix-numeric-value n)))
|
|
|
|
(cond ((null n)
|
|
|
|
(calc-roll-down-stack 2))
|
|
|
|
((> nn 0)
|
|
|
|
(calc-roll-down-stack nn))
|
|
|
|
((= nn 0)
|
|
|
|
(calc-pop-push-list (calc-stack-size)
|
|
|
|
(reverse
|
|
|
|
(calc-top-list (calc-stack-size)))))
|
|
|
|
(t
|
2001-11-14 09:06:05 +00:00
|
|
|
(calc-roll-down-stack (calc-stack-size) (- nn)))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-roll-up (n)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
|
|
|
(let ((nn (prefix-numeric-value n)))
|
|
|
|
(cond ((null n)
|
|
|
|
(calc-roll-up-stack 3))
|
|
|
|
((> nn 0)
|
|
|
|
(calc-roll-up-stack nn))
|
|
|
|
((= nn 0)
|
|
|
|
(calc-pop-push-list (calc-stack-size)
|
|
|
|
(reverse
|
|
|
|
(calc-top-list (calc-stack-size)))))
|
|
|
|
(t
|
2001-11-14 09:06:05 +00:00
|
|
|
(calc-roll-up-stack (calc-stack-size) (- nn)))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2009-07-29 03:42:19 +00:00
|
|
|
;;;###autoload
|
|
|
|
(defun calc-transpose-lines (&optional arg)
|
|
|
|
"Transpose previous line and current line.
|
|
|
|
With argument ARG, move previous line past ARG lines.
|
|
|
|
With argument 0, switch line point is in with line mark is in."
|
|
|
|
(interactive "p")
|
|
|
|
(setq arg (or arg 1))
|
|
|
|
(let (bot-line mid-line end-line
|
|
|
|
old-top-list new-top-list
|
|
|
|
bot-cell mid-cell
|
|
|
|
prev-mid-cell post-mid-cell post-bot-cell)
|
|
|
|
(calc-wrapper
|
|
|
|
(when (eq major-mode 'calc-mode)
|
|
|
|
(cond
|
|
|
|
;; exchange point and mark
|
|
|
|
((= 0 arg)
|
|
|
|
(setq bot-line (calc-locate-cursor-element (point))
|
|
|
|
mid-line (mark))
|
|
|
|
(if mid-line
|
|
|
|
(setq mid-line (calc-locate-cursor-element mid-line)
|
|
|
|
end-line (1+ mid-line))
|
|
|
|
(error "No mark set"))
|
|
|
|
(if (< bot-line mid-line)
|
|
|
|
(let ((temp mid-line))
|
|
|
|
(setq mid-line bot-line
|
|
|
|
bot-line temp))))
|
|
|
|
;; move bot-line to mid-line that is above bot-line on stack (that is
|
|
|
|
;; to say mid-line displayed below bot-line in *Calculator* buffer)
|
|
|
|
((> arg 0)
|
|
|
|
(setq bot-line (1+ (calc-locate-cursor-element (point)))
|
|
|
|
mid-line (- bot-line arg)
|
|
|
|
end-line mid-line))
|
|
|
|
;; move bot-line to mid-line that is above bot-line on stack (that is
|
|
|
|
;; to say mid-line displayed below bot-line in *Calculator* buffer)
|
|
|
|
((< arg 0)
|
|
|
|
(setq mid-line (1+ (calc-locate-cursor-element (point)))
|
|
|
|
bot-line (- mid-line arg)
|
|
|
|
end-line bot-line)))
|
|
|
|
(calc-check-stack bot-line)
|
|
|
|
(if (= 0 mid-line)
|
|
|
|
(error "Can't transpose beyond top"))
|
|
|
|
(setq old-top-list (nreverse (calc-top-list bot-line)))
|
|
|
|
;; example: (arg = 2)
|
|
|
|
;; old-top-list =
|
|
|
|
;; 1 <-- top of stack (bottom of *Calculator* buffer)
|
|
|
|
;; 2
|
|
|
|
;; 3 <-- mid-line = 3
|
|
|
|
;; 4 <-- point
|
|
|
|
;; 5 <-- bot-line = 5
|
2020-10-10 16:00:51 -04:00
|
|
|
(dotimes (_ mid-line)
|
2009-07-29 03:42:19 +00:00
|
|
|
(setq mid-cell old-top-list
|
|
|
|
old-top-list (cdr old-top-list))
|
|
|
|
(setcdr mid-cell new-top-list)
|
|
|
|
(setq new-top-list mid-cell))
|
|
|
|
;; example follow-up:
|
|
|
|
;; old-top-list =
|
|
|
|
;; 4
|
|
|
|
;; 5
|
|
|
|
;; new-top-list =
|
|
|
|
;; 3 <-- mid-cell
|
|
|
|
;; 2
|
|
|
|
;; 1
|
|
|
|
(setq prev-mid-cell old-top-list)
|
2020-10-10 16:00:51 -04:00
|
|
|
(dotimes (_ (- bot-line mid-line))
|
2009-07-29 03:42:19 +00:00
|
|
|
(setq bot-cell old-top-list
|
|
|
|
old-top-list (cdr old-top-list))
|
|
|
|
(setcdr bot-cell new-top-list)
|
|
|
|
(setq new-top-list bot-cell))
|
|
|
|
(setq post-mid-cell (cdr mid-cell)
|
|
|
|
post-bot-cell (cdr bot-cell))
|
|
|
|
;; example follow-up:
|
|
|
|
;; new-top-list =
|
|
|
|
;; 5 <-- bot-cell
|
|
|
|
;; 4 <-- prev-mid-cell & post-bot-cell
|
|
|
|
;; 3 <-- mid-cell
|
|
|
|
;; 2 <-- post-mid-cell
|
|
|
|
;; 1
|
|
|
|
(cond
|
|
|
|
((= 0 arg); swap bot and mid
|
|
|
|
(setcdr mid-cell post-bot-cell)
|
|
|
|
(setcdr bot-cell post-mid-cell)
|
|
|
|
(setcdr prev-mid-cell bot-cell)
|
|
|
|
;; example follow-up:
|
|
|
|
;; 3 <-- mid-cell
|
|
|
|
;; 4 <-- post-bot-cell & prev-mid-cell
|
|
|
|
;; 5 <-- bot-cell
|
|
|
|
;; 2 <-- post-mid-cell
|
|
|
|
;; 1
|
|
|
|
(setq new-top-list mid-cell))
|
|
|
|
((< 0 arg) ; move bot just after mid
|
|
|
|
(setcdr mid-cell bot-cell)
|
|
|
|
(setcdr bot-cell post-mid-cell)
|
|
|
|
;; example follow-up:
|
|
|
|
;; new-top-list =
|
|
|
|
;; 4 <-- post-bot-cell
|
|
|
|
;; 3 <-- mid-cell
|
|
|
|
;; 5 <-- bot-cell
|
|
|
|
;; 2 <-- post-mid-cell
|
|
|
|
;; 1
|
|
|
|
(setq new-top-list post-bot-cell))
|
|
|
|
((> 0 arg) ; move mid just before bot
|
|
|
|
(setcdr mid-cell bot-cell)
|
|
|
|
(setcdr prev-mid-cell post-mid-cell)
|
|
|
|
;; example follow-up:
|
|
|
|
;; new-top-list =
|
|
|
|
;; 3 <-- mid-cell
|
|
|
|
;; 5 <-- bot-cell
|
|
|
|
;; 4 <-- prev-mid-cell
|
|
|
|
;; 2 <-- post-mid-cell
|
|
|
|
;; 1
|
|
|
|
(setq new-top-list mid-cell)))
|
|
|
|
(calc-pop-push-list bot-line new-top-list)))
|
|
|
|
(calc-cursor-stack-index (1- end-line))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Other commands.
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-num-prefix-name (n)
|
|
|
|
(cond ((eq n '-) "- ")
|
|
|
|
((equal n '(4)) "C-u ")
|
|
|
|
((consp n) (format "%d " (car n)))
|
|
|
|
((integerp n) (format "%d " n))
|
2001-11-14 09:06:05 +00:00
|
|
|
(t "")))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-missing-key (n)
|
|
|
|
"This is a placeholder for a command which needs to be loaded from calc-ext.
|
|
|
|
When this key is used, calc-ext (the Calculator extensions module) will be
|
|
|
|
loaded and the keystroke automatically re-typed."
|
|
|
|
(interactive "P")
|
2004-11-29 05:57:46 +00:00
|
|
|
(require 'calc-ext)
|
2009-01-09 03:57:12 +00:00
|
|
|
(if (keymapp (key-binding (char-to-string last-command-event)))
|
|
|
|
(message "%s%c-" (calc-num-prefix-name n) last-command-event))
|
2001-11-06 18:59:06 +00:00
|
|
|
(calc-unread-command)
|
2001-11-14 09:06:05 +00:00
|
|
|
(setq prefix-arg n))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-shift-Y-prefix-help ()
|
|
|
|
(interactive)
|
2004-11-29 05:57:46 +00:00
|
|
|
(require 'calc-ext)
|
2001-11-14 09:06:05 +00:00
|
|
|
(calc-do-prefix-help calc-Y-help-msgs "other" ?Y))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calcDigit-letter ()
|
|
|
|
(interactive)
|
|
|
|
(if (calc-minibuffer-contains "[-+]?\\(1[1-9]\\|[2-9][0-9]\\)#.*")
|
|
|
|
(progn
|
2009-01-09 03:57:12 +00:00
|
|
|
(setq last-command-event (upcase last-command-event))
|
2001-11-06 18:59:06 +00:00
|
|
|
(calcDigit-key))
|
2001-11-14 09:06:05 +00:00
|
|
|
(calcDigit-nondigit)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
;; A Lisp version of temp_minibuffer_message from minibuf.c.
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-temp-minibuffer-message (m)
|
|
|
|
(let ((savemax (point-max)))
|
|
|
|
(save-excursion
|
|
|
|
(goto-char (point-max))
|
|
|
|
(insert m))
|
|
|
|
(let ((okay nil))
|
|
|
|
(unwind-protect
|
|
|
|
(progn
|
|
|
|
(sit-for 2)
|
2017-01-25 21:13:19 -08:00
|
|
|
(identity 1) ; This forces a call to maybe_quit in bytecode.c.
|
2001-11-06 18:59:06 +00:00
|
|
|
(setq okay t))
|
|
|
|
(progn
|
|
|
|
(delete-region savemax (point-max))
|
2001-11-14 09:06:05 +00:00
|
|
|
(or okay (abort-recursive-edit)))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
(put 'math-with-extra-prec 'lisp-indent-hook 1)
|
|
|
|
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;; Concatenate two vectors, or a vector and an object. [V O O] [Public]
|
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun math-concat (v1 v2)
|
|
|
|
(if (stringp v1)
|
|
|
|
(concat v1 v2)
|
2004-11-29 05:57:46 +00:00
|
|
|
(require 'calc-ext)
|
2001-11-06 18:59:06 +00:00
|
|
|
(if (and (or (math-objvecp v1) (math-known-scalarp v1))
|
|
|
|
(or (math-objvecp v2) (math-known-scalarp v2)))
|
|
|
|
(append (if (and (math-vectorp v1)
|
|
|
|
(or (math-matrixp v1)
|
|
|
|
(not (math-matrixp v2))))
|
|
|
|
v1
|
|
|
|
(list 'vec v1))
|
|
|
|
(if (and (math-vectorp v2)
|
|
|
|
(or (math-matrixp v2)
|
|
|
|
(not (math-matrixp v1))))
|
|
|
|
(cdr v2)
|
|
|
|
(list v2)))
|
2001-11-14 09:06:05 +00:00
|
|
|
(list '| v1 v2))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;; True if A is zero. Works for un-normalized values. [P n] [Public]
|
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun math-zerop (a)
|
|
|
|
(if (consp 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
|
|
|
(cond ((memq (car a) '(frac float polar mod))
|
2001-11-06 18:59:06 +00:00
|
|
|
(math-zerop (nth 1 a)))
|
|
|
|
((eq (car a) 'cplx)
|
|
|
|
(and (math-zerop (nth 1 a)) (math-zerop (nth 2 a))))
|
|
|
|
((eq (car a) 'hms)
|
|
|
|
(and (math-zerop (nth 1 a))
|
|
|
|
(math-zerop (nth 2 a))
|
|
|
|
(math-zerop (nth 3 a)))))
|
2001-11-14 09:06:05 +00:00
|
|
|
(eq a 0)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;; True if A is real and negative. [P n] [Public]
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun math-negp (a)
|
|
|
|
(if (consp 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
|
|
|
(cond ((memq (car a) '(float frac))
|
2001-11-06 18:59:06 +00:00
|
|
|
(Math-integer-negp (nth 1 a)))
|
|
|
|
((eq (car a) 'hms)
|
|
|
|
(if (math-zerop (nth 1 a))
|
|
|
|
(if (math-zerop (nth 2 a))
|
|
|
|
(math-negp (nth 3 a))
|
|
|
|
(math-negp (nth 2 a)))
|
|
|
|
(math-negp (nth 1 a))))
|
|
|
|
((eq (car a) 'date)
|
|
|
|
(math-negp (nth 1 a)))
|
|
|
|
((eq (car a) 'intv)
|
|
|
|
(or (math-negp (nth 3 a))
|
|
|
|
(and (math-zerop (nth 3 a))
|
|
|
|
(memq (nth 1 a) '(0 2)))))
|
|
|
|
((equal a '(neg (var inf var-inf))) t))
|
2001-11-14 09:06:05 +00:00
|
|
|
(< a 0)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;; True if A is a negative number or an expression the starts with '-'.
|
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun math-looks-negp (a) ; [P x] [Public]
|
|
|
|
(or (Math-negp a)
|
|
|
|
(eq (car-safe a) 'neg)
|
|
|
|
(and (memq (car-safe a) '(* /))
|
|
|
|
(or (math-looks-negp (nth 1 a))
|
|
|
|
(math-looks-negp (nth 2 a))))
|
|
|
|
(and (eq (car-safe a) '-)
|
2001-11-14 09:06:05 +00:00
|
|
|
(math-looks-negp (nth 1 a)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;; True if A is real and positive. [P n] [Public]
|
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun math-posp (a)
|
|
|
|
(if (consp 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
|
|
|
(cond ((memq (car a) '(float frac))
|
2001-11-06 18:59:06 +00:00
|
|
|
(Math-integer-posp (nth 1 a)))
|
|
|
|
((eq (car a) 'hms)
|
|
|
|
(if (math-zerop (nth 1 a))
|
|
|
|
(if (math-zerop (nth 2 a))
|
|
|
|
(math-posp (nth 3 a))
|
|
|
|
(math-posp (nth 2 a)))
|
|
|
|
(math-posp (nth 1 a))))
|
|
|
|
((eq (car a) 'date)
|
|
|
|
(math-posp (nth 1 a)))
|
|
|
|
((eq (car a) 'mod)
|
|
|
|
(not (math-zerop (nth 1 a))))
|
|
|
|
((eq (car a) 'intv)
|
|
|
|
(or (math-posp (nth 2 a))
|
|
|
|
(and (math-zerop (nth 2 a))
|
|
|
|
(memq (nth 1 a) '(0 1)))))
|
|
|
|
((equal a '(var inf var-inf)) t))
|
2001-11-14 09:06:05 +00:00
|
|
|
(> a 0)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
* 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-fixnump #'fixnump)
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
* 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-fixnatnump (x) (and (fixnump x) (natnump x)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;; True if A is an even integer. [P R R] [Public]
|
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun math-evenp (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-evenp a)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;; Compute A / 2, for small or big integer A. [I i]
|
|
|
|
;; If A is negative, type of truncation is undefined.
|
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun math-div2 (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
|
|
|
(/ a 2))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;; Reject an argument to a calculator function. [Public]
|
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun math-reject-arg (&optional a p option)
|
|
|
|
(if option
|
|
|
|
(calc-record-why option p a)
|
|
|
|
(if p
|
|
|
|
(calc-record-why p a)))
|
2001-11-14 09:06:05 +00:00
|
|
|
(signal 'wrong-type-argument (and a (if p (list p a) (list a)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;; Coerce A to be an integer (by truncation toward zero). [I N] [Public]
|
2004-11-24 21:45:32 +00:00
|
|
|
|
|
|
|
;; The variable math-trunc-prec is local to math-trunc, but used by
|
|
|
|
;; math-trunc-fancy in calc-arith.el, which is called by math-trunc.
|
2020-10-14 18:03:52 -04:00
|
|
|
(defvar math-trunc-prec)
|
2004-11-24 21:45:32 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2020-10-14 18:03:52 -04:00
|
|
|
(defun math-trunc (a &optional trunc-prec)
|
|
|
|
(cond (trunc-prec
|
2004-11-29 05:57:46 +00:00
|
|
|
(require 'calc-ext)
|
2020-10-14 18:03:52 -04:00
|
|
|
(math-trunc-special a trunc-prec))
|
2001-11-06 18:59:06 +00:00
|
|
|
((Math-integerp a) a)
|
|
|
|
((Math-looks-negp a)
|
|
|
|
(math-neg (math-trunc (math-neg a))))
|
|
|
|
((eq (car a) 'float)
|
|
|
|
(math-scale-int (nth 1 a) (nth 2 a)))
|
2004-11-29 05:57:46 +00:00
|
|
|
(t (require 'calc-ext)
|
2020-10-14 18:03:52 -04:00
|
|
|
(let ((math-trunc-prec trunc-prec))
|
|
|
|
(math-trunc-fancy a)))))
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-19 07:36:42 +00:00
|
|
|
(defalias 'calcFunc-trunc 'math-trunc)
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;; Coerce A to be an integer (by truncation toward minus infinity). [I N]
|
2004-11-24 21:45:32 +00:00
|
|
|
|
|
|
|
;; The variable math-floor-prec is local to math-floor, but used by
|
|
|
|
;; math-floor-fancy in calc-arith.el, which is called by math-floor.
|
2020-10-14 18:03:52 -04:00
|
|
|
(defvar math-floor-prec)
|
2004-11-24 21:45:32 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2020-10-14 18:03:52 -04:00
|
|
|
(defun math-floor (a &optional floor-prec) ; [Public]
|
|
|
|
(cond (floor-prec
|
2004-11-29 05:57:46 +00:00
|
|
|
(require 'calc-ext)
|
2020-10-14 18:03:52 -04:00
|
|
|
(math-floor-special a floor-prec))
|
2001-11-06 18:59:06 +00:00
|
|
|
((Math-integerp a) a)
|
|
|
|
((Math-messy-integerp a) (math-trunc a))
|
|
|
|
((Math-realp a)
|
|
|
|
(if (Math-negp a)
|
|
|
|
(math-add (math-trunc a) -1)
|
|
|
|
(math-trunc a)))
|
2004-11-29 05:57:46 +00:00
|
|
|
(t (require 'calc-ext)
|
2020-10-14 18:03:52 -04:00
|
|
|
(let ((math-floor-prec floor-prec))
|
|
|
|
(math-floor-fancy a)))))
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-19 07:36:42 +00:00
|
|
|
(defalias 'calcFunc-floor 'math-floor)
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun math-imod (a b) ; [I I I] [Public]
|
|
|
|
(if (and (not (consp a)) (not (consp b)))
|
|
|
|
(if (= b 0)
|
|
|
|
(math-reject-arg a "*Division by zero")
|
|
|
|
(% a b))
|
2001-11-14 09:06:05 +00:00
|
|
|
(cdr (math-idivmod a b))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calcFunc-inv (m)
|
|
|
|
(if (Math-vectorp m)
|
|
|
|
(progn
|
2004-11-29 05:57:46 +00:00
|
|
|
(require 'calc-ext)
|
2001-11-06 18:59:06 +00:00
|
|
|
(if (math-square-matrixp m)
|
|
|
|
(or (math-with-extra-prec 2 (math-matrix-inv-raw m))
|
|
|
|
(math-reject-arg m "*Singular matrix"))
|
|
|
|
(math-reject-arg m 'square-matrixp)))
|
2005-10-28 03:52:08 +00:00
|
|
|
(if (and
|
|
|
|
(require 'calc-arith)
|
|
|
|
(math-known-matrixp m))
|
|
|
|
(math-pow m -1)
|
|
|
|
(math-div 1 m))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun math-do-working (msg arg)
|
2001-11-13 07:30:58 +00:00
|
|
|
(or executing-kbd-macro
|
2001-11-06 18:59:06 +00:00
|
|
|
(progn
|
|
|
|
(calc-set-command-flag 'clear-message)
|
|
|
|
(if math-working-step
|
|
|
|
(if math-working-step-2
|
|
|
|
(setq msg (format "[%d/%d] %s"
|
|
|
|
math-working-step math-working-step-2 msg))
|
|
|
|
(setq msg (format "[%d] %s" math-working-step msg))))
|
|
|
|
(message "Working... %s = %s" msg
|
2001-11-14 09:06:05 +00:00
|
|
|
(math-showing-full-precision (math-format-number arg))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;; Compute A modulo B, defined in terms of truncation toward minus infinity.
|
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun math-mod (a b) ; [R R R] [Public]
|
|
|
|
(cond ((and (Math-zerop a) (not (eq (car-safe a) 'mod))) a)
|
|
|
|
((Math-zerop b)
|
|
|
|
(math-reject-arg a "*Division by zero"))
|
|
|
|
((and (Math-natnump a) (Math-natnump b))
|
|
|
|
(math-imod a b))
|
|
|
|
((and (Math-anglep a) (Math-anglep b))
|
|
|
|
(math-sub a (math-mul (math-floor (math-div a b)) b)))
|
2004-11-29 05:57:46 +00:00
|
|
|
(t (require 'calc-ext)
|
2001-11-14 09:06:05 +00:00
|
|
|
(math-mod-fancy a b))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; General exponentiation.
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun math-pow (a b) ; [O O N] [Public]
|
|
|
|
(cond ((equal b '(var nan var-nan))
|
|
|
|
b)
|
|
|
|
((Math-zerop a)
|
|
|
|
(if (and (Math-scalarp b) (Math-posp b))
|
|
|
|
(if (math-floatp b) (math-float a) a)
|
2004-11-29 05:57:46 +00:00
|
|
|
(require 'calc-ext)
|
2001-11-06 18:59:06 +00:00
|
|
|
(math-pow-of-zero a b)))
|
|
|
|
((or (eq a 1) (eq b 1)) a)
|
|
|
|
((or (equal a '(float 1 0)) (equal b '(float 1 0))) a)
|
|
|
|
((Math-zerop b)
|
|
|
|
(if (Math-scalarp a)
|
|
|
|
(if (or (math-floatp a) (math-floatp b))
|
|
|
|
'(float 1 0) 1)
|
2004-11-29 05:57:46 +00:00
|
|
|
(require 'calc-ext)
|
2001-11-06 18:59:06 +00:00
|
|
|
(math-pow-zero a b)))
|
|
|
|
((and (Math-integerp b) (or (Math-numberp a) (Math-vectorp a)))
|
|
|
|
(if (and (equal a '(float 1 1)) (integerp b))
|
|
|
|
(math-make-float 1 b)
|
|
|
|
(math-with-extra-prec 2
|
|
|
|
(math-ipow a b))))
|
|
|
|
(t
|
2004-11-29 05:57:46 +00:00
|
|
|
(require 'calc-ext)
|
2001-11-14 09:06:05 +00:00
|
|
|
(math-pow-fancy a b))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun math-ipow (a n) ; [O O I] [Public]
|
|
|
|
(cond ((Math-integer-negp n)
|
|
|
|
(math-ipow (math-div 1 a) (Math-integer-neg n)))
|
|
|
|
((not (consp n))
|
|
|
|
(if (and (Math-ratp a) (> n 20))
|
|
|
|
(math-iipow-show a n)
|
|
|
|
(math-iipow a n)))
|
|
|
|
((math-evenp n)
|
|
|
|
(math-ipow (math-mul a a) (math-div2 n)))
|
|
|
|
(t
|
|
|
|
(math-mul a (math-ipow (math-mul a a)
|
2001-11-14 09:06:05 +00:00
|
|
|
(math-div2 (math-add n -1)))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun math-iipow (a n) ; [O O S]
|
|
|
|
(cond ((= n 0) 1)
|
|
|
|
((= n 1) a)
|
|
|
|
((= (% n 2) 0) (math-iipow (math-mul a a) (/ n 2)))
|
2001-11-14 09:06:05 +00:00
|
|
|
(t (math-mul a (math-iipow (math-mul a a) (/ n 2))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun math-iipow-show (a n) ; [O O S]
|
|
|
|
(math-working "pow" a)
|
|
|
|
(let ((val (cond
|
|
|
|
((= n 0) 1)
|
|
|
|
((= n 1) a)
|
|
|
|
((= (% n 2) 0) (math-iipow-show (math-mul a a) (/ n 2)))
|
|
|
|
(t (math-mul a (math-iipow-show (math-mul a a) (/ n 2)))))))
|
|
|
|
(math-working "pow" val)
|
2001-11-14 09:06:05 +00:00
|
|
|
val))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun math-read-radix-digit (dig) ; [D S; Z S]
|
|
|
|
(if (> dig ?9)
|
|
|
|
(if (< dig ?A)
|
|
|
|
nil
|
|
|
|
(- dig 55))
|
|
|
|
(if (>= dig ?0)
|
|
|
|
(- dig ?0)
|
2001-11-14 09:06:05 +00:00
|
|
|
nil)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
;;; Bug reporting
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;;;###autoload
|
2018-09-03 10:28:07 -07:00
|
|
|
(define-obsolete-function-alias 'report-calc-bug 'report-emacs-bug "26.2")
|
|
|
|
;;;###autoload
|
|
|
|
(define-obsolete-function-alias 'calc-report-bug 'report-emacs-bug "26.2")
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2004-11-30 17:17:35 +00:00
|
|
|
(provide 'calc-misc)
|
|
|
|
|
2008-04-08 22:07:55 +00:00
|
|
|
;; Local variables:
|
|
|
|
;; generated-autoload-file: "calc-loaddefs.el"
|
|
|
|
;; End:
|
|
|
|
|
2001-11-14 09:06:05 +00:00
|
|
|
;;; calc-misc.el ends here
|