* character.c (char_string): Remove unnecessary casts.
[emacs.git] / lisp / calc / calc-mode.el
blob856dfad882d511cdab122328387e369942c62a45
1 ;;; calc-mode.el --- calculator modes for Calc
3 ;; Copyright (C) 1990-1993, 2001-2011 Free Software Foundation, Inc.
5 ;; Author: David Gillespie <daveg@synaptics.com>
6 ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 ;;; Commentary:
25 ;;; Code:
27 ;; This file is autoloaded from calc-ext.el.
29 (require 'calc-ext)
30 (require 'calc-macs)
32 ;; Declare functions which are defined elsewhere.
33 (declare-function calc-embedded-save-original-modes "calc-embed" ())
36 (defun calc-line-numbering (n)
37 (interactive "P")
38 (calc-wrapper
39 (message (if (calc-change-mode 'calc-line-numbering n t t)
40 "Displaying stack level numbers"
41 "Hiding stack level numbers"))))
43 (defun calc-line-breaking (n)
44 (interactive "P")
45 (calc-wrapper
46 (setq n (if n
47 (and (> (setq n (prefix-numeric-value n)) 0)
48 (or (< n 5)
49 n))
50 (not calc-line-breaking)))
51 (if (calc-change-mode 'calc-line-breaking n t)
52 (if (integerp calc-line-breaking)
53 (message "Breaking lines longer than %d characters" n)
54 (message "Breaking long lines in Stack display"))
55 (message "Not breaking long lines in Stack display"))))
58 (defun calc-left-justify (n)
59 (interactive "P")
60 (calc-wrapper
61 (and n (setq n (prefix-numeric-value n)))
62 (calc-change-mode '(calc-display-just calc-display-origin)
63 (list nil n) t)
64 (if n
65 (message "Displaying stack entries indented by %d" n)
66 (message "Displaying stack entries left-justified"))))
68 (defun calc-center-justify (n)
69 (interactive "P")
70 (calc-wrapper
71 (and n (setq n (prefix-numeric-value n)))
72 (calc-change-mode '(calc-display-just calc-display-origin)
73 (list 'center n) t)
74 (if n
75 (message "Displaying stack entries centered on column %d" n)
76 (message "Displaying stack entries centered in window"))))
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"))))
88 (defun calc-left-label (s)
89 (interactive "sLefthand label: ")
90 (calc-wrapper
91 (or (equal s "")
92 (setq s (concat s " ")))
93 (calc-change-mode 'calc-left-label s t)))
95 (defun calc-right-label (s)
96 (interactive "sRighthand label: ")
97 (calc-wrapper
98 (or (equal s "")
99 (setq s (concat " " s)))
100 (calc-change-mode 'calc-right-label s t)))
102 (defun calc-auto-why (n)
103 (interactive "P")
104 (calc-wrapper
105 (if n
106 (progn
107 (setq n (prefix-numeric-value n))
108 (if (<= n 0) (setq n nil)
109 (if (> n 1) (setq n t))))
110 (setq n (and (not (eq calc-auto-why t)) (if calc-auto-why t 1))))
111 (calc-change-mode 'calc-auto-why n nil)
112 (cond ((null n)
113 (message "User must press `w' to explain unsimplified results"))
114 ((eq n t)
115 (message "Automatically doing `w' to explain unsimplified results"))
117 (message "Automatically doing `w' only for unusual messages")))))
119 (defun calc-group-digits (n)
120 (interactive "P")
121 (calc-wrapper
122 (if n
123 (progn
124 (setq n (prefix-numeric-value n))
125 (cond ((or (> n 0) (< n -1)))
126 ((= n -1)
127 (setq n nil))
129 (setq n calc-group-digits))))
130 (setq n (not calc-group-digits)))
131 (calc-change-mode 'calc-group-digits n t)
132 (cond ((null n)
133 (message "Grouping is off"))
134 ((integerp n)
135 (message "Grouping every %d digits" (math-abs n)))
137 (message "Grouping is on")))))
139 (defun calc-group-char (ch)
140 (interactive "cGrouping character: ")
141 (calc-wrapper
142 (or (>= ch 32)
143 (error "Control characters not allowed for grouping"))
144 (if (= ch ?\\)
145 (setq ch "\\,")
146 (setq ch (char-to-string ch)))
147 (calc-change-mode 'calc-group-char ch calc-group-digits)
148 (message "Digit grouping character is \"%s\"" ch)))
150 (defun calc-point-char (ch)
151 (interactive "cCharacter to use as decimal point: ")
152 (calc-wrapper
153 (or (>= ch 32)
154 (error "Control characters not allowed as decimal point"))
155 (calc-change-mode 'calc-point-char (char-to-string ch) t)
156 (message "Decimal point character is \"%c\"" ch)))
158 (defun calc-normal-notation (n)
159 (interactive "P")
160 (calc-wrapper
161 (calc-change-mode 'calc-float-format
162 (let* ((val (if n (prefix-numeric-value n) 0))
163 (mode (/ (+ val 5000) 10000)))
164 (if (or (< val -5000) (> mode 3))
165 (error "Prefix out of range"))
166 (setq n (list (aref [float sci eng fix] mode)
167 (- (% (+ val 5000) 10000) 5000))))
169 (if (eq (nth 1 n) 0)
170 (message "Displaying floating-point numbers normally")
171 (if (> (nth 1 n) 0)
172 (message
173 "Displaying floating-point numbers with %d significant digits"
174 (nth 1 n))
175 (message "Displaying floating-point numbers with (precision%d)"
176 (nth 1 n))))))
178 (defun calc-fix-notation (n)
179 (interactive "NDigits after decimal point: ")
180 (calc-wrapper
181 (calc-change-mode 'calc-float-format
182 (setq n (list 'fix (if n (prefix-numeric-value n) 0)))
184 (message "Displaying floats with %d digits after decimal"
185 (math-abs (nth 1 n)))))
187 (defun calc-sci-notation (n)
188 (interactive "P")
189 (calc-wrapper
190 (calc-change-mode 'calc-float-format
191 (setq n (list 'sci (if n (prefix-numeric-value n) 0)))
193 (if (eq (nth 1 n) 0)
194 (message "Displaying floats in scientific notation")
195 (if (> (nth 1 n) 0)
196 (message "Displaying scientific notation with %d significant digits"
197 (nth 1 n))
198 (message "Displaying scientific notation with (precision%d)"
199 (nth 1 n))))))
201 (defun calc-eng-notation (n)
202 (interactive "P")
203 (calc-wrapper
204 (calc-change-mode 'calc-float-format
205 (setq n (list 'eng (if n (prefix-numeric-value n) 0)))
207 (if (eq (nth 1 n) 0)
208 (message "Displaying floats in engineering notation")
209 (if (> (nth 1 n) 0)
210 (message "Displaying engineering notation with %d significant digits"
211 (nth 1 n))
212 (message "Displaying engineering notation with (precision%d)"
213 (nth 1 n))))))
216 (defun calc-truncate-stack (n &optional rel)
217 (interactive "P")
218 (calc-wrapper
219 (let ((oldtop calc-stack-top)
220 (newtop calc-stack-top))
221 (calc-record-undo (list 'set 'saved-stack-top calc-stack-top))
222 (let ((calc-stack-top 0)
223 (nn (prefix-numeric-value n)))
224 (setq newtop
225 (if n
226 (progn
227 (if rel
228 (setq nn (+ oldtop nn))
229 (if (< nn 0)
230 (setq nn (+ nn (calc-stack-size)))
231 (setq nn (1+ nn))))
232 (if (< nn 1)
234 (if (> nn (calc-stack-size))
235 (calc-stack-size)
236 nn)))
237 (max 1 (calc-locate-cursor-element (point)))))
238 (if (= newtop oldtop)
240 (calc-pop-stack 1 oldtop t)
241 (calc-push-list '(top-of-stack) newtop)
242 (if calc-line-numbering
243 (calc-refresh))))
244 (calc-record-undo (list 'set 'saved-stack-top 0))
245 (setq calc-stack-top newtop))))
247 (defun calc-truncate-up (n)
248 (interactive "p")
249 (calc-truncate-stack n t))
251 (defun calc-truncate-down (n)
252 (interactive "p")
253 (calc-truncate-stack (- n) t))
255 (defun calc-display-raw (arg)
256 (interactive "P")
257 (calc-wrapper
258 (setq calc-display-raw (if calc-display-raw nil (if arg 0 t)))
259 (calc-do-refresh)
260 (if calc-display-raw
261 (message "Press d ' again to cancel \"raw\" display mode"))))
266 ;;; Mode commands.
268 (defun calc-save-modes ()
269 (interactive)
270 (calc-wrapper
271 (let (pos
272 (vals (mapcar (function (lambda (v) (symbol-value (car v))))
273 calc-mode-var-list)))
274 (unless calc-settings-file
275 (error "No `calc-settings-file' specified"))
276 (set-buffer (find-file-noselect (substitute-in-file-name
277 calc-settings-file)))
278 (goto-char (point-min))
279 (if (and (search-forward ";;; Mode settings stored by Calc" nil t)
280 (progn
281 (beginning-of-line)
282 (setq pos (point))
283 (search-forward "\n;;; End of mode settings" nil t)))
284 (progn
285 (beginning-of-line)
286 (forward-line 1)
287 (delete-region pos (point)))
288 (goto-char (point-max))
289 (insert "\n\n")
290 (forward-char -1))
291 (insert ";;; Mode settings stored by Calc on " (current-time-string) "\n")
292 (let ((list calc-mode-var-list))
293 (while list
294 (let* ((v (car (car list)))
295 (def (nth 1 (car list)))
296 (val (car vals)))
297 (or (equal val def)
298 (progn
299 (insert "(setq " (symbol-name v) " ")
300 (if (and (or (listp val)
301 (symbolp val))
302 (not (memq val '(nil t))))
303 (insert "'"))
304 (insert (prin1-to-string val) ")\n"))))
305 (setq list (cdr list)
306 vals (cdr vals))))
307 (run-hooks 'calc-mode-save-hook)
308 (insert ";;; End of mode settings\n")
309 (save-buffer)
310 (if calc-embedded-info
311 (calc-embedded-save-original-modes)))))
313 (defun calc-settings-file-name (name &optional arg)
314 (interactive
315 (list (read-file-name (format "Settings file name (normally %s): "
316 (abbreviate-file-name calc-settings-file)))
317 current-prefix-arg))
318 (calc-wrapper
319 (setq arg (if arg (prefix-numeric-value arg) 0))
320 (if (string-equal (file-name-nondirectory name) "")
321 (message "Calc settings file is \"%s\"" calc-settings-file)
322 (if (< (math-abs arg) 2)
323 (let ((list calc-mode-var-list))
324 (while list
325 (set (car (car list)) (nth 1 (car list)))
326 (setq list (cdr list)))))
327 (setq calc-settings-file name)
328 (or (and
329 calc-settings-file
330 (equal user-init-file calc-settings-file)
331 (> arg 0))
332 (< arg 0)
333 (load name t)
334 (message "New file")))))
336 (defun math-get-modes-vec ()
337 (list 'vec
338 calc-internal-prec
339 calc-word-size
340 (calc-stack-size)
341 calc-number-radix
342 (+ (if (<= (nth 1 calc-float-format) 0)
343 (+ calc-internal-prec (nth 1 calc-float-format))
344 (nth 1 calc-float-format))
345 (cdr (assq (car calc-float-format)
346 '((float . 0) (sci . 10000)
347 (eng . 20000) (fix . 30000)))))
348 (cond ((eq calc-angle-mode 'rad) 2)
349 ((eq calc-angle-mode 'hms) 3)
350 (t 1))
351 (if calc-symbolic-mode 1 0)
352 (if calc-prefer-frac 1 0)
353 (if (eq calc-complex-mode 'polar) 1 0)
354 (cond ((eq calc-matrix-mode 'scalar) 0)
355 ((eq calc-matrix-mode 'matrix) -2)
356 ((eq calc-matrix-mode 'sqmatrix) -3)
357 (calc-matrix-mode)
358 (t -1))
359 (cond ((eq calc-simplify-mode 'none) -1)
360 ((eq calc-simplify-mode 'num) 0)
361 ((eq calc-simplify-mode 'binary) 2)
362 ((eq calc-simplify-mode 'alg) 3)
363 ((eq calc-simplify-mode 'ext) 4)
364 ((eq calc-simplify-mode 'units) 5)
365 (t 1))
366 (cond ((eq calc-infinite-mode 1) 0)
367 (calc-infinite-mode 1)
368 (t -1))))
370 (defun calc-get-modes (n)
371 (interactive "P")
372 (calc-wrapper
373 (let ((modes (math-get-modes-vec)))
374 (calc-enter-result 0 "mode"
375 (if n
376 (if (and (>= (setq n (prefix-numeric-value n)) 1)
377 (< n (length modes)))
378 (nth n modes)
379 (error "Prefix out of range"))
380 modes)))))
382 (defun calc-shift-prefix (arg)
383 (interactive "P")
384 (calc-wrapper
385 (setq calc-shift-prefix (if arg
386 (> (prefix-numeric-value arg) 0)
387 (not calc-shift-prefix)))
388 (calc-init-prefixes)
389 (message (if calc-shift-prefix
390 "Prefix keys are now case-insensitive"
391 "Prefix keys must be unshifted (except V, Z)"))))
393 (defun calc-mode-record-mode (n)
394 (interactive "P")
395 (calc-wrapper
396 (calc-change-mode 'calc-mode-save-mode
397 (cond ((null n)
398 (cond ((not calc-embedded-info)
399 (if (eq calc-mode-save-mode 'save)
400 'local 'save))
401 ((eq calc-mode-save-mode 'local) 'edit)
402 ((eq calc-mode-save-mode 'edit) 'perm)
403 ((eq calc-mode-save-mode 'perm) 'global)
404 ((eq calc-mode-save-mode 'global) 'save)
405 ((eq calc-mode-save-mode 'save) nil)
406 ((eq calc-mode-save-mode nil) 'local)))
407 ((= (setq n (prefix-numeric-value n)) 0) nil)
408 ((= n 2) 'edit)
409 ((= n 3) 'perm)
410 ((= n 4) 'global)
411 ((= n 5) 'save)
412 (t 'local)))
413 (message "%s"
414 (cond ((and (eq calc-mode-save-mode 'local) calc-embedded-info)
415 "Recording mode changes with [calc-mode: ...]")
416 ((eq calc-mode-save-mode 'edit)
417 "Recording mode changes with [calc-edit-mode: ...]")
418 ((eq calc-mode-save-mode 'perm)
419 "Recording mode changes with [calc-perm-mode: ...]")
420 ((eq calc-mode-save-mode 'global)
421 "Recording mode changes with [calc-global-mode: ...]")
422 ((eq calc-mode-save-mode 'save)
423 (format "Recording mode changes in \"%s\""
424 calc-settings-file))
426 "Not recording mode changes permanently")))))
428 (defun calc-total-algebraic-mode (flag)
429 (interactive "P")
430 (calc-wrapper
431 (if (eq calc-algebraic-mode 'total)
432 (calc-algebraic-mode nil)
433 (calc-change-mode '(calc-algebraic-mode calc-incomplete-algebraic-mode)
434 '(total nil))
435 (use-local-map calc-alg-map)
436 (message
437 "All keys begin algebraic entry; use Meta (ESC) for Calc keys"))))
439 (defun calc-algebraic-mode (flag)
440 (interactive "P")
441 (calc-wrapper
442 (if flag
443 (calc-change-mode '(calc-algebraic-mode
444 calc-incomplete-algebraic-mode)
445 (list nil (not calc-incomplete-algebraic-mode)))
446 (calc-change-mode '(calc-algebraic-mode calc-incomplete-algebraic-mode)
447 (list (not calc-algebraic-mode) nil)))
448 (use-local-map calc-mode-map)
449 (message (if calc-algebraic-mode
450 "Numeric keys and ( and [ begin algebraic entry"
451 (if calc-incomplete-algebraic-mode
452 "Only ( and [ begin algebraic entry"
453 "No keys except ' and $ begin algebraic entry")))))
455 (defun calc-symbolic-mode (n)
456 (interactive "P")
457 (calc-wrapper
459 (message (if (calc-change-mode 'calc-symbolic-mode n nil t)
460 "Inexact computations like sqrt(2) are deferred"
461 "Numerical computations are always done immediately"))))
463 (defun calc-infinite-mode (n)
464 (interactive "P")
465 (calc-wrapper
466 (if (eq n 0)
467 (progn
468 (calc-change-mode 'calc-infinite-mode 1)
469 (message "Computations like 1 / 0 produce \"inf\""))
470 (message (if (calc-change-mode 'calc-infinite-mode n nil t)
471 "Computations like 1 / 0 produce \"uinf\""
472 "Computations like 1 / 0 are left unsimplified")))))
474 (defun calc-matrix-mode (arg)
475 (interactive "P")
476 (calc-wrapper
477 (calc-change-mode 'calc-matrix-mode
478 (cond ((eq arg 0) 'scalar)
479 ((< (prefix-numeric-value arg) 1)
480 (and (< (prefix-numeric-value arg) -1) 'matrix))
481 (arg
482 (if (consp arg) 'sqmatrix
483 (prefix-numeric-value arg)))
484 ((eq calc-matrix-mode 'matrix) 'scalar)
485 ((eq calc-matrix-mode 'scalar) nil)
486 (t 'matrix)))
487 (if (integerp calc-matrix-mode)
488 (message "Variables are assumed to be %dx%d matrices"
489 calc-matrix-mode calc-matrix-mode)
490 (message (if (eq calc-matrix-mode 'matrix)
491 "Variables are assumed to be matrices"
492 (if (eq calc-matrix-mode 'sqmatrix)
493 "Variables are assumed to be square matrices"
494 (if calc-matrix-mode
495 "Variables are assumed to be scalars (non-matrices)"
496 "Variables are not assumed to be matrix or scalar")))))))
498 (defun calc-set-simplify-mode (mode arg msg)
499 (calc-change-mode 'calc-simplify-mode
500 (if arg
501 (and (> (prefix-numeric-value arg) 0)
502 mode)
503 (and (not (eq calc-simplify-mode mode))
504 mode)))
505 (message "%s" (if (eq calc-simplify-mode mode)
507 "Default simplifications enabled")))
509 (defun calc-no-simplify-mode (arg)
510 (interactive "P")
511 (calc-wrapper
512 (calc-set-simplify-mode 'none arg
513 "All default simplifications are disabled")))
515 (defun calc-num-simplify-mode (arg)
516 (interactive "P")
517 (calc-wrapper
518 (calc-set-simplify-mode 'num arg
519 "Default simplifications apply only if arguments are numeric")))
521 (defun calc-default-simplify-mode (arg)
522 (interactive "p")
523 (cond ((= arg 1)
524 (calc-wrapper
525 (calc-set-simplify-mode
526 nil nil "Usual default simplifications are enabled")))
527 ((= arg 0) (calc-num-simplify-mode 1))
528 ((< arg 0) (calc-no-simplify-mode 1))
529 ((= arg 2) (calc-bin-simplify-mode 1))
530 ((= arg 3) (calc-alg-simplify-mode 1))
531 ((= arg 4) (calc-ext-simplify-mode 1))
532 ((= arg 5) (calc-units-simplify-mode 1))
533 (t (error "Prefix argument out of range"))))
535 (defun calc-bin-simplify-mode (arg)
536 (interactive "P")
537 (calc-wrapper
538 (calc-set-simplify-mode 'binary arg
539 (format "Binary simplification occurs by default (word size=%d)"
540 calc-word-size))))
542 (defun calc-alg-simplify-mode (arg)
543 (interactive "P")
544 (calc-wrapper
545 (calc-set-simplify-mode 'alg arg
546 "Algebraic simplification occurs by default")))
548 (defun calc-ext-simplify-mode (arg)
549 (interactive "P")
550 (calc-wrapper
551 (calc-set-simplify-mode 'ext arg
552 "Extended algebraic simplification occurs by default")))
554 (defun calc-units-simplify-mode (arg)
555 (interactive "P")
556 (calc-wrapper
557 (calc-set-simplify-mode 'units arg
558 "Units simplification occurs by default")))
560 (defun calc-auto-recompute (arg)
561 (interactive "P")
562 (calc-wrapper
563 (calc-change-mode 'calc-auto-recompute arg nil t)
564 (calc-refresh-evaltos)
565 (message (if calc-auto-recompute
566 "Automatically recomputing `=>' forms when necessary"
567 "Not recomputing `=>' forms automatically"))))
569 (defun calc-working (n)
570 (interactive "P")
571 (calc-wrapper
572 (cond ((consp n)
573 (calc-pop-push-record 0 "work"
574 (cond ((eq calc-display-working-message t) 1)
575 (calc-display-working-message 2)
576 (t 0))))
577 ((eq n 2) (calc-change-mode 'calc-display-working-message 'lots))
578 ((eq n 0) (calc-change-mode 'calc-display-working-message nil))
579 ((eq n 1) (calc-change-mode 'calc-display-working-message t)))
580 (cond ((eq calc-display-working-message t)
581 (message "\"Working...\" messages enabled"))
582 (calc-display-working-message
583 (message "Detailed \"Working...\" messages enabled"))
585 (message "\"Working...\" messages disabled")))))
587 (defun calc-always-load-extensions ()
588 (interactive)
589 (calc-wrapper
590 (if (setq calc-always-load-extensions (not calc-always-load-extensions))
591 (message "Always loading extensions package")
592 (message "Loading extensions package on demand only"))))
595 (defun calc-matrix-left-justify ()
596 (interactive)
597 (calc-wrapper
598 (calc-change-mode 'calc-matrix-just nil t)
599 (message "Matrix elements will be left-justified in columns")))
601 (defun calc-matrix-center-justify ()
602 (interactive)
603 (calc-wrapper
604 (calc-change-mode 'calc-matrix-just 'center t)
605 (message "Matrix elements will be centered in columns")))
607 (defun calc-matrix-right-justify ()
608 (interactive)
609 (calc-wrapper
610 (calc-change-mode 'calc-matrix-just 'right t)
611 (message "Matrix elements will be right-justified in columns")))
613 (defun calc-full-vectors (n)
614 (interactive "P")
615 (calc-wrapper
616 (message (if (calc-change-mode 'calc-full-vectors n t t)
617 "Displaying long vectors in full"
618 "Displaying long vectors in [a, b, c, ..., z] notation"))))
620 (defun calc-full-trail-vectors (n)
621 (interactive "P")
622 (calc-wrapper
623 (message (if (calc-change-mode 'calc-full-trail-vectors n nil t)
624 "Recording long vectors in full"
625 "Recording long vectors in [a, b, c, ..., z] notation"))))
627 (defun calc-break-vectors (n)
628 (interactive "P")
629 (calc-wrapper
630 (message (if (calc-change-mode 'calc-break-vectors n t t)
631 "Displaying vector elements one-per-line"
632 "Displaying vector elements all on one line"))))
634 (defun calc-vector-commas ()
635 (interactive)
636 (calc-wrapper
637 (if (calc-change-mode 'calc-vector-commas (if calc-vector-commas nil ",") t)
638 (message "Separating vector elements with \",\"")
639 (message "Separating vector elements with spaces"))))
641 (defun calc-vector-brackets ()
642 (interactive)
643 (calc-wrapper
644 (if (calc-change-mode 'calc-vector-brackets
645 (if (equal calc-vector-brackets "[]") nil "[]") t)
646 (message "Surrounding vectors with \"[]\"")
647 (message "Not surrounding vectors with brackets"))))
649 (defun calc-vector-braces ()
650 (interactive)
651 (calc-wrapper
652 (if (calc-change-mode 'calc-vector-brackets
653 (if (equal calc-vector-brackets "{}") nil "{}") t)
654 (message "Surrounding vectors with \"{}\"")
655 (message "Not surrounding vectors with brackets"))))
657 (defun calc-vector-parens ()
658 (interactive)
659 (calc-wrapper
660 (if (calc-change-mode 'calc-vector-brackets
661 (if (equal calc-vector-brackets "()") nil "()") t)
662 (message "Surrounding vectors with \"()\"")
663 (message "Not surrounding vectors with brackets"))))
665 (defun calc-matrix-brackets (arg)
666 (interactive "sCode letters (R, O, C): ")
667 (calc-wrapper
668 (let ((code (append (and (string-match "[rR]" arg) '(R))
669 (and (string-match "[oO]" arg) '(O))
670 (and (string-match "[cC]" arg) '(C))
671 (and (string-match "[pP]" arg) '(P))))
672 (bad (string-match "[^rRoOcCpP ]" arg)))
673 (if bad
674 (error "Unrecognized character: %c" (aref arg bad)))
675 (calc-change-mode 'calc-matrix-brackets code t))))
677 (provide 'calc-mode)
679 ;;; calc-mode.el ends here