Mercurial > emacs
annotate lisp/calc/calc-misc.el @ 93904:41ee2cc9680d
(font-lock-extend-after-change-region-function): Make it buffer local.
author | Alan Mackenzie <acm@muc.de> |
---|---|
date | Wed, 09 Apr 2008 08:17:59 +0000 |
parents | c6152337e4ad |
children | 6c9af2bfcfee |
rev | line source |
---|---|
63610 | 1 ;;; calc-misc.el --- miscellaneous functions for Calc |
41267
e9718841a5b1
(math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents:
41045
diff
changeset
|
2 |
64325
1db49616ce05
Update copyright information.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
63610
diff
changeset
|
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004 |
79702 | 4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
41267
e9718841a5b1
(math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents:
41045
diff
changeset
|
5 |
e9718841a5b1
(math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents:
41045
diff
changeset
|
6 ;; Author: David Gillespie <daveg@synaptics.com> |
77465
1154f082efd9
Update maintainer's address.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
76595
diff
changeset
|
7 ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com> |
40785 | 8 |
9 ;; This file is part of GNU Emacs. | |
10 | |
76595
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
78215
095d08e7d6bb
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
77465
diff
changeset
|
13 ;; the Free Software Foundation; either version 3, or (at your option) |
76595
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
14 ;; any later version. |
40785 | 15 |
76595
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
19 ;; GNU General Public License for more details. |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
20 |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
497d17a80bb8
Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
24 ;; Boston, MA 02110-1301, USA. |
40785 | 25 |
41267
e9718841a5b1
(math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents:
41045
diff
changeset
|
26 ;;; Commentary: |
40785 | 27 |
41267
e9718841a5b1
(math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents:
41045
diff
changeset
|
28 ;;; Code: |
40785 | 29 |
30 ;; This file is autoloaded from calc.el. | |
58664
f23c98cc77a1
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58613
diff
changeset
|
31 |
40785 | 32 (require 'calc) |
33 (require 'calc-macs) | |
34 | |
86477
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
35 ;; Declare functions which are defined elsewhere. |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
36 (declare-function calc-do-keypad "calc-keypd" (&optional full-display interactive)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
37 (declare-function calc-inv-hyp-prefix-help "calc-help" ()) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
38 (declare-function calc-inverse-prefix-help "calc-help" ()) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
39 (declare-function calc-hyperbolic-prefix-help "calc-help" ()) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
40 (declare-function calc-explain-why "calc-stuff" (why &optional more)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
41 (declare-function calc-clear-command-flag "calc-ext" (f)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
42 (declare-function calc-roll-down-with-selections "calc-sel" (n m)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
43 (declare-function calc-roll-up-with-selections "calc-sel" (n m)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
44 (declare-function calc-last-args "calc-undo" (n)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
45 (declare-function calc-is-inverse "calc-ext" ()) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
46 (declare-function calc-do-prefix-help "calc-ext" (msgs group key)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
47 (declare-function math-objvecp "calc-ext" (a)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
48 (declare-function math-known-scalarp "calc-arith" (a &optional assume-scalar)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
49 (declare-function math-vectorp "calc-ext" (a)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
50 (declare-function math-matrixp "calc-ext" (a)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
51 (declare-function math-trunc-special "calc-arith" (a prec)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
52 (declare-function math-trunc-fancy "calc-arith" (a)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
53 (declare-function math-floor-special "calc-arith" (a prec)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
54 (declare-function math-floor-fancy "calc-arith" (a)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
55 (declare-function math-square-matrixp "calc-ext" (a)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
56 (declare-function math-matrix-inv-raw "calc-mtx" (m)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
57 (declare-function math-known-matrixp "calc-arith" (a)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
58 (declare-function math-mod-fancy "calc-arith" (a b)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
59 (declare-function math-pow-of-zero "calc-arith" (a b)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
60 (declare-function math-pow-zero "calc-arith" (a b)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
61 (declare-function math-pow-fancy "calc-arith" (a b)) |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
62 |
327601aefd65
(calc-do-keypad, calc-inv-hyp-prefix-help)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
84888
diff
changeset
|
63 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
64 ;;;###autoload |
40785 | 65 (defun calc-dispatch-help (arg) |
67190
655ce2fe3aa6
(calc-dispatch-help): Update docstring.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
66480
diff
changeset
|
66 "C-x* is a prefix key sequence; follow it with one of these letters: |
40785 | 67 |
68 For turning Calc on and off: | |
69 C calc. Start the Calculator in a window at the bottom of the screen. | |
70 O calc-other-window. Start the Calculator but don't select its window. | |
71 B calc-big-or-small. Control whether to use the full Emacs screen for Calc. | |
72 Q quick-calc. Use the Calculator in the minibuffer. | |
73 K calc-keypad. Start the Calculator in keypad mode (X window system only). | |
74 E calc-embedded. Use the Calculator on a formula in this editing buffer. | |
75 J calc-embedded-select. Like E, but select appropriate half of => or :=. | |
76 W calc-embedded-word. Like E, but activate a single word, i.e., a number. | |
77 Z calc-user-invocation. Invoke Calc in the way you defined with `Z I' cmd. | |
78 X calc-quit. Turn Calc off. | |
79 | |
80 For moving data into and out of Calc: | |
81 G calc-grab-region. Grab the region defined by mark and point into Calc. | |
82 R calc-grab-rectangle. Grab the rectangle defined by mark, point into Calc. | |
83 : calc-grab-sum-down. Grab a rectangle and sum the columns. | |
84 _ calc-grab-sum-across. Grab a rectangle and sum the rows. | |
85 Y calc-copy-to-buffer. Copy a value from the stack into the editing buffer. | |
86 | |
87 For use with Embedded mode: | |
88 A calc-embedded-activate. Find and activate all :='s and =>'s in buffer. | |
89 D calc-embedded-duplicate. Make a copy of this formula and select it. | |
90 F calc-embedded-new-formula. Insert a new formula at current point. | |
91 N calc-embedded-next. Advance cursor to next known formula in buffer. | |
92 P calc-embedded-previous. Advance cursor to previous known formula. | |
93 U calc-embedded-update-formula. Re-evaluate formula at point. | |
94 ` calc-embedded-edit. Use calc-edit to edit formula at point. | |
95 | |
96 Documentation: | |
97 I calc-info. Read the Calculator manual in the Emacs Info system. | |
98 T calc-tutorial. Run the Calculator Tutorial using the Emacs Info system. | |
99 S calc-summary. Read the Summary from the Calculator manual in Info. | |
100 | |
101 Miscellaneous: | |
102 L calc-load-everything. Load all parts of the Calculator into memory. | |
103 M read-kbd-macro. Read a region of keystroke names as a keyboard macro. | |
104 0 (zero) calc-reset. Reset Calc stack and modes to default state. | |
105 | |
67190
655ce2fe3aa6
(calc-dispatch-help): Update docstring.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
66480
diff
changeset
|
106 Press `*' twice (`C-x * *') to turn Calc on or off using the same |
655ce2fe3aa6
(calc-dispatch-help): Update docstring.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
66480
diff
changeset
|
107 Calc user interface as before (either C-x * C or C-x * K; initially C-x * C). |
655ce2fe3aa6
(calc-dispatch-help): Update docstring.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
66480
diff
changeset
|
108 " |
40785 | 109 (interactive "P") |
110 (calc-check-defines) | |
111 (if calc-dispatch-help | |
112 (progn | |
113 (save-window-excursion | |
114 (describe-function 'calc-dispatch-help) | |
115 (let ((win (get-buffer-window "*Help*"))) | |
116 (if win | |
117 (let (key) | |
118 (select-window win) | |
119 (while (progn | |
120 (message "Calc options: Calc, Keypad, ... %s" | |
121 "press SPC, DEL to scroll, C-g to cancel") | |
122 (memq (car (setq key (calc-read-key t))) | |
123 '(? ?\C-h ?\C-? ?\C-v ?\M-v))) | |
124 (condition-case err | |
125 (if (memq (car key) '(? ?\C-v)) | |
126 (scroll-up) | |
127 (scroll-down)) | |
128 (error (beep)))) | |
129 (calc-unread-command (cdr key)))))) | |
130 (calc-do-dispatch nil)) | |
131 (let ((calc-dispatch-help t)) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
132 (calc-do-dispatch arg)))) |
40785 | 133 |
134 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
135 ;;;###autoload |
40785 | 136 (defun calc-big-or-small (arg) |
137 "Toggle Calc between full-screen and regular mode." | |
138 (interactive "P") | |
139 (let ((cwin (get-buffer-window "*Calculator*")) | |
140 (twin (get-buffer-window "*Calc Trail*")) | |
141 (kwin (get-buffer-window "*Calc Keypad*"))) | |
142 (if cwin | |
143 (setq calc-full-mode | |
144 (if kwin | |
40998
ee9c2872370b
Use `frame-width' instead of `screen-width',
Eli Zaretskii <eliz@gnu.org>
parents:
40785
diff
changeset
|
145 (and twin (eq (window-width twin) (frame-width))) |
ee9c2872370b
Use `frame-width' instead of `screen-width',
Eli Zaretskii <eliz@gnu.org>
parents:
40785
diff
changeset
|
146 (eq (window-height cwin) (1- (frame-height)))))) |
40785 | 147 (setq calc-full-mode (if arg |
148 (> (prefix-numeric-value arg) 0) | |
149 (not calc-full-mode))) | |
150 (if kwin | |
151 (progn | |
152 (calc-quit) | |
153 (calc-do-keypad calc-full-mode nil)) | |
154 (if cwin | |
155 (progn | |
156 (calc-quit) | |
157 (calc nil calc-full-mode nil)))) | |
158 (message (if calc-full-mode | |
41267
e9718841a5b1
(math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents:
41045
diff
changeset
|
159 "Now using full screen for Calc" |
e9718841a5b1
(math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents:
41045
diff
changeset
|
160 "Now using partial screen for Calc")))) |
40785 | 161 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
162 ;;;###autoload |
57711
d9073880a6e4
(calc-other-window): Use an extra argument instead of `interactive-p'.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57430
diff
changeset
|
163 (defun calc-other-window (&optional interactive) |
40785 | 164 "Invoke the Calculator in another window." |
57711
d9073880a6e4
(calc-other-window): Use an extra argument instead of `interactive-p'.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57430
diff
changeset
|
165 (interactive "p") |
40785 | 166 (if (memq major-mode '(calc-mode calc-trail-mode)) |
167 (progn | |
168 (other-window 1) | |
169 (if (memq major-mode '(calc-mode calc-trail-mode)) | |
170 (other-window 1))) | |
171 (if (get-buffer-window "*Calculator*") | |
172 (calc-quit) | |
173 (let ((win (selected-window))) | |
57711
d9073880a6e4
(calc-other-window): Use an extra argument instead of `interactive-p'.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57430
diff
changeset
|
174 (calc nil win interactive))))) |
40785 | 175 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
176 ;;;###autoload |
40785 | 177 (defun another-calc () |
178 "Create another, independent Calculator buffer." | |
179 (interactive) | |
180 (if (eq major-mode 'calc-mode) | |
84888
23f1c8af4174
(another-calc): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82140
diff
changeset
|
181 (mapc (function |
23f1c8af4174
(another-calc): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82140
diff
changeset
|
182 (lambda (v) |
23f1c8af4174
(another-calc): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
82140
diff
changeset
|
183 (set-default v (symbol-value v)))) calc-local-var-list)) |
40785 | 184 (set-buffer (generate-new-buffer "*Calculator*")) |
185 (pop-to-buffer (current-buffer)) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
186 (calc-mode)) |
40785 | 187 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
188 ;;;###autoload |
40785 | 189 (defun calc-info () |
190 "Run the Emacs Info system on the Calculator documentation." | |
191 (interactive) | |
192 (select-window (get-largest-window)) | |
41359
5042a5269efd
(calc-info): Don't perform voodoo, just (info "Calc").
Colin Walters <walters@gnu.org>
parents:
41267
diff
changeset
|
193 (info "Calc")) |
40785 | 194 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
195 ;;;###autoload |
57430
f4e473491598
(calc-info-goto-node): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
196 (defun calc-info-goto-node (node) |
f4e473491598
(calc-info-goto-node): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
197 "Go to a node in the Calculator info documentation." |
f4e473491598
(calc-info-goto-node): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
198 (interactive) |
f4e473491598
(calc-info-goto-node): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
199 (select-window (get-largest-window)) |
62829
a91bfc189888
(calc-info-goto-node): Use info instead of Info-goto-node.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
62442
diff
changeset
|
200 (info (concat "(Calc)" node))) |
57430
f4e473491598
(calc-info-goto-node): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
201 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
202 ;;;###autoload |
40785 | 203 (defun calc-tutorial () |
204 "Run the Emacs Info system on the Calculator Tutorial." | |
205 (interactive) | |
206 (if (get-buffer-window "*Calculator*") | |
207 (calc-quit)) | |
57430
f4e473491598
(calc-info-goto-node): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
208 (calc-info-goto-node "Interactive Tutorial") |
40785 | 209 (calc-other-window) |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
210 (message "Welcome to the Calc Tutorial!")) |
40785 | 211 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
212 ;;;###autoload |
40785 | 213 (defun calc-info-summary () |
214 "Run the Emacs Info system on the Calculator Summary." | |
215 (interactive) | |
57430
f4e473491598
(calc-info-goto-node): New function.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
216 (calc-info-goto-node "Summary")) |
40785 | 217 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
218 ;;;###autoload |
40785 | 219 (defun calc-help () |
220 (interactive) | |
221 (let ((msgs (append | |
222 '("Press `h' for complete help; press `?' repeatedly for a summary" | |
223 "Letter keys: Negate; Precision; Yank; Why; Xtended cmd; Quit" | |
224 "Letter keys: SHIFT + Undo, reDo; Keep-args; Inverse, Hyperbolic" | |
225 "Letter keys: SHIFT + sQrt; Sin, Cos, Tan; Exp, Ln, logB" | |
226 "Letter keys: SHIFT + Floor, Round; Abs, conJ, arG; Pi" | |
227 "Letter keys: SHIFT + Num-eval; More-recn; eXec-kbd-macro" | |
228 "Other keys: +, -, *, /, ^, \\ (int div), : (frac div)" | |
229 "Other keys: & (1/x), | (concat), % (modulo), ! (factorial)" | |
230 "Other keys: ' (alg-entry), = (eval), ` (edit); M-RET (last-args)" | |
231 "Other keys: SPC/RET (enter/dup), LFD (over); < > (scroll horiz)" | |
232 "Other keys: DEL (drop), M-DEL (drop-above); { } (scroll vert)" | |
233 "Other keys: TAB (swap/roll-dn), M-TAB (roll-up)" | |
234 "Other keys: [ , ; ] (vector), ( , ) (complex), ( ; ) (polar)" | |
235 "Prefix keys: Algebra, Binary/business, Convert, Display" | |
236 "Prefix keys: Functions, Graphics, Help, J (select)" | |
237 "Prefix keys: Kombinatorics/statistics, Modes, Store/recall" | |
238 "Prefix keys: Trail/time, Units/statistics, Vector/matrix" | |
239 "Prefix keys: Z (user), SHIFT + Z (define)" | |
240 "Prefix keys: prefix + ? gives further help for that prefix") | |
241 (list (format | |
242 " Calc %s by Dave Gillespie, daveg@synaptics.com" | |
243 calc-version))))) | |
244 (if calc-full-help-flag | |
245 msgs | |
246 (if (or calc-inverse-flag calc-hyperbolic-flag) | |
247 (if calc-inverse-flag | |
248 (if calc-hyperbolic-flag | |
249 (calc-inv-hyp-prefix-help) | |
250 (calc-inverse-prefix-help)) | |
251 (calc-hyperbolic-prefix-help)) | |
252 (setq calc-help-phase | |
253 (if (eq this-command last-command) | |
254 (% (1+ calc-help-phase) (1+ (length msgs))) | |
255 0)) | |
256 (let ((msg (nth calc-help-phase msgs))) | |
257 (message "%s" (if msg | |
258 (concat msg ":" | |
259 (make-string (- (apply 'max | |
260 (mapcar 'length | |
261 msgs)) | |
262 (length msg)) 32) | |
263 " [?=MORE]") | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
264 ""))))))) |
40785 | 265 |
266 | |
267 | |
268 | |
269 ;;;; Stack and buffer management. | |
270 | |
58543
129486947645
(calc-last-why-command): Declare it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58480
diff
changeset
|
271 ;; The variable calc-last-why-command is set in calc-do-handly-whys |
129486947645
(calc-last-why-command): Declare it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58480
diff
changeset
|
272 ;; and used in calc-why (in calc-stuff.el). |
129486947645
(calc-last-why-command): Declare it.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58480
diff
changeset
|
273 (defvar calc-last-why-command) |
40785 | 274 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
275 ;;;###autoload |
40785 | 276 (defun calc-do-handle-whys () |
277 (setq calc-why (sort calc-next-why | |
278 (function | |
279 (lambda (x y) | |
280 (and (eq (car x) '*) (not (eq (car y) '*)))))) | |
281 calc-next-why nil) | |
282 (if (and calc-why (or (eq calc-auto-why t) | |
283 (and (eq (car (car calc-why)) '*) | |
284 calc-auto-why))) | |
285 (progn | |
58613
3eb7a394510d
(calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58543
diff
changeset
|
286 (require 'calc-ext) |
40785 | 287 (calc-explain-why (car calc-why) |
288 (if (eq calc-auto-why t) | |
289 (cdr calc-why) | |
290 (if calc-auto-why | |
291 (eq (car (nth 1 calc-why)) '*)))) | |
292 (setq calc-last-why-command this-command) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
293 (calc-clear-command-flag 'clear-message)))) |
40785 | 294 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
295 ;;;###autoload |
40785 | 296 (defun calc-record-why (&rest stuff) |
297 (if (eq (car stuff) 'quiet) | |
298 (setq stuff (cdr stuff)) | |
299 (if (and (symbolp (car stuff)) | |
300 (cdr stuff) | |
301 (or (Math-objectp (nth 1 stuff)) | |
302 (and (Math-vectorp (nth 1 stuff)) | |
303 (math-constp (nth 1 stuff))) | |
304 (math-infinitep (nth 1 stuff)))) | |
305 (setq stuff (cons '* stuff)) | |
306 (if (and (stringp (car stuff)) | |
307 (string-match "\\`\\*" (car stuff))) | |
308 (setq stuff (cons '* (cons (substring (car stuff) 1) | |
309 (cdr stuff))))))) | |
310 (setq calc-next-why (cons stuff calc-next-why)) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
311 nil) |
40785 | 312 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
313 ;; True if A is a constant or vector of constants. [P x] [Public] |
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
314 ;;;###autoload |
40785 | 315 (defun math-constp (a) |
316 (or (Math-scalarp a) | |
317 (and (memq (car a) '(sdev intv mod vec)) | |
318 (progn | |
319 (while (and (setq a (cdr a)) | |
320 (or (Math-scalarp (car a)) ; optimization | |
321 (math-constp (car a))))) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
322 (null a))))) |
40785 | 323 |
324 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
325 ;;;###autoload |
40785 | 326 (defun calc-roll-down-stack (n &optional m) |
327 (if (< n 0) | |
328 (calc-roll-up-stack (- n) m) | |
329 (if (or (= n 0) (> n (calc-stack-size))) (setq n (calc-stack-size))) | |
330 (or m (setq m 1)) | |
331 (and (> n 1) | |
332 (< m n) | |
333 (if (and calc-any-selections | |
334 (not calc-use-selections)) | |
335 (calc-roll-down-with-selections n m) | |
336 (calc-pop-push-list n | |
337 (append (calc-top-list m 1) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
338 (calc-top-list (- n m) (1+ m)))))))) |
40785 | 339 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
340 ;;;###autoload |
40785 | 341 (defun calc-roll-up-stack (n &optional m) |
342 (if (< n 0) | |
343 (calc-roll-down-stack (- n) m) | |
344 (if (or (= n 0) (> n (calc-stack-size))) (setq n (calc-stack-size))) | |
345 (or m (setq m 1)) | |
346 (and (> n 1) | |
347 (< m n) | |
348 (if (and calc-any-selections | |
349 (not calc-use-selections)) | |
350 (calc-roll-up-with-selections n m) | |
351 (calc-pop-push-list n | |
352 (append (calc-top-list (- n m) 1) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
353 (calc-top-list m (- n m -1)))))))) |
40785 | 354 |
355 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
356 ;;;###autoload |
40785 | 357 (defun calc-do-refresh () |
358 (if calc-hyperbolic-flag | |
359 (progn | |
360 (setq calc-display-dirty t) | |
361 nil) | |
362 (calc-refresh) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
363 t)) |
40785 | 364 |
365 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
366 ;;;###autoload |
40785 | 367 (defun calc-record-list (vals &optional prefix) |
368 (while vals | |
369 (or (eq (car vals) 'top-of-stack) | |
370 (progn | |
371 (calc-record (car vals) prefix) | |
372 (setq prefix "..."))) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
373 (setq vals (cdr vals)))) |
40785 | 374 |
375 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
376 ;;;###autoload |
40785 | 377 (defun calc-last-args-stub (arg) |
378 (interactive "p") | |
58613
3eb7a394510d
(calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58543
diff
changeset
|
379 (require 'calc-ext) |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
380 (calc-last-args arg)) |
40785 | 381 |
382 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
383 ;;;###autoload |
40785 | 384 (defun calc-power (arg) |
385 (interactive "P") | |
386 (calc-slow-wrapper | |
58613
3eb7a394510d
(calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58543
diff
changeset
|
387 (if (and (featurep 'calc-ext) |
40785 | 388 (calc-is-inverse)) |
389 (calc-binary-op "root" 'calcFunc-nroot arg nil nil) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
390 (calc-binary-op "^" 'calcFunc-pow arg nil nil '^)))) |
40785 | 391 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
392 ;;;###autoload |
40785 | 393 (defun calc-mod (arg) |
394 (interactive "P") | |
395 (calc-slow-wrapper | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
396 (calc-binary-op "%" 'calcFunc-mod arg nil nil '%))) |
40785 | 397 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
398 ;;;###autoload |
40785 | 399 (defun calc-inv (arg) |
400 (interactive "P") | |
401 (calc-slow-wrapper | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
402 (calc-unary-op "inv" 'calcFunc-inv arg))) |
40785 | 403 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
404 ;;;###autoload |
40785 | 405 (defun calc-percent () |
406 (interactive) | |
407 (calc-slow-wrapper | |
408 (calc-pop-push-record-list | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
409 1 "%" (list (list 'calcFunc-percent (calc-top-n 1)))))) |
40785 | 410 |
411 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
412 ;;;###autoload |
40785 | 413 (defun calc-over (n) |
414 (interactive "P") | |
415 (if n | |
416 (calc-enter (- (prefix-numeric-value n))) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
417 (calc-enter -2))) |
40785 | 418 |
419 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
420 ;;;###autoload |
40785 | 421 (defun calc-pop-above (n) |
422 (interactive "P") | |
423 (if n | |
424 (calc-pop (- (prefix-numeric-value n))) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
425 (calc-pop -2))) |
40785 | 426 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
427 ;;;###autoload |
40785 | 428 (defun calc-roll-down (n) |
429 (interactive "P") | |
430 (calc-wrapper | |
431 (let ((nn (prefix-numeric-value n))) | |
432 (cond ((null n) | |
433 (calc-roll-down-stack 2)) | |
434 ((> nn 0) | |
435 (calc-roll-down-stack nn)) | |
436 ((= nn 0) | |
437 (calc-pop-push-list (calc-stack-size) | |
438 (reverse | |
439 (calc-top-list (calc-stack-size))))) | |
440 (t | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
441 (calc-roll-down-stack (calc-stack-size) (- nn))))))) |
40785 | 442 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
443 ;;;###autoload |
40785 | 444 (defun calc-roll-up (n) |
445 (interactive "P") | |
446 (calc-wrapper | |
447 (let ((nn (prefix-numeric-value n))) | |
448 (cond ((null n) | |
449 (calc-roll-up-stack 3)) | |
450 ((> nn 0) | |
451 (calc-roll-up-stack nn)) | |
452 ((= nn 0) | |
453 (calc-pop-push-list (calc-stack-size) | |
454 (reverse | |
455 (calc-top-list (calc-stack-size))))) | |
456 (t | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
457 (calc-roll-up-stack (calc-stack-size) (- nn))))))) |
40785 | 458 |
459 | |
460 | |
461 | |
462 ;;; Other commands. | |
463 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
464 ;;;###autoload |
40785 | 465 (defun calc-num-prefix-name (n) |
466 (cond ((eq n '-) "- ") | |
467 ((equal n '(4)) "C-u ") | |
468 ((consp n) (format "%d " (car n))) | |
469 ((integerp n) (format "%d " n)) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
470 (t ""))) |
40785 | 471 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
472 ;;;###autoload |
40785 | 473 (defun calc-missing-key (n) |
474 "This is a placeholder for a command which needs to be loaded from calc-ext. | |
475 When this key is used, calc-ext (the Calculator extensions module) will be | |
476 loaded and the keystroke automatically re-typed." | |
477 (interactive "P") | |
58613
3eb7a394510d
(calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58543
diff
changeset
|
478 (require 'calc-ext) |
40785 | 479 (if (keymapp (key-binding (char-to-string last-command-char))) |
480 (message "%s%c-" (calc-num-prefix-name n) last-command-char)) | |
481 (calc-unread-command) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
482 (setq prefix-arg n)) |
40785 | 483 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
484 ;;;###autoload |
40785 | 485 (defun calc-shift-Y-prefix-help () |
486 (interactive) | |
58613
3eb7a394510d
(calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58543
diff
changeset
|
487 (require 'calc-ext) |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
488 (calc-do-prefix-help calc-Y-help-msgs "other" ?Y)) |
40785 | 489 |
490 | |
491 | |
492 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
493 ;;;###autoload |
40785 | 494 (defun calcDigit-letter () |
495 (interactive) | |
496 (if (calc-minibuffer-contains "[-+]?\\(1[1-9]\\|[2-9][0-9]\\)#.*") | |
497 (progn | |
498 (setq last-command-char (upcase last-command-char)) | |
499 (calcDigit-key)) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
500 (calcDigit-nondigit))) |
40785 | 501 |
502 | |
503 ;; A Lisp version of temp_minibuffer_message from minibuf.c. | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
504 ;;;###autoload |
40785 | 505 (defun calc-temp-minibuffer-message (m) |
506 (let ((savemax (point-max))) | |
507 (save-excursion | |
508 (goto-char (point-max)) | |
509 (insert m)) | |
510 (let ((okay nil)) | |
511 (unwind-protect | |
512 (progn | |
513 (sit-for 2) | |
514 (identity 1) ; this forces a call to QUIT; in bytecode.c. | |
515 (setq okay t)) | |
516 (progn | |
517 (delete-region savemax (point-max)) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
518 (or okay (abort-recursive-edit))))))) |
40785 | 519 |
520 | |
521 (put 'math-with-extra-prec 'lisp-indent-hook 1) | |
522 | |
523 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
524 ;; Concatenate two vectors, or a vector and an object. [V O O] [Public] |
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
525 ;;;###autoload |
40785 | 526 (defun math-concat (v1 v2) |
527 (if (stringp v1) | |
528 (concat v1 v2) | |
58613
3eb7a394510d
(calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58543
diff
changeset
|
529 (require 'calc-ext) |
40785 | 530 (if (and (or (math-objvecp v1) (math-known-scalarp v1)) |
531 (or (math-objvecp v2) (math-known-scalarp v2))) | |
532 (append (if (and (math-vectorp v1) | |
533 (or (math-matrixp v1) | |
534 (not (math-matrixp v2)))) | |
535 v1 | |
536 (list 'vec v1)) | |
537 (if (and (math-vectorp v2) | |
538 (or (math-matrixp v2) | |
539 (not (math-matrixp v1)))) | |
540 (cdr v2) | |
541 (list v2))) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
542 (list '| v1 v2)))) |
40785 | 543 |
544 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
545 ;; True if A is zero. Works for un-normalized values. [P n] [Public] |
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
546 ;;;###autoload |
40785 | 547 (defun math-zerop (a) |
548 (if (consp a) | |
549 (cond ((memq (car a) '(bigpos bigneg)) | |
550 (while (eq (car (setq a (cdr a))) 0)) | |
551 (null a)) | |
552 ((memq (car a) '(frac float polar mod)) | |
553 (math-zerop (nth 1 a))) | |
554 ((eq (car a) 'cplx) | |
555 (and (math-zerop (nth 1 a)) (math-zerop (nth 2 a)))) | |
556 ((eq (car a) 'hms) | |
557 (and (math-zerop (nth 1 a)) | |
558 (math-zerop (nth 2 a)) | |
559 (math-zerop (nth 3 a))))) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
560 (eq a 0))) |
40785 | 561 |
562 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
563 ;; True if A is real and negative. [P n] [Public] |
40785 | 564 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
565 ;;;###autoload |
40785 | 566 (defun math-negp (a) |
567 (if (consp a) | |
568 (cond ((eq (car a) 'bigpos) nil) | |
569 ((eq (car a) 'bigneg) (cdr a)) | |
570 ((memq (car a) '(float frac)) | |
571 (Math-integer-negp (nth 1 a))) | |
572 ((eq (car a) 'hms) | |
573 (if (math-zerop (nth 1 a)) | |
574 (if (math-zerop (nth 2 a)) | |
575 (math-negp (nth 3 a)) | |
576 (math-negp (nth 2 a))) | |
577 (math-negp (nth 1 a)))) | |
578 ((eq (car a) 'date) | |
579 (math-negp (nth 1 a))) | |
580 ((eq (car a) 'intv) | |
581 (or (math-negp (nth 3 a)) | |
582 (and (math-zerop (nth 3 a)) | |
583 (memq (nth 1 a) '(0 2))))) | |
584 ((equal a '(neg (var inf var-inf))) t)) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
585 (< a 0))) |
40785 | 586 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
587 ;; True if A is a negative number or an expression the starts with '-'. |
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
588 ;;;###autoload |
40785 | 589 (defun math-looks-negp (a) ; [P x] [Public] |
590 (or (Math-negp a) | |
591 (eq (car-safe a) 'neg) | |
592 (and (memq (car-safe a) '(* /)) | |
593 (or (math-looks-negp (nth 1 a)) | |
594 (math-looks-negp (nth 2 a)))) | |
595 (and (eq (car-safe a) '-) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
596 (math-looks-negp (nth 1 a))))) |
40785 | 597 |
598 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
599 ;; True if A is real and positive. [P n] [Public] |
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
600 ;;;###autoload |
40785 | 601 (defun math-posp (a) |
602 (if (consp a) | |
603 (cond ((eq (car a) 'bigpos) (cdr a)) | |
604 ((eq (car a) 'bigneg) nil) | |
605 ((memq (car a) '(float frac)) | |
606 (Math-integer-posp (nth 1 a))) | |
607 ((eq (car a) 'hms) | |
608 (if (math-zerop (nth 1 a)) | |
609 (if (math-zerop (nth 2 a)) | |
610 (math-posp (nth 3 a)) | |
611 (math-posp (nth 2 a))) | |
612 (math-posp (nth 1 a)))) | |
613 ((eq (car a) 'date) | |
614 (math-posp (nth 1 a))) | |
615 ((eq (car a) 'mod) | |
616 (not (math-zerop (nth 1 a)))) | |
617 ((eq (car a) 'intv) | |
618 (or (math-posp (nth 2 a)) | |
619 (and (math-zerop (nth 2 a)) | |
620 (memq (nth 1 a) '(0 1))))) | |
621 ((equal a '(var inf var-inf)) t)) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
622 (> a 0))) |
40785 | 623 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
624 ;;;###autoload |
41267
e9718841a5b1
(math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents:
41045
diff
changeset
|
625 (defalias 'math-fixnump 'integerp) |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
626 ;;;###autoload |
41267
e9718841a5b1
(math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents:
41045
diff
changeset
|
627 (defalias 'math-fixnatnump 'natnump) |
40785 | 628 |
629 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
630 ;; True if A is an even integer. [P R R] [Public] |
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
631 ;;;###autoload |
40785 | 632 (defun math-evenp (a) |
633 (if (consp a) | |
634 (and (memq (car a) '(bigpos bigneg)) | |
635 (= (% (nth 1 a) 2) 0)) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
636 (= (% a 2) 0))) |
40785 | 637 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
638 ;; Compute A / 2, for small or big integer A. [I i] |
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
639 ;; If A is negative, type of truncation is undefined. |
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
640 ;;;###autoload |
40785 | 641 (defun math-div2 (a) |
642 (if (consp a) | |
643 (if (cdr a) | |
644 (math-normalize (cons (car a) (math-div2-bignum (cdr a)))) | |
645 0) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
646 (/ a 2))) |
40785 | 647 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
648 ;;;###autoload |
40785 | 649 (defun math-div2-bignum (a) ; [l l] |
650 (if (cdr a) | |
81596
d175ac539ca9
(math-div2-bignum): Use math-bignum-digit-size.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
77465
diff
changeset
|
651 (cons (+ (/ (car a) 2) (* (% (nth 1 a) 2) (/ math-bignum-digit-size 2))) |
40785 | 652 (math-div2-bignum (cdr a))) |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
653 (list (/ (car a) 2)))) |
40785 | 654 |
655 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
656 ;; Reject an argument to a calculator function. [Public] |
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
657 ;;;###autoload |
40785 | 658 (defun math-reject-arg (&optional a p option) |
659 (if option | |
660 (calc-record-why option p a) | |
661 (if p | |
662 (calc-record-why p a))) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
663 (signal 'wrong-type-argument (and a (if p (list p a) (list a))))) |
40785 | 664 |
665 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
666 ;; Coerce A to be an integer (by truncation toward zero). [I N] [Public] |
58480
d11199c971ec
(math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57711
diff
changeset
|
667 |
d11199c971ec
(math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57711
diff
changeset
|
668 ;; The variable math-trunc-prec is local to math-trunc, but used by |
d11199c971ec
(math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57711
diff
changeset
|
669 ;; math-trunc-fancy in calc-arith.el, which is called by math-trunc. |
d11199c971ec
(math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57711
diff
changeset
|
670 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
671 ;;;###autoload |
58480
d11199c971ec
(math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57711
diff
changeset
|
672 (defun math-trunc (a &optional math-trunc-prec) |
d11199c971ec
(math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57711
diff
changeset
|
673 (cond (math-trunc-prec |
58613
3eb7a394510d
(calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58543
diff
changeset
|
674 (require 'calc-ext) |
58480
d11199c971ec
(math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57711
diff
changeset
|
675 (math-trunc-special a math-trunc-prec)) |
40785 | 676 ((Math-integerp a) a) |
677 ((Math-looks-negp a) | |
678 (math-neg (math-trunc (math-neg a)))) | |
679 ((eq (car a) 'float) | |
680 (math-scale-int (nth 1 a) (nth 2 a))) | |
58613
3eb7a394510d
(calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58543
diff
changeset
|
681 (t (require 'calc-ext) |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
682 (math-trunc-fancy a)))) |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
683 ;;;###autoload |
41267
e9718841a5b1
(math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents:
41045
diff
changeset
|
684 (defalias 'calcFunc-trunc 'math-trunc) |
40785 | 685 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
686 ;; Coerce A to be an integer (by truncation toward minus infinity). [I N] |
58480
d11199c971ec
(math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57711
diff
changeset
|
687 |
d11199c971ec
(math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57711
diff
changeset
|
688 ;; The variable math-floor-prec is local to math-floor, but used by |
d11199c971ec
(math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57711
diff
changeset
|
689 ;; math-floor-fancy in calc-arith.el, which is called by math-floor. |
d11199c971ec
(math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57711
diff
changeset
|
690 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
691 ;;;###autoload |
58480
d11199c971ec
(math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57711
diff
changeset
|
692 (defun math-floor (a &optional math-floor-prec) ; [Public] |
d11199c971ec
(math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57711
diff
changeset
|
693 (cond (math-floor-prec |
58613
3eb7a394510d
(calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58543
diff
changeset
|
694 (require 'calc-ext) |
58480
d11199c971ec
(math-trunc): Replace variable prec by math-trunc-prec.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57711
diff
changeset
|
695 (math-floor-special a math-floor-prec)) |
40785 | 696 ((Math-integerp a) a) |
697 ((Math-messy-integerp a) (math-trunc a)) | |
698 ((Math-realp a) | |
699 (if (Math-negp a) | |
700 (math-add (math-trunc a) -1) | |
701 (math-trunc a))) | |
58613
3eb7a394510d
(calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58543
diff
changeset
|
702 (t (require 'calc-ext) |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
703 (math-floor-fancy a)))) |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
704 ;;;###autoload |
41267
e9718841a5b1
(math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents:
41045
diff
changeset
|
705 (defalias 'calcFunc-floor 'math-floor) |
40785 | 706 |
707 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
708 ;;;###autoload |
40785 | 709 (defun math-imod (a b) ; [I I I] [Public] |
710 (if (and (not (consp a)) (not (consp b))) | |
711 (if (= b 0) | |
712 (math-reject-arg a "*Division by zero") | |
713 (% a b)) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
714 (cdr (math-idivmod a b)))) |
40785 | 715 |
716 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
717 ;;;###autoload |
40785 | 718 (defun calcFunc-inv (m) |
719 (if (Math-vectorp m) | |
720 (progn | |
58613
3eb7a394510d
(calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58543
diff
changeset
|
721 (require 'calc-ext) |
40785 | 722 (if (math-square-matrixp m) |
723 (or (math-with-extra-prec 2 (math-matrix-inv-raw m)) | |
724 (math-reject-arg m "*Singular matrix")) | |
725 (math-reject-arg m 'square-matrixp))) | |
66480
feb65aa82eeb
(calcFunc-inv): Check for symbolic matrices.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
64325
diff
changeset
|
726 (if (and |
feb65aa82eeb
(calcFunc-inv): Check for symbolic matrices.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
64325
diff
changeset
|
727 (require 'calc-arith) |
feb65aa82eeb
(calcFunc-inv): Check for symbolic matrices.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
64325
diff
changeset
|
728 (math-known-matrixp m)) |
feb65aa82eeb
(calcFunc-inv): Check for symbolic matrices.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
64325
diff
changeset
|
729 (math-pow m -1) |
feb65aa82eeb
(calcFunc-inv): Check for symbolic matrices.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
64325
diff
changeset
|
730 (math-div 1 m)))) |
40785 | 731 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
732 ;;;###autoload |
40785 | 733 (defun math-do-working (msg arg) |
40998
ee9c2872370b
Use `frame-width' instead of `screen-width',
Eli Zaretskii <eliz@gnu.org>
parents:
40785
diff
changeset
|
734 (or executing-kbd-macro |
40785 | 735 (progn |
736 (calc-set-command-flag 'clear-message) | |
737 (if math-working-step | |
738 (if math-working-step-2 | |
739 (setq msg (format "[%d/%d] %s" | |
740 math-working-step math-working-step-2 msg)) | |
741 (setq msg (format "[%d] %s" math-working-step msg)))) | |
742 (message "Working... %s = %s" msg | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
743 (math-showing-full-precision (math-format-number arg)))))) |
40785 | 744 |
745 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
746 ;; Compute A modulo B, defined in terms of truncation toward minus infinity. |
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
747 ;;;###autoload |
40785 | 748 (defun math-mod (a b) ; [R R R] [Public] |
749 (cond ((and (Math-zerop a) (not (eq (car-safe a) 'mod))) a) | |
750 ((Math-zerop b) | |
751 (math-reject-arg a "*Division by zero")) | |
752 ((and (Math-natnump a) (Math-natnump b)) | |
753 (math-imod a b)) | |
754 ((and (Math-anglep a) (Math-anglep b)) | |
755 (math-sub a (math-mul (math-floor (math-div a b)) b))) | |
58613
3eb7a394510d
(calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58543
diff
changeset
|
756 (t (require 'calc-ext) |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
757 (math-mod-fancy a b)))) |
40785 | 758 |
759 | |
760 | |
761 ;;; General exponentiation. | |
762 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
763 ;;;###autoload |
40785 | 764 (defun math-pow (a b) ; [O O N] [Public] |
765 (cond ((equal b '(var nan var-nan)) | |
766 b) | |
767 ((Math-zerop a) | |
768 (if (and (Math-scalarp b) (Math-posp b)) | |
769 (if (math-floatp b) (math-float a) a) | |
58613
3eb7a394510d
(calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58543
diff
changeset
|
770 (require 'calc-ext) |
40785 | 771 (math-pow-of-zero a b))) |
772 ((or (eq a 1) (eq b 1)) a) | |
773 ((or (equal a '(float 1 0)) (equal b '(float 1 0))) a) | |
774 ((Math-zerop b) | |
775 (if (Math-scalarp a) | |
776 (if (or (math-floatp a) (math-floatp b)) | |
777 '(float 1 0) 1) | |
58613
3eb7a394510d
(calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58543
diff
changeset
|
778 (require 'calc-ext) |
40785 | 779 (math-pow-zero a b))) |
780 ((and (Math-integerp b) (or (Math-numberp a) (Math-vectorp a))) | |
781 (if (and (equal a '(float 1 1)) (integerp b)) | |
782 (math-make-float 1 b) | |
783 (math-with-extra-prec 2 | |
784 (math-ipow a b)))) | |
785 (t | |
58613
3eb7a394510d
(calc-do-handle-whys, calc-last-args-stub, calc-missing-key)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58543
diff
changeset
|
786 (require 'calc-ext) |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
787 (math-pow-fancy a b)))) |
40785 | 788 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
789 ;;;###autoload |
40785 | 790 (defun math-ipow (a n) ; [O O I] [Public] |
791 (cond ((Math-integer-negp n) | |
792 (math-ipow (math-div 1 a) (Math-integer-neg n))) | |
793 ((not (consp n)) | |
794 (if (and (Math-ratp a) (> n 20)) | |
795 (math-iipow-show a n) | |
796 (math-iipow a n))) | |
797 ((math-evenp n) | |
798 (math-ipow (math-mul a a) (math-div2 n))) | |
799 (t | |
800 (math-mul a (math-ipow (math-mul a a) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
801 (math-div2 (math-add n -1))))))) |
40785 | 802 |
803 (defun math-iipow (a n) ; [O O S] | |
804 (cond ((= n 0) 1) | |
805 ((= n 1) a) | |
806 ((= (% n 2) 0) (math-iipow (math-mul a a) (/ n 2))) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
807 (t (math-mul a (math-iipow (math-mul a a) (/ n 2)))))) |
40785 | 808 |
809 (defun math-iipow-show (a n) ; [O O S] | |
810 (math-working "pow" a) | |
811 (let ((val (cond | |
812 ((= n 0) 1) | |
813 ((= n 1) a) | |
814 ((= (% n 2) 0) (math-iipow-show (math-mul a a) (/ n 2))) | |
815 (t (math-mul a (math-iipow-show (math-mul a a) (/ n 2))))))) | |
816 (math-working "pow" val) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
817 val)) |
40785 | 818 |
819 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
820 ;;;###autoload |
40785 | 821 (defun math-read-radix-digit (dig) ; [D S; Z S] |
822 (if (> dig ?9) | |
823 (if (< dig ?A) | |
824 nil | |
825 (- dig 55)) | |
826 (if (>= dig ?0) | |
827 (- dig ?0) | |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
828 nil))) |
40785 | 829 |
830 | |
831 ;;; Bug reporting | |
832 | |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
833 ;;;###autoload |
41377
be3e9c2f0159
(report-calc-bug): Use `reporter-prompt-for-summary-p'.
Colin Walters <walters@gnu.org>
parents:
41363
diff
changeset
|
834 (defun report-calc-bug () |
40785 | 835 "Report a bug in Calc, the GNU Emacs calculator. |
836 Prompts for bug subject. Leaves you in a mail buffer." | |
41377
be3e9c2f0159
(report-calc-bug): Use `reporter-prompt-for-summary-p'.
Colin Walters <walters@gnu.org>
parents:
41363
diff
changeset
|
837 (interactive) |
be3e9c2f0159
(report-calc-bug): Use `reporter-prompt-for-summary-p'.
Colin Walters <walters@gnu.org>
parents:
41363
diff
changeset
|
838 (let ((reporter-prompt-for-summary-p t)) |
be3e9c2f0159
(report-calc-bug): Use `reporter-prompt-for-summary-p'.
Colin Walters <walters@gnu.org>
parents:
41363
diff
changeset
|
839 (reporter-submit-bug-report calc-bug-address "Calc" '(calc-version) |
be3e9c2f0159
(report-calc-bug): Use `reporter-prompt-for-summary-p'.
Colin Walters <walters@gnu.org>
parents:
41363
diff
changeset
|
840 nil nil |
be3e9c2f0159
(report-calc-bug): Use `reporter-prompt-for-summary-p'.
Colin Walters <walters@gnu.org>
parents:
41363
diff
changeset
|
841 "Please describe exactly what actions triggered the bug and the |
41363
f17cae9ea728
(report-calc-bug): Use reporter.el.
Colin Walters <walters@gnu.org>
parents:
41359
diff
changeset
|
842 precise symptoms of the bug. If possible, include a backtrace by |
f17cae9ea728
(report-calc-bug): Use reporter.el.
Colin Walters <walters@gnu.org>
parents:
41359
diff
changeset
|
843 doing 'M-x toggle-debug-on-error', then reproducing the bug. |
41377
be3e9c2f0159
(report-calc-bug): Use `reporter-prompt-for-summary-p'.
Colin Walters <walters@gnu.org>
parents:
41363
diff
changeset
|
844 " ))) |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
845 ;;;###autoload |
41267
e9718841a5b1
(math-fixnump, math-fixnatnump, calcFunc-trunc)
Colin Walters <walters@gnu.org>
parents:
41045
diff
changeset
|
846 (defalias 'calc-report-bug 'report-calc-bug) |
40785 | 847 |
58664
f23c98cc77a1
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58613
diff
changeset
|
848 (provide 'calc-misc) |
f23c98cc77a1
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58613
diff
changeset
|
849 |
93880
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
850 ;; Local variables: |
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
851 ;; generated-autoload-file: "calc-loaddefs.el" |
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
852 ;; End: |
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
853 |
c6152337e4ad
* calc/calc.el: Load "cal-loaddefs" rather than set up autoloads manually.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
854 ;; arch-tag: 7984d9d0-62e5-41dc-afb8-e904b975f250 |
41045
3491bfbd825e
(math-fixnump, math-fixnatnump, calcFunc-trunc, calcFunc-floor,
Colin Walters <walters@gnu.org>
parents:
40998
diff
changeset
|
855 ;;; calc-misc.el ends here |