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