40785
|
1 ;; Calculator for GNU Emacs, part II [calc-mode.el]
|
|
2 ;; Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
|
|
3 ;; Written by Dave Gillespie, daveg@synaptics.com.
|
|
4
|
|
5 ;; This file is part of GNU Emacs.
|
|
6
|
|
7 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
8 ;; but WITHOUT ANY WARRANTY. No author or distributor
|
|
9 ;; accepts responsibility to anyone for the consequences of using it
|
|
10 ;; or for whether it serves any particular purpose or works at all,
|
|
11 ;; unless he says so in writing. Refer to the GNU Emacs General Public
|
|
12 ;; License for full details.
|
|
13
|
|
14 ;; Everyone is granted permission to copy, modify and redistribute
|
|
15 ;; GNU Emacs, but only under the conditions described in the
|
|
16 ;; GNU Emacs General Public License. A copy of this license is
|
|
17 ;; supposed to have been given to you along with GNU Emacs so you
|
|
18 ;; can know your rights and responsibilities. It should be in a
|
|
19 ;; file named COPYING. Among other things, the copyright notice
|
|
20 ;; and this notice must be preserved on all copies.
|
|
21
|
|
22
|
|
23
|
|
24 ;; This file is autoloaded from calc-ext.el.
|
|
25 (require 'calc-ext)
|
|
26
|
|
27 (require 'calc-macs)
|
|
28
|
|
29 (defun calc-Need-calc-mode () nil)
|
|
30
|
|
31
|
|
32 (defun calc-line-numbering (n)
|
|
33 (interactive "P")
|
|
34 (calc-wrapper
|
|
35 (message (if (calc-change-mode 'calc-line-numbering n t t)
|
|
36 "Displaying stack level numbers."
|
|
37 "Hiding stack level numbers.")))
|
|
38 )
|
|
39
|
|
40 (defun calc-line-breaking (n)
|
|
41 (interactive "P")
|
|
42 (calc-wrapper
|
|
43 (setq n (if n
|
|
44 (and (> (setq n (prefix-numeric-value n)) 0)
|
|
45 (or (< n 5)
|
|
46 n))
|
|
47 (not calc-line-breaking)))
|
|
48 (if (calc-change-mode 'calc-line-breaking n t)
|
|
49 (if (integerp calc-line-breaking)
|
|
50 (message "Breaking lines longer than %d characters." n)
|
|
51 (message "Breaking long lines in Stack display."))
|
|
52 (message "Not breaking long lines in Stack display.")))
|
|
53 )
|
|
54
|
|
55
|
|
56 (defun calc-left-justify (n)
|
|
57 (interactive "P")
|
|
58 (calc-wrapper
|
|
59 (and n (setq n (prefix-numeric-value n)))
|
|
60 (calc-change-mode '(calc-display-just calc-display-origin)
|
|
61 (list nil n) t)
|
|
62 (if n
|
|
63 (message "Displaying stack entries indented by %d." n)
|
|
64 (message "Displaying stack entries left-justified.")))
|
|
65 )
|
|
66
|
|
67 (defun calc-center-justify (n)
|
|
68 (interactive "P")
|
|
69 (calc-wrapper
|
|
70 (and n (setq n (prefix-numeric-value n)))
|
|
71 (calc-change-mode '(calc-display-just calc-display-origin)
|
|
72 (list 'center n) t)
|
|
73 (if n
|
|
74 (message "Displaying stack entries centered on column %d." n)
|
|
75 (message "Displaying stack entries centered in window.")))
|
|
76 )
|
|
77
|
|
78 (defun calc-right-justify (n)
|
|
79 (interactive "P")
|
|
80 (calc-wrapper
|
|
81 (and n (setq n (prefix-numeric-value n)))
|
|
82 (calc-change-mode '(calc-display-just calc-display-origin)
|
|
83 (list 'right n) t)
|
|
84 (if n
|
|
85 (message "Displaying stack entries right-justified to column %d." n)
|
|
86 (message "Displaying stack entries right-justified in window.")))
|
|
87 )
|
|
88
|
|
89 (defun calc-left-label (s)
|
|
90 (interactive "sLefthand label: ")
|
|
91 (calc-wrapper
|
|
92 (or (equal s "")
|
|
93 (setq s (concat s " ")))
|
|
94 (calc-change-mode 'calc-left-label s t))
|
|
95 )
|
|
96
|
|
97 (defun calc-right-label (s)
|
|
98 (interactive "sRighthand label: ")
|
|
99 (calc-wrapper
|
|
100 (or (equal s "")
|
|
101 (setq s (concat " " s)))
|
|
102 (calc-change-mode 'calc-right-label s t))
|
|
103 )
|
|
104
|
|
105 (defun calc-auto-why (n)
|
|
106 (interactive "P")
|
|
107 (calc-wrapper
|
|
108 (if n
|
|
109 (progn
|
|
110 (setq n (prefix-numeric-value n))
|
|
111 (if (<= n 0) (setq n nil)
|
|
112 (if (> n 1) (setq n t))))
|
|
113 (setq n (and (not (eq calc-auto-why t)) (if calc-auto-why t 1))))
|
|
114 (calc-change-mode 'calc-auto-why n nil)
|
|
115 (cond ((null n)
|
|
116 (message "User must press `w' to explain unsimplified results."))
|
|
117 ((eq n t)
|
|
118 (message "Automatically doing `w' to explain unsimplified results."))
|
|
119 (t
|
|
120 (message "Automatically doing `w' only for unusual messages."))))
|
|
121 )
|
|
122
|
|
123 (defun calc-group-digits (n)
|
|
124 (interactive "P")
|
|
125 (calc-wrapper
|
|
126 (if n
|
|
127 (progn
|
|
128 (setq n (prefix-numeric-value n))
|
|
129 (cond ((or (> n 0) (< n -1)))
|
|
130 ((= n -1)
|
|
131 (setq n nil))
|
|
132 (t
|
|
133 (setq n calc-group-digits))))
|
|
134 (setq n (not calc-group-digits)))
|
|
135 (calc-change-mode 'calc-group-digits n t)
|
|
136 (cond ((null n)
|
|
137 (message "Grouping is off."))
|
|
138 ((integerp n)
|
|
139 (message "Grouping every %d digits." (math-abs n)))
|
|
140 (t
|
|
141 (message "Grouping is on."))))
|
|
142 )
|
|
143
|
|
144 (defun calc-group-char (ch)
|
|
145 (interactive "cGrouping character: ")
|
|
146 (calc-wrapper
|
|
147 (or (>= ch 32)
|
|
148 (error "Control characters not allowed for grouping."))
|
|
149 (if (= ch ?\\)
|
|
150 (setq ch "\\,")
|
|
151 (setq ch (char-to-string ch)))
|
|
152 (calc-change-mode 'calc-group-char ch calc-group-digits)
|
|
153 (message "Digit grouping character is \"%s\"." ch))
|
|
154 )
|
|
155
|
|
156 (defun calc-point-char (ch)
|
|
157 (interactive "cCharacter to use as decimal point: ")
|
|
158 (calc-wrapper
|
|
159 (or (>= ch 32)
|
|
160 (error "Control characters not allowed as decimal point."))
|
|
161 (calc-change-mode 'calc-point-char (char-to-string ch) t)
|
|
162 (message "Decimal point character is \"%c\"." ch))
|
|
163 )
|
|
164
|
|
165 (defun calc-normal-notation (n)
|
|
166 (interactive "P")
|
|
167 (calc-wrapper
|
|
168 (calc-change-mode 'calc-float-format
|
|
169 (let* ((val (if n (prefix-numeric-value n) 0))
|
|
170 (mode (/ (+ val 5000) 10000)))
|
|
171 (if (or (< val -5000) (> mode 3))
|
|
172 (error "Prefix out of range"))
|
|
173 (setq n (list (aref [float sci eng fix] mode)
|
|
174 (- (% (+ val 5000) 10000) 5000))))
|
|
175 t)
|
|
176 (if (eq (nth 1 n) 0)
|
|
177 (message "Displaying floating-point numbers normally.")
|
|
178 (if (> (nth 1 n) 0)
|
|
179 (message
|
|
180 "Displaying floating-point numbers with %d significant digits."
|
|
181 (nth 1 n))
|
|
182 (message "Displaying floating-point numbers with (precision%d)."
|
|
183 (nth 1 n)))))
|
|
184 )
|
|
185
|
|
186 (defun calc-fix-notation (n)
|
|
187 (interactive "NDigits after decimal point: ")
|
|
188 (calc-wrapper
|
|
189 (calc-change-mode 'calc-float-format
|
|
190 (setq n (list 'fix (if n (prefix-numeric-value n) 0)))
|
|
191 t)
|
|
192 (message "Displaying floats with %d digits after decimal."
|
|
193 (math-abs (nth 1 n))))
|
|
194 )
|
|
195
|
|
196 (defun calc-sci-notation (n)
|
|
197 (interactive "P")
|
|
198 (calc-wrapper
|
|
199 (calc-change-mode 'calc-float-format
|
|
200 (setq n (list 'sci (if n (prefix-numeric-value n) 0)))
|
|
201 t)
|
|
202 (if (eq (nth 1 n) 0)
|
|
203 (message "Displaying floats in scientific notation.")
|
|
204 (if (> (nth 1 n) 0)
|
|
205 (message "Displaying scientific notation with %d significant digits."
|
|
206 (nth 1 n))
|
|
207 (message "Displaying scientific notation with (precision%d)."
|
|
208 (nth 1 n)))))
|
|
209 )
|
|
210
|
|
211 (defun calc-eng-notation (n)
|
|
212 (interactive "P")
|
|
213 (calc-wrapper
|
|
214 (calc-change-mode 'calc-float-format
|
|
215 (setq n (list 'eng (if n (prefix-numeric-value n) 0)))
|
|
216 t)
|
|
217 (if (eq (nth 1 n) 0)
|
|
218 (message "Displaying floats in engineering notation.")
|
|
219 (if (> (nth 1 n) 0)
|
|
220 (message "Displaying engineering notation with %d significant digits."
|
|
221 (nth 1 n))
|
|
222 (message "Displaying engineering notation with (precision%d)."
|
|
223 (nth 1 n)))))
|
|
224 )
|
|
225
|
|
226
|
|
227 (defun calc-truncate-stack (n &optional rel)
|
|
228 (interactive "P")
|
|
229 (calc-wrapper
|
|
230 (let ((oldtop calc-stack-top)
|
|
231 (newtop calc-stack-top))
|
|
232 (calc-record-undo (list 'set 'saved-stack-top calc-stack-top))
|
|
233 (let ((calc-stack-top 0)
|
|
234 (nn (prefix-numeric-value n)))
|
|
235 (setq newtop
|
|
236 (if n
|
|
237 (progn
|
|
238 (if rel
|
|
239 (setq nn (+ oldtop nn))
|
|
240 (if (< nn 0)
|
|
241 (setq nn (+ nn (calc-stack-size)))
|
|
242 (setq nn (1+ nn))))
|
|
243 (if (< nn 1)
|
|
244 1
|
|
245 (if (> nn (calc-stack-size))
|
|
246 (calc-stack-size)
|
|
247 nn)))
|
|
248 (max 1 (calc-locate-cursor-element (point)))))
|
|
249 (if (= newtop oldtop)
|
|
250 ()
|
|
251 (calc-pop-stack 1 oldtop t)
|
|
252 (calc-push-list '(top-of-stack) newtop)
|
|
253 (if calc-line-numbering
|
|
254 (calc-refresh))))
|
|
255 (calc-record-undo (list 'set 'saved-stack-top 0))
|
|
256 (setq calc-stack-top newtop)))
|
|
257 )
|
|
258
|
|
259 (defun calc-truncate-up (n)
|
|
260 (interactive "p")
|
|
261 (calc-truncate-stack n t)
|
|
262 )
|
|
263
|
|
264 (defun calc-truncate-down (n)
|
|
265 (interactive "p")
|
|
266 (calc-truncate-stack (- n) t)
|
|
267 )
|
|
268
|
|
269 (defun calc-display-raw (arg)
|
|
270 (interactive "P")
|
|
271 (calc-wrapper
|
|
272 (setq calc-display-raw (if calc-display-raw nil (if arg 0 t)))
|
|
273 (calc-do-refresh)
|
|
274 (if calc-display-raw
|
|
275 (message "Press d ' again to cancel \"raw\" display mode.")))
|
|
276 )
|
|
277
|
|
278
|
|
279
|
|
280
|
|
281 ;;; Mode commands.
|
|
282
|
|
283 (defun calc-save-modes (&optional quiet)
|
|
284 (interactive)
|
|
285 (calc-wrapper
|
|
286 (let (pos
|
|
287 (vals (mapcar (function (lambda (v) (symbol-value (car v))))
|
|
288 calc-mode-var-list)))
|
|
289 (set-buffer (find-file-noselect (substitute-in-file-name
|
|
290 calc-settings-file)))
|
|
291 (goto-char (point-min))
|
|
292 (if (and (search-forward ";;; Mode settings stored by Calc" nil t)
|
|
293 (progn
|
|
294 (beginning-of-line)
|
|
295 (setq pos (point))
|
|
296 (search-forward "\n;;; End of mode settings" nil t)))
|
|
297 (progn
|
|
298 (beginning-of-line)
|
|
299 (forward-line 1)
|
|
300 (delete-region pos (point)))
|
|
301 (goto-char (point-max))
|
|
302 (insert "\n\n")
|
|
303 (forward-char -1))
|
|
304 (insert ";;; Mode settings stored by Calc on " (current-time-string) "\n")
|
|
305 (let ((list calc-mode-var-list))
|
|
306 (while list
|
|
307 (let* ((v (car (car list)))
|
|
308 (def (nth 1 (car list)))
|
|
309 (val (car vals)))
|
|
310 (or (equal val def)
|
|
311 (progn
|
|
312 (insert "(setq " (symbol-name v) " ")
|
|
313 (if (and (or (listp val)
|
|
314 (symbolp val))
|
|
315 (not (memq val '(nil t))))
|
|
316 (insert "'"))
|
|
317 (insert (prin1-to-string val) ")\n"))))
|
|
318 (setq list (cdr list)
|
|
319 vals (cdr vals))))
|
|
320 (run-hooks 'calc-mode-save-hook)
|
|
321 (insert ";;; End of mode settings\n")
|
|
322 (if quiet
|
|
323 (let ((executing-macro "")) ; what a kludge!
|
|
324 (save-buffer))
|
|
325 (save-buffer))))
|
|
326 )
|
|
327
|
|
328 (defun calc-settings-file-name (name &optional arg)
|
|
329 (interactive "sSettings file name (normally ~/.emacs): \nP")
|
|
330 (calc-wrapper
|
|
331 (setq arg (if arg (prefix-numeric-value arg) 0))
|
|
332 (if (equal name "")
|
|
333 (message "Calc settings file is \"%s\"" calc-settings-file)
|
|
334 (if (< (math-abs arg) 2)
|
|
335 (let ((list calc-mode-var-list))
|
|
336 (while list
|
|
337 (set (car (car list)) (nth 1 (car list)))
|
|
338 (setq list (cdr list)))))
|
|
339 (setq calc-settings-file name)
|
|
340 (or (and (string-match "\\.emacs" calc-settings-file)
|
|
341 (> arg 0))
|
|
342 (< arg 0)
|
|
343 (load name t)
|
|
344 (message "New file"))))
|
|
345 )
|
|
346
|
|
347 (defun math-get-modes-vec ()
|
|
348 (list 'vec
|
|
349 calc-internal-prec
|
|
350 calc-word-size
|
|
351 (calc-stack-size)
|
|
352 calc-number-radix
|
|
353 (+ (if (<= (nth 1 calc-float-format) 0)
|
|
354 (+ calc-internal-prec (nth 1 calc-float-format))
|
|
355 (nth 1 calc-float-format))
|
|
356 (cdr (assq (car calc-float-format)
|
|
357 '((float . 0) (sci . 10000)
|
|
358 (eng . 20000) (fix . 30000)))))
|
|
359 (cond ((eq calc-angle-mode 'rad) 2)
|
|
360 ((eq calc-angle-mode 'hms) 3)
|
|
361 (t 1))
|
|
362 (if calc-symbolic-mode 1 0)
|
|
363 (if calc-prefer-frac 1 0)
|
|
364 (if (eq calc-complex-mode 'polar) 1 0)
|
|
365 (cond ((eq calc-matrix-mode 'scalar) 0)
|
|
366 ((eq calc-matrix-mode 'matrix) -2)
|
|
367 (calc-matrix-mode)
|
|
368 (t -1))
|
|
369 (cond ((eq calc-simplify-mode 'none) -1)
|
|
370 ((eq calc-simplify-mode 'num) 0)
|
|
371 ((eq calc-simplify-mode 'binary) 2)
|
|
372 ((eq calc-simplify-mode 'alg) 3)
|
|
373 ((eq calc-simplify-mode 'ext) 4)
|
|
374 ((eq calc-simplify-mode 'units) 5)
|
|
375 (t 1))
|
|
376 (cond ((eq calc-infinite-mode 1) 0)
|
|
377 (calc-infinite-mode 1)
|
|
378 (t -1)))
|
|
379 )
|
|
380
|
|
381 (defun calc-get-modes (n)
|
|
382 (interactive "P")
|
|
383 (calc-wrapper
|
|
384 (let ((modes (math-get-modes-vec)))
|
|
385 (calc-enter-result 0 "mode"
|
|
386 (if n
|
|
387 (if (and (>= (setq n (prefix-numeric-value n)) 1)
|
|
388 (< n (length modes)))
|
|
389 (nth n modes)
|
|
390 (error "Prefix out of range"))
|
|
391 modes))))
|
|
392 )
|
|
393
|
|
394 (defun calc-shift-prefix (arg)
|
|
395 (interactive "P")
|
|
396 (calc-wrapper
|
|
397 (setq calc-shift-prefix (if arg
|
|
398 (> (prefix-numeric-value arg) 0)
|
|
399 (not calc-shift-prefix)))
|
|
400 (calc-init-prefixes)
|
|
401 (message (if calc-shift-prefix
|
|
402 "Prefix keys are now case-insensitive"
|
|
403 "Prefix keys must be unshifted (except V, Z)")))
|
|
404 )
|
|
405
|
|
406 (defun calc-mode-record-mode (n)
|
|
407 (interactive "P")
|
|
408 (calc-wrapper
|
|
409 (calc-change-mode 'calc-mode-save-mode
|
|
410 (cond ((null n)
|
|
411 (cond ((not calc-embedded-info)
|
|
412 (if (eq calc-mode-save-mode 'save)
|
|
413 'local 'save))
|
|
414 ((eq calc-mode-save-mode 'local) 'edit)
|
|
415 ((eq calc-mode-save-mode 'edit) 'perm)
|
|
416 ((eq calc-mode-save-mode 'perm) 'global)
|
|
417 ((eq calc-mode-save-mode 'global) 'save)
|
|
418 ((eq calc-mode-save-mode 'save) nil)
|
|
419 ((eq calc-mode-save-mode nil) 'local)))
|
|
420 ((= (setq n (prefix-numeric-value n)) 0) nil)
|
|
421 ((= n 2) 'edit)
|
|
422 ((= n 3) 'perm)
|
|
423 ((= n 4) 'global)
|
|
424 ((= n 5) 'save)
|
|
425 (t 'local)))
|
|
426 (message (cond ((and (eq calc-mode-save-mode 'local) calc-embedded-info)
|
|
427 "Recording mode changes with [calc-mode: ...]")
|
|
428 ((eq calc-mode-save-mode 'edit)
|
|
429 "Recording mode changes with [calc-edit-mode: ...]")
|
|
430 ((eq calc-mode-save-mode 'perm)
|
|
431 "Recording mode changes with [calc-perm-mode: ...]")
|
|
432 ((eq calc-mode-save-mode 'global)
|
|
433 "Recording mode changes with [calc-global-mode: ...]")
|
|
434 ((eq calc-mode-save-mode 'save)
|
|
435 (format "Recording mode changes in \"%s\"."
|
|
436 calc-settings-file))
|
|
437 (t
|
|
438 "Not recording mode changes permanently."))))
|
|
439 )
|
|
440
|
|
441 (defun calc-total-algebraic-mode (flag)
|
|
442 (interactive "P")
|
|
443 (if calc-emacs-type-19
|
|
444 (error "Total algebraic mode not yet supported for Emacs 19"))
|
|
445 (calc-wrapper
|
|
446 (if (eq calc-algebraic-mode 'total)
|
|
447 (calc-algebraic-mode nil)
|
|
448 (calc-change-mode '(calc-algebraic-mode calc-incomplete-algebraic-mode)
|
|
449 '(total nil))
|
|
450 (use-local-map calc-alg-map)
|
|
451 (message
|
|
452 "All keys begin algebraic entry; use Meta (ESC) for Calc keys.")))
|
|
453 )
|
|
454
|
|
455 (defun calc-algebraic-mode (flag)
|
|
456 (interactive "P")
|
|
457 (calc-wrapper
|
|
458 (if flag
|
|
459 (calc-change-mode '(calc-algebraic-mode
|
|
460 calc-incomplete-algebraic-mode)
|
|
461 (list nil (not calc-incomplete-algebraic-mode)))
|
|
462 (calc-change-mode '(calc-algebraic-mode calc-incomplete-algebraic-mode)
|
|
463 (list (not calc-algebraic-mode) nil)))
|
|
464 (use-local-map calc-mode-map)
|
|
465 (message (if calc-algebraic-mode
|
|
466 "Numeric keys and ( and [ begin algebraic entry."
|
|
467 (if calc-incomplete-algebraic-mode
|
|
468 "Only ( and [ begin algebraic entry."
|
|
469 "No keys except ' and $ begin algebraic entry."))))
|
|
470 )
|
|
471
|
|
472 (defun calc-symbolic-mode (n)
|
|
473 (interactive "P")
|
|
474 (calc-wrapper
|
|
475
|
|
476 (message (if (calc-change-mode 'calc-symbolic-mode n nil t)
|
|
477 "Inexact computations like sqrt(2) are deferred."
|
|
478 "Numerical computations are always done immediately.")))
|
|
479 )
|
|
480
|
|
481 (defun calc-infinite-mode (n)
|
|
482 (interactive "P")
|
|
483 (calc-wrapper
|
|
484 (if (eq n 0)
|
|
485 (progn
|
|
486 (calc-change-mode 'calc-infinite-mode 1)
|
|
487 (message "Computations like 1 / 0 produce \"inf\"."))
|
|
488 (message (if (calc-change-mode 'calc-infinite-mode n nil t)
|
|
489 "Computations like 1 / 0 produce \"uinf\"."
|
|
490 "Computations like 1 / 0 are left unsimplified."))))
|
|
491 )
|
|
492
|
|
493 (defun calc-matrix-mode (arg)
|
|
494 (interactive "P")
|
|
495 (calc-wrapper
|
|
496 (calc-change-mode 'calc-matrix-mode
|
|
497 (cond ((eq arg 0) 'scalar)
|
|
498 ((< (prefix-numeric-value arg) 1)
|
|
499 (and (< (prefix-numeric-value arg) -1) 'matrix))
|
|
500 (arg (prefix-numeric-value arg))
|
|
501 ((eq calc-matrix-mode 'matrix) 'scalar)
|
|
502 ((eq calc-matrix-mode 'scalar) nil)
|
|
503 (t 'matrix)))
|
|
504 (if (integerp calc-matrix-mode)
|
|
505 (message "Variables are assumed to be %dx%d matrices."
|
|
506 calc-matrix-mode calc-matrix-mode)
|
|
507 (message (if (eq calc-matrix-mode 'matrix)
|
|
508 "Variables are assumed to be matrices."
|
|
509 (if calc-matrix-mode
|
|
510 "Variables are assumed to be scalars (non-matrices)."
|
|
511 "Variables are not assumed to be matrix or scalar.")))))
|
|
512 )
|
|
513
|
|
514 (defun calc-set-simplify-mode (mode arg msg)
|
|
515 (calc-change-mode 'calc-simplify-mode
|
|
516 (if arg
|
|
517 (and (> (prefix-numeric-value arg) 0)
|
|
518 mode)
|
|
519 (and (not (eq calc-simplify-mode mode))
|
|
520 mode)))
|
|
521 (message (if (eq calc-simplify-mode mode)
|
|
522 msg
|
|
523 "Default simplifications enabled."))
|
|
524 )
|
|
525
|
|
526 (defun calc-no-simplify-mode (arg)
|
|
527 (interactive "P")
|
|
528 (calc-wrapper
|
|
529 (calc-set-simplify-mode 'none arg
|
|
530 "All default simplifications are disabled."))
|
|
531 )
|
|
532
|
|
533 (defun calc-num-simplify-mode (arg)
|
|
534 (interactive "P")
|
|
535 (calc-wrapper
|
|
536 (calc-set-simplify-mode 'num arg
|
|
537 "Default simplifications apply only if arguments are numeric."))
|
|
538 )
|
|
539
|
|
540 (defun calc-default-simplify-mode (arg)
|
|
541 (interactive "p")
|
|
542 (cond ((= arg 1)
|
|
543 (calc-wrapper
|
|
544 (calc-set-simplify-mode
|
|
545 nil nil "Usual default simplifications are enabled.")))
|
|
546 ((= arg 0) (calc-num-simplify-mode 1))
|
|
547 ((< arg 0) (calc-no-simplify-mode 1))
|
|
548 ((= arg 2) (calc-bin-simplify-mode 1))
|
|
549 ((= arg 3) (calc-alg-simplify-mode 1))
|
|
550 ((= arg 4) (calc-ext-simplify-mode 1))
|
|
551 ((= arg 5) (calc-units-simplify-mode 1))
|
|
552 (t (error "Prefix argument out of range")))
|
|
553 )
|
|
554
|
|
555 (defun calc-bin-simplify-mode (arg)
|
|
556 (interactive "P")
|
|
557 (calc-wrapper
|
|
558 (calc-set-simplify-mode 'binary arg
|
|
559 (format "Binary simplification occurs by default (word size=%d)."
|
|
560 calc-word-size)))
|
|
561 )
|
|
562
|
|
563 (defun calc-alg-simplify-mode (arg)
|
|
564 (interactive "P")
|
|
565 (calc-wrapper
|
|
566 (calc-set-simplify-mode 'alg arg
|
|
567 "Algebraic simplification occurs by default."))
|
|
568 )
|
|
569
|
|
570 (defun calc-ext-simplify-mode (arg)
|
|
571 (interactive "P")
|
|
572 (calc-wrapper
|
|
573 (calc-set-simplify-mode 'ext arg
|
|
574 "Extended algebraic simplification occurs by default."))
|
|
575 )
|
|
576
|
|
577 (defun calc-units-simplify-mode (arg)
|
|
578 (interactive "P")
|
|
579 (calc-wrapper
|
|
580 (calc-set-simplify-mode 'units arg
|
|
581 "Units simplification occurs by default."))
|
|
582 )
|
|
583
|
|
584 (defun calc-auto-recompute (arg)
|
|
585 (interactive "P")
|
|
586 (calc-wrapper
|
|
587 (calc-change-mode 'calc-auto-recompute arg nil t)
|
|
588 (calc-refresh-evaltos)
|
|
589 (message (if calc-auto-recompute
|
|
590 "Automatically recomputing `=>' forms when necessary."
|
|
591 "Not recomputing `=>' forms automatically.")))
|
|
592 )
|
|
593
|
|
594 (defun calc-working (n)
|
|
595 (interactive "P")
|
|
596 (calc-wrapper
|
|
597 (cond ((consp n)
|
|
598 (calc-pop-push-record 0 "work"
|
|
599 (cond ((eq calc-display-working-message t) 1)
|
|
600 (calc-display-working-message 2)
|
|
601 (t 0))))
|
|
602 ((eq n 2) (calc-change-mode 'calc-display-working-message 'lots))
|
|
603 ((eq n 0) (calc-change-mode 'calc-display-working-message nil))
|
|
604 ((eq n 1) (calc-change-mode 'calc-display-working-message t)))
|
|
605 (cond ((eq calc-display-working-message t)
|
|
606 (message "\"Working...\" messages enabled."))
|
|
607 (calc-display-working-message
|
|
608 (message "Detailed \"Working...\" messages enabled."))
|
|
609 (t
|
|
610 (message "\"Working...\" messages disabled."))))
|
|
611 )
|
|
612
|
|
613 (defun calc-always-load-extensions ()
|
|
614 (interactive)
|
|
615 (calc-wrapper
|
|
616 (if (setq calc-always-load-extensions (not calc-always-load-extensions))
|
|
617 (message "Always loading extensions package.")
|
|
618 (message "Loading extensions package on demand only.")))
|
|
619 )
|
|
620
|
|
621
|
|
622 (defun calc-matrix-left-justify ()
|
|
623 (interactive)
|
|
624 (calc-wrapper
|
|
625 (calc-change-mode 'calc-matrix-just nil t)
|
|
626 (message "Matrix elements will be left-justified in columns."))
|
|
627 )
|
|
628
|
|
629 (defun calc-matrix-center-justify ()
|
|
630 (interactive)
|
|
631 (calc-wrapper
|
|
632 (calc-change-mode 'calc-matrix-just 'center t)
|
|
633 (message "Matrix elements will be centered in columns."))
|
|
634 )
|
|
635
|
|
636 (defun calc-matrix-right-justify ()
|
|
637 (interactive)
|
|
638 (calc-wrapper
|
|
639 (calc-change-mode 'calc-matrix-just 'right t)
|
|
640 (message "Matrix elements will be right-justified in columns."))
|
|
641 )
|
|
642
|
|
643 (defun calc-full-vectors (n)
|
|
644 (interactive "P")
|
|
645 (calc-wrapper
|
|
646 (message (if (calc-change-mode 'calc-full-vectors n t t)
|
|
647 "Displaying long vectors in full."
|
|
648 "Displaying long vectors in [a, b, c, ..., z] notation.")))
|
|
649 )
|
|
650
|
|
651 (defun calc-full-trail-vectors (n)
|
|
652 (interactive "P")
|
|
653 (calc-wrapper
|
|
654 (message (if (calc-change-mode 'calc-full-trail-vectors n nil t)
|
|
655 "Recording long vectors in full."
|
|
656 "Recording long vectors in [a, b, c, ..., z] notation.")))
|
|
657 )
|
|
658
|
|
659 (defun calc-break-vectors (n)
|
|
660 (interactive "P")
|
|
661 (calc-wrapper
|
|
662 (message (if (calc-change-mode 'calc-break-vectors n t t)
|
|
663 "Displaying vector elements one-per-line."
|
|
664 "Displaying vector elements all on one line.")))
|
|
665 )
|
|
666
|
|
667 (defun calc-vector-commas ()
|
|
668 (interactive)
|
|
669 (calc-wrapper
|
|
670 (if (calc-change-mode 'calc-vector-commas (if calc-vector-commas nil ",") t)
|
|
671 (message "Separating vector elements with \",\".")
|
|
672 (message "Separating vector elements with spaces.")))
|
|
673 )
|
|
674
|
|
675 (defun calc-vector-brackets ()
|
|
676 (interactive)
|
|
677 (calc-wrapper
|
|
678 (if (calc-change-mode 'calc-vector-brackets
|
|
679 (if (equal calc-vector-brackets "[]") nil "[]") t)
|
|
680 (message "Surrounding vectors with \"[]\".")
|
|
681 (message "Not surrounding vectors with brackets.")))
|
|
682 )
|
|
683
|
|
684 (defun calc-vector-braces ()
|
|
685 (interactive)
|
|
686 (calc-wrapper
|
|
687 (if (calc-change-mode 'calc-vector-brackets
|
|
688 (if (equal calc-vector-brackets "{}") nil "{}") t)
|
|
689 (message "Surrounding vectors with \"{}\".")
|
|
690 (message "Not surrounding vectors with brackets.")))
|
|
691 )
|
|
692
|
|
693 (defun calc-vector-parens ()
|
|
694 (interactive)
|
|
695 (calc-wrapper
|
|
696 (if (calc-change-mode 'calc-vector-brackets
|
|
697 (if (equal calc-vector-brackets "()") nil "()") t)
|
|
698 (message "Surrounding vectors with \"()\".")
|
|
699 (message "Not surrounding vectors with brackets.")))
|
|
700 )
|
|
701
|
|
702 (defun calc-matrix-brackets (arg)
|
|
703 (interactive "sCode letters (R, O, C, P): ")
|
|
704 (calc-wrapper
|
|
705 (let ((code (append (and (string-match "[rR]" arg) '(R))
|
|
706 (and (string-match "[oO]" arg) '(O))
|
|
707 (and (string-match "[cC]" arg) '(C))
|
|
708 (and (string-match "[pP]" arg) '(P))))
|
|
709 (bad (string-match "[^rRoOcCpP ]" arg)))
|
|
710 (if bad
|
|
711 (error "Unrecognized character: %c" (aref arg bad)))
|
|
712 (calc-change-mode 'calc-matrix-brackets code t)))
|
|
713 )
|
|
714
|