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