3 |
;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002 Free Software Foundation, Inc. |
;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002 Free Software Foundation, Inc. |
4 |
|
|
5 |
;; Author: David Gillespie <daveg@synaptics.com> |
;; Author: David Gillespie <daveg@synaptics.com> |
6 |
;; Maintainer: Colin Walters <walters@debian.org> |
;; Maintainers: D. Goel <deego@gnufans.org> |
7 |
|
;; Colin Walters <walters@debian.org> |
8 |
;; Keywords: convenience, extensions |
;; Keywords: convenience, extensions |
9 |
;; Version: 2.02g |
;; Version: 2.02g |
10 |
|
|
146 |
;; Subject: Re: fix for `Cannot open load file: calc-alg-3' |
;; Subject: Re: fix for `Cannot open load file: calc-alg-3' |
147 |
;; To: walters@debian.org |
;; To: walters@debian.org |
148 |
;; Date: Sat, 24 Nov 2001 21:44:21 +0000 (UTC) |
;; Date: Sat, 24 Nov 2001 21:44:21 +0000 (UTC) |
149 |
;; |
;; |
150 |
;; Could you add logistic curve fitting to the current list? |
;; Could you add logistic curve fitting to the current list? |
151 |
;; |
;; |
152 |
;; (I guess the key binding for a logistic curve would have to be `s' |
;; (I guess the key binding for a logistic curve would have to be `s' |
153 |
;; since a logistic curve is an `s' curve; both `l' and `L' are already |
;; since a logistic curve is an `s' curve; both `l' and `L' are already |
154 |
;; taken for logarithms.) |
;; taken for logarithms.) |
155 |
;; |
;; |
156 |
;; Here is the current list for curve fitting; |
;; Here is the current list for curve fitting; |
157 |
;; |
;; |
158 |
;; `1' |
;; `1' |
159 |
;; Linear or multilinear. a + b x + c y + d z. |
;; Linear or multilinear. a + b x + c y + d z. |
160 |
;; |
;; |
161 |
;; `2-9' |
;; `2-9' |
162 |
;; Polynomials. a + b x + c x^2 + d x^3. |
;; Polynomials. a + b x + c x^2 + d x^3. |
163 |
;; |
;; |
164 |
;; `e' |
;; `e' |
165 |
;; Exponential. a exp(b x) exp(c y). |
;; Exponential. a exp(b x) exp(c y). |
166 |
;; |
;; |
167 |
;; `E' |
;; `E' |
168 |
;; Base-10 exponential. a 10^(b x) 10^(c y). |
;; Base-10 exponential. a 10^(b x) 10^(c y). |
169 |
;; |
;; |
170 |
;; `x' |
;; `x' |
171 |
;; Exponential (alternate notation). exp(a + b x + c y). |
;; Exponential (alternate notation). exp(a + b x + c y). |
172 |
;; |
;; |
173 |
;; `X' |
;; `X' |
174 |
;; Base-10 exponential (alternate). 10^(a + b x + c y). |
;; Base-10 exponential (alternate). 10^(a + b x + c y). |
175 |
;; |
;; |
176 |
;; `l' |
;; `l' |
177 |
;; Logarithmic. a + b ln(x) + c ln(y). |
;; Logarithmic. a + b ln(x) + c ln(y). |
178 |
;; |
;; |
179 |
;; `L' |
;; `L' |
180 |
;; Base-10 logarithmic. a + b log10(x) + c log10(y). |
;; Base-10 logarithmic. a + b log10(x) + c log10(y). |
181 |
;; |
;; |
182 |
;; `^' |
;; `^' |
183 |
;; General exponential. a b^x c^y. |
;; General exponential. a b^x c^y. |
184 |
;; |
;; |
185 |
;; `p' |
;; `p' |
186 |
;; Power law. a x^b y^c. |
;; Power law. a x^b y^c. |
187 |
;; |
;; |
188 |
;; `q' |
;; `q' |
189 |
;; Quadratic. a + b (x-c)^2 + d (x-e)^2. |
;; Quadratic. a + b (x-c)^2 + d (x-e)^2. |
190 |
;; |
;; |
191 |
;; `g' |
;; `g' |
192 |
;; Gaussian. (a / b sqrt(2 pi)) exp(-0.5*((x-c)/b)^2). |
;; Gaussian. (a / b sqrt(2 pi)) exp(-0.5*((x-c)/b)^2). |
193 |
;; |
;; |
194 |
;; |
;; |
195 |
;; Logistic curves are used a great deal in ecology, and in predicting |
;; Logistic curves are used a great deal in ecology, and in predicting |
196 |
;; human actions, such as use of different kinds of energy in a country |
;; human actions, such as use of different kinds of energy in a country |
197 |
;; (wood, coal, oil, natural gas, etc.) or the number of scientific |
;; (wood, coal, oil, natural gas, etc.) or the number of scientific |
198 |
;; papers a person publishes, or the number of movies made. |
;; papers a person publishes, or the number of movies made. |
199 |
;; |
;; |
200 |
;; (The less information on which to base the curve, the higher the error |
;; (The less information on which to base the curve, the higher the error |
201 |
;; rate. Theodore Modis ran some Monte Carlo simulations and produced |
;; rate. Theodore Modis ran some Monte Carlo simulations and produced |
202 |
;; what may be useful set of confidence levels for different amounts of |
;; what may be useful set of confidence levels for different amounts of |
237 |
(defvar calc-gnuplot-print-command "lp %s" |
(defvar calc-gnuplot-print-command "lp %s" |
238 |
"*Name of command for printing GNUPLOT output; %s = file name to print.") |
"*Name of command for printing GNUPLOT output; %s = file name to print.") |
239 |
|
|
240 |
;; Address of the author of Calc, for use by report-calc-bug. |
(defvar calc-bug-address "deego@gnufans.org" |
241 |
(defvar calc-bug-address "walters@debian.org") |
"Address of the author of Calc, for use by `report-calc-bug'.") |
242 |
|
|
243 |
;; If t, scan keymaps to find all DEL-like keys. |
(defvar calc-scan-for-dels t |
244 |
;; if nil, only DEL itself is mapped to calc-pop. |
"If t, scan keymaps to find all DEL-like keys. |
245 |
(defvar calc-scan-for-dels t) |
if nil, only DEL itself is mapped to calc-pop.") |
246 |
|
|
247 |
(defvar calc-extensions-loaded nil) |
(defvar calc-extensions-loaded nil) |
248 |
|
|
249 |
;; Calculator stack. |
(defvar calc-stack '((top-of-stack 1 nil)) |
250 |
;; Entries are 3-lists: Formula, Height (in lines), Selection (or nil). |
"Calculator stack. |
251 |
(defvar calc-stack '((top-of-stack 1 nil))) |
Entries are 3-lists: Formula, Height (in lines), Selection (or nil).") |
252 |
|
|
253 |
(defvar calc-show-banner t |
(defvar calc-show-banner t |
254 |
"*If non-nil, show a friendly greeting above the stack.") |
"*If non-nil, show a friendly greeting above the stack.") |
255 |
|
|
256 |
;; Index into calc-stack of "top" of stack. |
(defvar calc-stack-top 1 |
257 |
;; This is 1 unless calc-truncate-stack has been used. |
"Index into `calc-stack' of \"top\" of stack. |
258 |
;;(defvar calc-stack-top 1) |
This is 1 unless `calc-truncate-stack' has been used.") |
259 |
|
|
260 |
;; If non-nil, load the calc-ext module automatically when calc is loaded. |
(defvar calc-always-load-extensions nil |
261 |
;;(defvar calc-always-load-extensions nil) |
"If non-nil, load the calc-ext module automatically when calc is loaded.") |
262 |
|
|
263 |
;; If non-nil, display line numbers in Calculator stack. |
(defvar calc-line-numbering t |
264 |
;;(defvar calc-line-numbering t) |
"If non-nil, display line numbers in Calculator stack.") |
265 |
|
|
266 |
;; If non-nil, break long values across multiple lines in Calculator stack. |
(defvar calc-line-breaking t |
267 |
;;(defvar calc-line-breaking t) |
"If non-nil, break long values across multiple lines in Calculator stack.") |
268 |
|
|
269 |
;; If nil, stack display is left-justified. |
(defvar calc-display-just nil |
270 |
;; If 'right, stack display is right-justified. |
"If nil, stack display is left-justified. |
271 |
;; If 'center, stack display is centered." |
If `right', stack display is right-justified. |
272 |
;;(defvar calc-display-just nil) |
If `center', stack display is centered.") |
273 |
|
|
274 |
;; Horizontal origin of displayed stack entries. |
(defvar calc-display-origin nil |
275 |
;; In left-justified mode, this is effectively indentation. (Default 0). |
"Horizontal origin of displayed stack entries. |
276 |
;; In right-justified mode, this is effectively window width. |
In left-justified mode, this is effectively indentation. (Default 0). |
277 |
;; In centered mode, center of stack entry is placed here. |
In right-justified mode, this is effectively window width. |
278 |
;;(defvar calc-display-origin nil) |
In centered mode, center of stack entry is placed here.") |
279 |
|
|
280 |
;; Radix for entry and display of numbers in calc-mode, 2-36. |
(defvar calc-number-radix 10 |
281 |
;;(defvar calc-number-radix 10) |
"Radix for entry and display of numbers in calc-mode, 2-36.") |
282 |
|
|
283 |
;; If non-nil, leading zeros are provided to pad integers to calc-word-size. |
(defvar calc-leading-zeros nil |
284 |
;;(defvar calc-leading-zeros nil) |
"If non-nil, leading zeros are provided to pad integers to calc-word-size.") |
285 |
|
|
286 |
;; If non-nil, group digits in large displayed integers by inserting spaces. |
(defvar calc-group-digits nil |
287 |
;; If an integer, group that many digits at a time. |
"If non-nil, group digits in large displayed integers by inserting spaces. |
288 |
;; If 't', use 4 for binary and hex, 3 otherwise. |
If an integer, group that many digits at a time. |
289 |
;;(defvar calc-group-digits nil) |
If t, use 4 for binary and hex, 3 otherwise.") |
290 |
|
|
291 |
;; The character (in the form of a string) to be used for grouping digits. |
(defvar calc-group-char "," |
292 |
;; This is used only when calc-group-digits mode is on. |
"The character (in the form of a string) to be used for grouping digits. |
293 |
;;(defvar calc-group-char ",") |
This is used only when calc-group-digits mode is on.") |
294 |
|
|
295 |
;; The character (in the form of a string) to be used as a decimal point. |
(defvar calc-point-char "." |
296 |
;;(defvar calc-point-char ".") |
"The character (in the form of a string) to be used as a decimal point.") |
297 |
|
|
298 |
;; Format of displayed fractions; a string of one or two of ":" or "/". |
(defvar calc-frac-format '(":" nil) |
299 |
;;(defvar calc-frac-format '(":" nil)) |
"Format of displayed fractions; a string of one or two of \":\" or \"/\".") |
300 |
|
|
301 |
;; If non-nil, prefer fractional over floating-point results. |
(defvar calc-prefer-frac nil |
302 |
;;(defvar calc-prefer-frac nil) |
"If non-nil, prefer fractional over floating-point results.") |
303 |
|
|
304 |
;; Format of displayed hours-minutes-seconds angles, a format string. |
(defvar calc-hms-format "%s@ %s' %s\"" |
305 |
;; String must contain three %s marks for hours, minutes, seconds respectively. |
"Format of displayed hours-minutes-seconds angles, a format string. |
306 |
;;(defvar calc-hms-format "%s@ %s' %s\"") |
String must contain three %s marks for hours, minutes, seconds respectively.") |
307 |
|
|
308 |
;; Format of displayed date forms. |
(defvar calc-date-format '((H ":" mm C SS pp " ") |
309 |
;;(defvar calc-date-format '((H ":" mm ":" SS pp " ") Www " " Mmm " " D ", " YYYY)) |
Www " " Mmm " " D ", " YYYY) |
310 |
|
"Format of displayed date forms.") |
311 |
;; Format to use for display of floating-point numbers in calc-mode. |
|
312 |
;; Must be a list of one of the following forms: |
(defvar calc-float-format '(float 0) |
313 |
;; (float 0) Floating point format, display full precision. |
"Format to use for display of floating-point numbers in calc-mode. |
314 |
;; (float N) N > 0: Floating point format, at most N significant figures. |
Must be a list of one of the following forms: |
315 |
;; (float -N) -N < 0: Floating point format, calc-internal-prec - N figs. |
(float 0) Floating point format, display full precision. |
316 |
;; (fix N) N >= 0: Fixed point format, N places after decimal point. |
(float N) N > 0: Floating point format, at most N significant figures. |
317 |
;; (sci 0) Scientific notation, full precision. |
(float -N) -N < 0: Floating point format, calc-internal-prec - N figs. |
318 |
;; (sci N) N > 0: Scientific notation, N significant figures. |
(fix N) N >= 0: Fixed point format, N places after decimal point. |
319 |
;; (sci -N) -N < 0: Scientific notation, calc-internal-prec - N figs. |
(sci 0) Scientific notation, full precision. |
320 |
;; (eng 0) Engineering notation, full precision. |
(sci N) N > 0: Scientific notation, N significant figures. |
321 |
;; (eng N) N > 0: Engineering notation, N significant figures. |
(sci -N) -N < 0: Scientific notation, calc-internal-prec - N figs. |
322 |
;; (eng -N) -N < 0: Engineering notation, calc-internal-prec - N figs. |
(eng 0) Engineering notation, full precision. |
323 |
;;(defvar calc-float-format '(float 0)) |
(eng N) N > 0: Engineering notation, N significant figures. |
324 |
|
(eng -N) -N < 0: Engineering notation, calc-internal-prec - N figs.") |
325 |
;; Format to use when full precision must be displayed. |
|
326 |
;;(defvar calc-full-float-format '(float 0)) |
(defvar calc-full-float-format '(float 0) |
327 |
|
"Format to use when full precision must be displayed.") |
328 |
;; Format to use for display of complex numbers in calc-mode. Must be one of: |
|
329 |
;; nil Use (x, y) form. |
(defvar calc-complex-format nil |
330 |
;; i Use x + yi form. |
"Format to use for display of complex numbers in calc-mode. Must be one of: |
331 |
;; j Use x + yj form. |
nil Use (x, y) form. |
332 |
;;(defvar calc-complex-format nil) |
i Use x + yi form. |
333 |
|
j Use x + yj form.") |
334 |
;; Preferred form, either 'cplx or 'polar, for complex numbers. |
|
335 |
;;(defvar calc-complex-mode 'cplx) |
(defvar calc-complex-mode 'cplx |
336 |
|
"Preferred form, either `cplx' or `polar', for complex numbers.") |
337 |
;; If nil, 1 / 0 is left unsimplified. |
|
338 |
;; If 0, 1 / 0 is changed to inf (zeros are considered positive). |
(defvar calc-infinite-mode nil |
339 |
;; Otherwise, 1 / 0 is changed to uinf (undirected infinity). |
"If nil, 1 / 0 is left unsimplified. |
340 |
;;(defvar calc-infinite-mode nil) |
If 0, 1 / 0 is changed to inf (zeros are considered positive). |
341 |
|
Otherwise, 1 / 0 is changed to uinf (undirected infinity).") |
342 |
;; If non-nil, display vectors of byte-sized integers as strings. |
|
343 |
;;(defvar calc-display-strings nil) |
(defvar calc-display-strings nil |
344 |
|
"If non-nil, display vectors of byte-sized integers as strings.") |
345 |
;; If nil, vector elements are left-justified. |
|
346 |
;; If 'right, vector elements are right-justified. |
(defvar calc-matrix-just 'center |
347 |
;; If 'center, vector elements are centered." |
"If nil, vector elements are left-justified. |
348 |
;;(defvar calc-matrix-just 'center) |
If `right', vector elements are right-justified. |
349 |
|
If `center', vector elements are centered.") |
350 |
;; If non-nil, display vectors one element per line. |
|
351 |
;;(defvar calc-break-vectors nil) |
(defvar calc-break-vectors nil |
352 |
|
"If non-nil, display vectors one element per line.") |
353 |
;; If non-nil, display long vectors in full. If nil, use abbreviated form. |
|
354 |
;;(defvar calc-full-vectors t) |
(defvar calc-full-vectors t |
355 |
|
"If non-nil, display long vectors in full. If nil, use abbreviated form.") |
356 |
;; If non-nil, display long vectors in full in the trail. |
|
357 |
;;(defvar calc-full-trail-vectors t) |
(defvar calc-full-trail-vectors t |
358 |
|
"If non-nil, display long vectors in full in the trail.") |
359 |
;; If non-nil, separate elements of displayed vectors with this string. |
|
360 |
;;(defvar calc-vector-commas ",") |
(defvar calc-vector-commas "," |
361 |
|
"If non-nil, separate elements of displayed vectors with this string.") |
362 |
;; If non-nil, surround displayed vectors with these characters. |
|
363 |
;;(defvar calc-vector-brackets "[]") |
(defvar calc-vector-brackets "[]" |
364 |
|
"If non-nil, surround displayed vectors with these characters.") |
365 |
;; A list of code-letter symbols that control "big" matrix display. |
|
366 |
;; If 'R is present, display inner brackets for matrices. |
(defvar calc-matrix-brackets '(R O) |
367 |
;; If 'O is present, display outer brackets for matrices (above/below). |
"A list of code-letter symbols that control \"big\" matrix display. |
368 |
;; If 'C is present, display outer brackets for matrices (centered). |
If `R' is present, display inner brackets for matrices. |
369 |
;;(defvar calc-matrix-brackets '(R O)) |
If `O' is present, display outer brackets for matrices (above/below). |
370 |
|
If `C' is present, display outer brackets for matrices (centered).") |
371 |
;; Language or format for entry and display of stack values. Must be one of: |
|
372 |
;; nil Use standard Calc notation. |
(defvar calc-language nil |
373 |
;; flat Use standard Calc notation, one-line format. |
"Language or format for entry and display of stack values. Must be one of: |
374 |
;; big Display formulas in 2-d notation (enter w/std notation). |
nil Use standard Calc notation. |
375 |
;; unform Use unformatted display: add(a, mul(b,c)). |
flat Use standard Calc notation, one-line format. |
376 |
;; c Use C language notation. |
big Display formulas in 2-d notation (enter w/std notation). |
377 |
;; pascal Use Pascal language notation. |
unform Use unformatted display: add(a, mul(b,c)). |
378 |
;; fortran Use Fortran language notation. |
c Use C language notation. |
379 |
;; tex Use TeX notation. |
pascal Use Pascal language notation. |
380 |
;; eqn Use eqn notation. |
fortran Use Fortran language notation. |
381 |
;; math Use Mathematica(tm) notation. |
tex Use TeX notation. |
382 |
;; maple Use Maple notation. |
eqn Use eqn notation. |
383 |
;;(defvar calc-language nil) |
math Use Mathematica(tm) notation. |
384 |
|
maple Use Maple notation.") |
385 |
;; Numeric prefix argument for the command that set calc-language. |
|
386 |
;;(defvar calc-language-option nil) |
(defvar calc-language-option nil |
387 |
|
"Numeric prefix argument for the command that set `calc-language'.") |
388 |
;; Open-parenthesis string for function call notation. |
|
389 |
;;(defvar calc-function-open "(") |
(defvar calc-function-open "(" |
390 |
|
"Open-parenthesis string for function call notation.") |
391 |
;; Close-parenthesis string for function call notation. |
|
392 |
;;(defvar calc-function-close ")") |
(defvar calc-function-close ")" |
393 |
|
"Close-parenthesis string for function call notation.") |
394 |
;; Function through which to pass strings after formatting. |
|
395 |
;;(defvar calc-language-output-filter nil) |
(defvar calc-language-output-filter nil |
396 |
|
"Function through which to pass strings after formatting.") |
397 |
;; Function through which to pass strings before parsing. |
|
398 |
;;(defvar calc-language-input-filter nil) |
(defvar calc-language-input-filter nil |
399 |
|
"Function through which to pass strings before parsing.") |
400 |
;; Formatting function used for non-decimal numbers. |
|
401 |
;;(defvar calc-radix-formatter nil) |
(defvar calc-radix-formatter nil |
402 |
|
"Formatting function used for non-decimal numbers.") |
403 |
;; Label to display at left of formula. |
|
404 |
;;(defvar calc-left-label "") |
(defvar calc-left-label "" |
405 |
|
"Label to display at left of formula.") |
406 |
;; Label to display at right of formula. |
|
407 |
;;(defvar calc-right-label "") |
(defvar calc-right-label "" |
408 |
|
"Label to display at right of formula.") |
409 |
;; Minimum number of bits per word, if any, for binary operations in calc-mode. |
|
410 |
;;(defvar calc-word-size 32) |
(defvar calc-word-size 32 |
411 |
|
"Minimum number of bits per word, if any, for binary operations in calc-mode.") |
412 |
;; Most recently used value of M in a modulo form. |
|
413 |
;;(defvar calc-previous-modulo nil) |
(defvar calc-previous-modulo nil |
414 |
|
"Most recently used value of M in a modulo form.") |
415 |
;; Type of simplification applied to results. |
|
416 |
;; If 'none, results are not simplified when pushed on the stack. |
(defvar calc-simplify-mode nil |
417 |
;; If 'num, functions are simplified only when args are constant. |
"Type of simplification applied to results. |
418 |
;; If nil, only fast simplifications are applied. |
If `none', results are not simplified when pushed on the stack. |
419 |
;; If 'binary, math-clip is applied if appropriate. |
If `num', functions are simplified only when args are constant. |
420 |
;; If 'alg, math-simplify is applied. |
If nil, only fast simplifications are applied. |
421 |
;; If 'ext, math-simplify-extended is applied. |
If `binary', `math-clip' is applied if appropriate. |
422 |
;; If 'units, math-simplify-units is applied. |
If `alg', `math-simplify' is applied. |
423 |
;;(defvar calc-simplify-mode nil) |
If `ext', `math-simplify-extended' is applied. |
424 |
|
If `units', `math-simplify-units' is applied.") |
425 |
;; If non-nil, recompute evalto's automatically when necessary. |
|
426 |
;;(defvar calc-auto-recompute t) |
(defvar calc-auto-recompute t |
427 |
|
"If non-nil, recompute evalto's automatically when necessary.") |
428 |
;; If non-nil, display shows unformatted Lisp exprs. (For debugging) |
|
429 |
;;(defvar calc-display-raw nil) |
(defvar calc-display-raw nil |
430 |
|
"If non-nil, display shows unformatted Lisp exprs. (For debugging)") |
431 |
;; Number of digits of internal precision for calc-mode calculations. |
|
432 |
;;(defvar calc-internal-prec 12) |
(defvar calc-internal-prec 12 |
433 |
|
"Number of digits of internal precision for calc-mode calculations.") |
434 |
;; If non-nil, next operation is Inverse. |
|
435 |
;;(defvar calc-inverse-flag nil) |
(defvar calc-inverse-flag nil |
436 |
|
"If non-nil, next operation is Inverse.") |
437 |
;; If non-nil, next operation is Hyperbolic. |
|
438 |
;;(defvar calc-hyperbolic-flag nil) |
(defvar calc-hyperbolic-flag nil |
439 |
|
"If non-nil, next operation is Hyperbolic.") |
440 |
;; If non-nil, next operation should not remove its arguments from stack. |
|
441 |
;;(defvar calc-keep-args-flag nil) |
(defvar calc-keep-args-flag nil |
442 |
|
"If non-nil, next operation should not remove its arguments from stack.") |
443 |
;; If deg, angles are in degrees; if rad, angles are in radians. |
|
444 |
;; If hms, angles are in degrees-minutes-seconds. |
(defvar calc-angle-mode 'deg |
445 |
;;(defvar calc-angle-mode 'deg) |
"If deg, angles are in degrees; if rad, angles are in radians. |
446 |
|
If hms, angles are in degrees-minutes-seconds.") |
447 |
;; If non-nil, numeric entry accepts whole algebraic expressions. |
|
448 |
;; If nil, algebraic expressions must be preceded by "'". |
(defvar calc-algebraic-mode nil |
449 |
;;(defvar calc-algebraic-mode nil) |
"If non-nil, numeric entry accepts whole algebraic expressions. |
450 |
|
If nil, algebraic expressions must be preceded by \"'\".") |
451 |
;; Like calc-algebraic-mode except only affects ( and [ keys. |
|
452 |
;;(defvar calc-incomplete-algebraic-mode nil) |
(defvar calc-incomplete-algebraic-mode nil |
453 |
|
"Like calc-algebraic-mode except only affects ( and [ keys.") |
454 |
;; If non-nil, inexact numeric computations like sqrt(2) are postponed. |
|
455 |
;; If nil, computations on numbers always yield numbers where possible. |
(defvar calc-symbolic-mode nil |
456 |
;;(defvar calc-symbolic-mode nil) |
"If non-nil, inexact numeric computations like sqrt(2) are postponed. |
457 |
|
If nil, computations on numbers always yield numbers where possible.") |
458 |
;; If 'matrix, variables are assumed to be matrix-valued. |
|
459 |
;; If a number, variables are assumed to be NxN matrices. |
(defvar calc-matrix-mode nil |
460 |
;; If 'scalar, variables are assumed to be scalar-valued. |
"If `matrix', variables are assumed to be matrix-valued. |
461 |
;; If nil, symbolic math routines make no assumptions about variables. |
If a number, variables are assumed to be NxN matrices. |
462 |
;;(defvar calc-matrix-mode nil) |
If `scalar', variables are assumed to be scalar-valued. |
463 |
|
If nil, symbolic math routines make no assumptions about variables.") |
464 |
;; If non-nil, shifted letter keys are prefix keys rather than normal meanings. |
|
465 |
;;(defvar calc-shift-prefix nil) |
(defvar calc-shift-prefix nil |
466 |
|
"If non-nil, shifted letter keys are prefix keys rather than normal meanings.") |
467 |
;; Initial height of Calculator window. |
|
468 |
;;(defvar calc-window-height 7) |
(defvar calc-window-height 7 |
469 |
|
"Initial height of Calculator window.") |
470 |
;; If non-nil, M-x calc creates a window to display Calculator trail. |
|
471 |
;;(defvar calc-display-trail t) |
(defvar calc-display-trail t |
472 |
|
"If non-nil, M-x calc creates a window to display Calculator trail.") |
473 |
;; If non-nil, selected sub-formulas are shown by obscuring rest of formula. |
|
474 |
;; If nil, selected sub-formulas are highlighted by obscuring the sub-formulas. |
(defvar calc-show-selections t |
475 |
;;(defvar calc-show-selections t) |
"If non-nil, selected sub-formulas are shown by obscuring rest of formula. |
476 |
|
If nil, selected sub-formulas are highlighted by obscuring the sub-formulas.") |
477 |
;; If non-nil, commands operate only on selected portions of formulas. |
|
478 |
;; If nil, selections displayed but ignored. |
(defvar calc-use-selections t |
479 |
;;(defvar calc-use-selections t) |
"If non-nil, commands operate only on selected portions of formulas. |
480 |
|
If nil, selections displayed but ignored.") |
481 |
;; If non-nil, selection hides deep structure of associative formulas. |
|
482 |
;;(defvar calc-assoc-selections t) |
(defvar calc-assoc-selections t |
483 |
|
"If non-nil, selection hides deep structure of associative formulas.") |
484 |
;; If non-nil, display "Working..." for potentially slow Calculator commands. |
|
485 |
;;(defvar calc-display-working-message 'lots) |
(defvar calc-display-working-message 'lots |
486 |
|
"If non-nil, display \"Working...\" for potentially slow Calculator commands.") |
487 |
;; If non-nil, automatically execute a "why" command to explain odd results. |
|
488 |
;;(defvar calc-auto-why nil) |
(defvar calc-auto-why 'maybe |
489 |
|
"If non-nil, automatically execute a \"why\" command to explain odd results.") |
490 |
;; If non-nil, display timing information on each slow command. |
|
491 |
;;(defvar calc-timing nil) |
(defvar calc-timing nil |
492 |
|
"If non-nil, display timing information on each slow command.") |
493 |
;; Floating-point numbers with this positive exponent or higher above the |
|
494 |
;; current precision are displayed in scientific notation in calc-mode. |
(defvar calc-display-sci-high 0 |
495 |
(defvar calc-display-sci-high 0) |
"Floating-point numbers with this positive exponent or higher above the |
496 |
|
current precision are displayed in scientific notation in calc-mode.") |
497 |
;; Floating-point numbers with this negative exponent or lower are displayed |
|
498 |
;; scientific notation in calc-mode. |
(defvar calc-display-sci-low -3 |
499 |
(defvar calc-display-sci-low -3) |
"Floating-point numbers with this negative exponent or lower are displayed |
500 |
|
scientific notation in calc-mode.") |
501 |
|
|
502 |
;; List of used-defined strings to append to Calculator mode line. |
|
503 |
(defvar calc-other-modes nil) |
(defvar calc-other-modes nil |
504 |
|
"List of used-defined strings to append to Calculator mode line.") |
505 |
;; List of strings for Y prefix help. |
|
506 |
(defvar calc-Y-help-msgs nil) |
(defvar calc-Y-help-msgs nil |
507 |
|
"List of strings for Y prefix help.") |
508 |
;; t if calc-settings-file has been loaded yet. |
|
509 |
(defvar calc-loaded-settings-file nil) |
(defvar calc-loaded-settings-file nil |
510 |
|
"t if `calc-settings-file' has been loaded yet.") |
511 |
|
|
512 |
|
|
513 |
(defconst calc-mode-var-list '((calc-always-load-extensions nil) |
|
514 |
(calc-mode-save-mode local) |
(defvar calc-mode-save-mode 'local) |
515 |
(calc-line-numbering t) |
(defvar calc-standard-date-formats |
516 |
(calc-line-breaking t) |
'("N" |
517 |
(calc-display-just nil) |
"<H:mm:SSpp >Www Mmm D, YYYY" |
518 |
(calc-display-origin nil) |
"D Mmm YYYY<, h:mm:SS>" |
519 |
(calc-left-label "") |
"Www Mmm BD< hh:mm:ss> YYYY" |
520 |
(calc-right-label "") |
"M/D/Y< H:mm:SSpp>" |
521 |
(calc-number-radix 10) |
"D.M.Y< h:mm:SS>" |
522 |
(calc-leading-zeros nil) |
"M-D-Y< H:mm:SSpp>" |
523 |
(calc-group-digits nil) |
"D-M-Y< h:mm:SS>" |
524 |
(calc-group-char ",") |
"j<, h:mm:SS>" |
525 |
(calc-point-char ".") |
"YYddd< hh:mm:ss>")) |
526 |
(calc-frac-format (":" nil)) |
(defvar calc-autorange-units nil) |
527 |
(calc-prefer-frac nil) |
(defvar calc-was-keypad-mode nil) |
528 |
(calc-hms-format "%s@ %s' %s\"") |
(defvar calc-full-mode nil) |
529 |
(calc-date-format ((H ":" mm C SS pp " ") |
(defvar calc-user-parse-tables nil) |
530 |
Www " " Mmm " " D ", " YYYY)) |
(defvar calc-gnuplot-default-device "default") |
531 |
(calc-standard-date-formats |
(defvar calc-gnuplot-default-output "STDOUT") |
532 |
("N" |
(defvar calc-gnuplot-print-device "postscript") |
533 |
"<H:mm:SSpp >Www Mmm D, YYYY" |
(defvar calc-gnuplot-print-output "auto") |
534 |
"D Mmm YYYY<, h:mm:SS>" |
(defvar calc-gnuplot-geometry nil) |
535 |
"Www Mmm BD< hh:mm:ss> YYYY" |
(defvar calc-graph-default-resolution 15) |
536 |
"M/D/Y< H:mm:SSpp>" |
(defvar calc-graph-default-resolution-3d 5) |
537 |
"D.M.Y< h:mm:SS>" |
(defvar calc-invocation-macro nil) |
538 |
"M-D-Y< H:mm:SSpp>" |
(defvar calc-show-banner t) |
|
"D-M-Y< h:mm:SS>" |
|
|
"j<, h:mm:SS>" |
|
|
"YYddd< hh:mm:ss>")) |
|
|
(calc-float-format (float 0)) |
|
|
(calc-full-float-format (float 0)) |
|
|
(calc-complex-format nil) |
|
|
(calc-matrix-just center) |
|
|
(calc-full-vectors t) |
|
|
(calc-full-trail-vectors t) |
|
|
(calc-break-vectors nil) |
|
|
(calc-vector-commas ",") |
|
|
(calc-vector-brackets "[]") |
|
|
(calc-matrix-brackets (R O)) |
|
|
(calc-complex-mode cplx) |
|
|
(calc-infinite-mode nil) |
|
|
(calc-display-strings nil) |
|
|
(calc-simplify-mode nil) |
|
|
(calc-auto-recompute t) |
|
|
(calc-word-size 32) |
|
|
(calc-previous-modulo nil) |
|
|
(calc-display-raw nil) |
|
|
(calc-internal-prec 12) |
|
|
(calc-angle-mode deg) |
|
|
(calc-algebraic-mode nil) |
|
|
(calc-incomplete-algebraic-mode nil) |
|
|
(calc-symbolic-mode nil) |
|
|
(calc-matrix-mode nil) |
|
|
(calc-autorange-units nil) |
|
|
(calc-shift-prefix nil) |
|
|
(calc-window-height 7) |
|
|
(calc-was-keypad-mode nil) |
|
|
(calc-full-mode nil) |
|
|
(calc-language nil) |
|
|
(calc-language-option nil) |
|
|
(calc-user-parse-tables nil) |
|
|
(calc-show-selections t) |
|
|
(calc-use-selections t) |
|
|
(calc-assoc-selections t) |
|
|
(calc-display-trail t) |
|
|
(calc-display-working-message lots) |
|
|
(calc-auto-why 'maybe) |
|
|
(calc-timing nil) |
|
|
(calc-gnuplot-default-device "default") |
|
|
(calc-gnuplot-default-output "STDOUT") |
|
|
(calc-gnuplot-print-device "postscript") |
|
|
(calc-gnuplot-print-output "auto") |
|
|
(calc-gnuplot-geometry nil) |
|
|
(calc-graph-default-resolution 15) |
|
|
(calc-graph-default-resolution-3d 5) |
|
|
(calc-invocation-macro nil) |
|
|
(calc-show-banner t))) |
|
539 |
|
|
540 |
(defconst calc-local-var-list '(calc-stack |
(defconst calc-local-var-list '(calc-stack |
541 |
calc-stack-top |
calc-stack-top |
593 |
calc-internal-prec)) |
calc-internal-prec)) |
594 |
|
|
595 |
|
|
596 |
(defun calc-init-base () |
;; Verify that Calc is running on the right kind of system. |
597 |
|
(defconst calc-emacs-type-epoch (and (fboundp 'epoch::version) epoch::version)) |
598 |
;; Verify that Calc is running on the right kind of system. |
(defvar calc-emacs-type-19 (not (or calc-emacs-type-epoch |
599 |
(setq calc-emacs-type-epoch (and (fboundp 'epoch::version) epoch::version) |
(string-lessp emacs-version "19")))) |
600 |
calc-emacs-type-19 (not (or calc-emacs-type-epoch |
(defvar calc-emacs-type-lucid (not (not (string-match "Lucid" emacs-version)))) |
601 |
(string-lessp emacs-version "19"))) |
(defvar calc-emacs-type-gnu19 (and calc-emacs-type-19 |
|
calc-emacs-type-lucid (not (not (string-match "Lucid" emacs-version))) |
|
|
calc-emacs-type-gnu19 (and calc-emacs-type-19 |
|
602 |
(not calc-emacs-type-lucid))) |
(not calc-emacs-type-lucid))) |
603 |
|
|
604 |
;; Set up the standard keystroke (M-#) to run the Calculator, if that key |
;; Set up the standard keystroke (M-#) to run the Calculator, if that key |
605 |
;; has not yet been bound to anything. For best results, the user should |
;; has not yet been bound to anything. For best results, the user should |
606 |
;; do this before Calc is even loaded, so that M-# can auto-load Calc. |
;; do this before Calc is even loaded, so that M-# can auto-load Calc. |
607 |
(or (global-key-binding "\e#") |
(or (global-key-binding "\e#") (global-set-key "\e#" 'calc-dispatch)) |
|
(global-set-key "\e#" 'calc-dispatch)) |
|
608 |
|
|
609 |
;; Set up the autoloading linkage. |
;; Set up the autoloading linkage. |
610 |
(let ((name (and (fboundp 'calc-dispatch) |
(let ((name (and (fboundp 'calc-dispatch) |
611 |
(eq (car-safe (symbol-function 'calc-dispatch)) 'autoload) |
(eq (car-safe (symbol-function 'calc-dispatch)) 'autoload) |
612 |
(nth 1 (symbol-function 'calc-dispatch)))) |
(nth 1 (symbol-function 'calc-dispatch)))) |
613 |
(p load-path)) |
(p load-path)) |
627 |
(while (and p2 (not (file-exists-p |
(while (and p2 (not (file-exists-p |
628 |
(expand-file-name name2 (car p2))))) |
(expand-file-name name2 (car p2))))) |
629 |
(setq p2 (cdr p2))) |
(setq p2 (cdr p2))) |
630 |
(if p2 |
(when p2 |
631 |
(setq load-path (nconc load-path |
(setq load-path (nconc load-path |
632 |
(list |
(list |
633 |
(directory-file-name |
(directory-file-name |
634 |
(file-name-directory |
(file-name-directory |
635 |
(expand-file-name |
(expand-file-name |
636 |
name (car p2)))))))))) |
name (car p2)))))))))) |
637 |
|
|
638 |
;; If calc-autoload-directory is given, use that (and hope it works!). |
;; If calc-autoload-directory is given, use that (and hope it works!). |
639 |
(and calc-autoload-directory |
(and calc-autoload-directory |
642 |
(list (directory-file-name |
(list (directory-file-name |
643 |
calc-autoload-directory))))))) |
calc-autoload-directory))))))) |
644 |
|
|
645 |
;; The following modes use specially-formatted data. |
;; The following modes use specially-formatted data. |
646 |
(put 'calc-mode 'mode-class 'special) |
(put 'calc-mode 'mode-class 'special) |
647 |
(put 'calc-trail-mode 'mode-class 'special) |
(put 'calc-trail-mode 'mode-class 'special) |
648 |
|
|
649 |
;; Define "inexact-result" as an e-lisp error symbol. |
;; Define "inexact-result" as an e-lisp error symbol. |
650 |
(put 'inexact-result 'error-conditions '(error inexact-result calc-error)) |
(put 'inexact-result 'error-conditions '(error inexact-result calc-error)) |
651 |
(put 'inexact-result 'error-message "Calc internal error (inexact-result)") |
(put 'inexact-result 'error-message "Calc internal error (inexact-result)") |
652 |
|
|
653 |
;; Define "math-overflow" and "math-underflow" as e-lisp error symbols. |
;; Define "math-overflow" and "math-underflow" as e-lisp error symbols. |
654 |
(put 'math-overflow 'error-conditions '(error math-overflow calc-error)) |
(put 'math-overflow 'error-conditions '(error math-overflow calc-error)) |
655 |
(put 'math-overflow 'error-message "Floating-point overflow occurred") |
(put 'math-overflow 'error-message "Floating-point overflow occurred") |
656 |
(put 'math-underflow 'error-conditions '(error math-underflow calc-error)) |
(put 'math-underflow 'error-conditions '(error math-underflow calc-error)) |
657 |
(put 'math-underflow 'error-message "Floating-point underflow occurred") |
(put 'math-underflow 'error-message "Floating-point underflow occurred") |
658 |
|
|
659 |
(setq calc-version "2.02g" |
(defconst calc-version "2.02g") |
660 |
calc-version-date "Mon Nov 19 2001" |
(defconst calc-version-date "Mon Nov 19 2001") |
661 |
calc-trail-pointer nil ; "Current" entry in trail buffer. |
(defvar calc-trail-pointer nil) ; "Current" entry in trail buffer. |
662 |
calc-trail-overlay nil ; Value of overlay-arrow-string. |
(defvar calc-trail-overlay nil) ; Value of overlay-arrow-string. |
663 |
calc-undo-list nil ; List of previous operations for undo. |
(defvar calc-undo-list nil) ; List of previous operations for undo. |
664 |
calc-redo-list nil ; List of recent undo operations. |
(defvar calc-redo-list nil) ; List of recent undo operations. |
665 |
calc-main-buffer nil ; Pointer to Calculator buffer. |
(defvar calc-main-buffer nil) ; Pointer to Calculator buffer. |
666 |
calc-trail-buffer nil ; Pointer to Calc Trail buffer. |
(defvar calc-trail-buffer nil) ; Pointer to Calc Trail buffer. |
667 |
calc-why nil ; Explanations of most recent errors. |
(defvar calc-why nil) ; Explanations of most recent errors. |
668 |
calc-next-why nil |
(defvar calc-next-why nil) |
669 |
calc-inverse-flag nil |
(defvar calc-inverse-flag nil) |
670 |
calc-hyperbolic-flag nil |
(defvar calc-hyperbolic-flag nil) |
671 |
calc-keep-args-flag nil |
(defvar calc-keep-args-flag nil) |
672 |
calc-function-open "(" |
(defvar calc-last-kill nil) ; Last number killed in calc-mode. |
673 |
calc-function-close ")" |
(defvar calc-previous-alg-entry nil) ; Previous algebraic entry. |
674 |
calc-language-output-filter nil |
(defvar calc-dollar-values nil) ; Values to be used for '$'. |
675 |
calc-language-input-filter nil |
(defvar calc-dollar-used nil) ; Highest order of '$' that occurred. |
676 |
calc-radix-formatter nil |
(defvar calc-hashes-used nil) ; Highest order of '#' that occurred. |
677 |
calc-last-kill nil ; Last number killed in calc-mode. |
(defvar calc-quick-prev-results nil) ; Previous results from Quick Calc. |
678 |
calc-previous-alg-entry nil ; Previous algebraic entry. |
(defvar calc-said-hello nil) ; Has welcome message been said yet? |
679 |
calc-dollar-values nil ; Values to be used for '$'. |
(defvar calc-executing-macro nil) ; Kbd macro executing from "K" key. |
680 |
calc-dollar-used nil ; Highest order of '$' that occurred. |
(defvar calc-any-selections nil) ; Nil means no selections present. |
681 |
calc-hashes-used nil ; Highest order of '#' that occurred. |
(defvar calc-help-phase 0) ; Count of consecutive "?" keystrokes. |
682 |
calc-quick-prev-results nil ; Previous results from Quick Calc. |
(defvar calc-full-help-flag nil) ; Executing calc-full-help? |
683 |
calc-said-hello nil ; Has welcome message been said yet? |
(defvar calc-refresh-count 0) ; Count of calc-refresh calls. |
684 |
calc-executing-macro nil ; Kbd macro executing from "K" key. |
(defvar calc-display-dirty nil) |
685 |
calc-any-selections nil ; Nil means no selections present. |
(defvar calc-prepared-composition nil) |
686 |
calc-help-phase 0 ; Count of consecutive "?" keystrokes. |
(defvar calc-selection-cache-default-entry nil) |
687 |
calc-full-help-flag nil ; Executing calc-full-help? |
(defvar calc-embedded-info nil) |
688 |
calc-refresh-count 0 ; Count of calc-refresh calls. |
(defvar calc-embedded-active nil) |
689 |
calc-display-dirty nil |
(defvar calc-standalone-flag nil) |
690 |
calc-prepared-composition nil |
(defvar var-EvalRules nil) |
691 |
calc-selection-cache-default-entry nil |
(defvar math-eval-rules-cache-tag t) |
692 |
calc-embedded-info nil |
(defvar math-radix-explicit-format t) |
693 |
calc-embedded-active nil |
(defvar math-expr-function-mapping nil) |
694 |
calc-standalone-flag nil |
(defvar math-expr-variable-mapping nil) |
695 |
var-EvalRules nil |
(defvar math-read-expr-quotes nil) |
696 |
math-eval-rules-cache-tag t |
(defvar math-working-step nil) |
697 |
math-radix-explicit-format t |
(defvar math-working-step-2 nil) |
698 |
math-expr-function-mapping nil |
(defvar var-i '(special-const (math-imaginary 1))) |
699 |
math-expr-variable-mapping nil |
(defvar var-pi '(special-const (math-pi))) |
700 |
math-read-expr-quotes nil |
(defvar var-e '(special-const (math-e))) |
701 |
math-working-step nil |
(defvar var-phi '(special-const (math-phi))) |
702 |
math-working-step-2 nil |
(defvar var-gamma '(special-const (math-gamma-const))) |
703 |
var-i '(special-const (math-imaginary 1)) |
(defvar var-Modes '(special-const (math-get-modes-vec))) |
704 |
var-pi '(special-const (math-pi)) |
|
705 |
var-e '(special-const (math-e)) |
(mapcar (lambda (v) (or (boundp v) (set v nil))) |
|
var-phi '(special-const (math-phi)) |
|
|
var-gamma '(special-const (math-gamma-const)) |
|
|
var-Modes '(special-const (math-get-modes-vec))) |
|
|
|
|
|
(mapcar (function (lambda (v) (or (boundp (car v)) (set (car v) (nth 1 v))))) |
|
|
calc-mode-var-list) |
|
|
(mapcar (function (lambda (v) (or (boundp v) (set v nil)))) |
|
706 |
calc-local-var-list) |
calc-local-var-list) |
707 |
|
|
708 |
(unless (boundp 'calc-mode-map) |
(defvar calc-mode-map |
709 |
(setq calc-mode-map (make-keymap)) |
(let ((map (make-keymap))) |
710 |
(suppress-keymap calc-mode-map t) |
(suppress-keymap map t) |
711 |
(define-key calc-mode-map "+" 'calc-plus) |
(define-key map "+" 'calc-plus) |
712 |
(define-key calc-mode-map "-" 'calc-minus) |
(define-key map "-" 'calc-minus) |
713 |
(define-key calc-mode-map "*" 'calc-times) |
(define-key map "*" 'calc-times) |
714 |
(define-key calc-mode-map "/" 'calc-divide) |
(define-key map "/" 'calc-divide) |
715 |
(define-key calc-mode-map "%" 'calc-mod) |
(define-key map "%" 'calc-mod) |
716 |
(define-key calc-mode-map "&" 'calc-inv) |
(define-key map "&" 'calc-inv) |
717 |
(define-key calc-mode-map "^" 'calc-power) |
(define-key map "^" 'calc-power) |
718 |
(define-key calc-mode-map "\M-%" 'calc-percent) |
(define-key map "\M-%" 'calc-percent) |
719 |
(define-key calc-mode-map "e" 'calcDigit-start) |
(define-key map "e" 'calcDigit-start) |
720 |
(define-key calc-mode-map "i" 'calc-info) |
(define-key map "i" 'calc-info) |
721 |
(define-key calc-mode-map "n" 'calc-change-sign) |
(define-key map "n" 'calc-change-sign) |
722 |
(define-key calc-mode-map "q" 'calc-quit) |
(define-key map "q" 'calc-quit) |
723 |
(define-key calc-mode-map "Y" 'nil) |
(define-key map "Y" 'nil) |
724 |
(define-key calc-mode-map "Y?" 'calc-shift-Y-prefix-help) |
(define-key map "Y?" 'calc-shift-Y-prefix-help) |
725 |
(define-key calc-mode-map "?" 'calc-help) |
(define-key map "?" 'calc-help) |
726 |
(define-key calc-mode-map " " 'calc-enter) |
(define-key map " " 'calc-enter) |
727 |
(define-key calc-mode-map "'" 'calc-algebraic-entry) |
(define-key map "'" 'calc-algebraic-entry) |
728 |
(define-key calc-mode-map "$" 'calc-auto-algebraic-entry) |
(define-key map "$" 'calc-auto-algebraic-entry) |
729 |
(define-key calc-mode-map "\"" 'calc-auto-algebraic-entry) |
(define-key map "\"" 'calc-auto-algebraic-entry) |
730 |
(define-key calc-mode-map "\t" 'calc-roll-down) |
(define-key map "\t" 'calc-roll-down) |
731 |
(define-key calc-mode-map "\M-\t" 'calc-roll-up) |
(define-key map "\M-\t" 'calc-roll-up) |
732 |
(define-key calc-mode-map "\C-m" 'calc-enter) |
(define-key map "\C-m" 'calc-enter) |
733 |
(define-key calc-mode-map "\M-\C-m" 'calc-last-args-stub) |
(define-key map "\M-\C-m" 'calc-last-args-stub) |
734 |
(define-key calc-mode-map "\C-j" 'calc-over) |
(define-key map "\C-j" 'calc-over) |
735 |
|
|
736 |
(mapcar (function |
(mapcar (lambda (x) (define-key map (char-to-string x) 'undefined)) |
|
(lambda (x) |
|
|
(define-key calc-mode-map (char-to-string x) 'undefined))) |
|
737 |
"lOW") |
"lOW") |
738 |
(mapcar (function |
(mapcar (lambda (x) (define-key map (char-to-string x) 'calc-missing-key)) |
|
(lambda (x) |
|
|
(define-key calc-mode-map (char-to-string x) |
|
|
'calc-missing-key))) |
|
739 |
(concat "ABCDEFGHIJKLMNPQRSTUVXZabcdfghjkmoprstuvwxyz" |
(concat "ABCDEFGHIJKLMNPQRSTUVXZabcdfghjkmoprstuvwxyz" |
740 |
":\\|!()[]<>{},;=~`\C-k\M-k\C-w\M-w\C-y\C-_")) |
":\\|!()[]<>{},;=~`\C-k\M-k\C-w\M-w\C-y\C-_")) |
741 |
(mapcar (function |
(mapcar (lambda (x) (define-key map (char-to-string x) 'calcDigit-start)) |
|
(lambda (x) |
|
|
(define-key calc-mode-map (char-to-string x) 'calcDigit-start))) |
|
742 |
"_0123456789.#@") |
"_0123456789.#@") |
743 |
|
map)) |
744 |
|
|
745 |
(setq calc-digit-map (make-keymap)) |
(defvar calc-digit-map |
746 |
|
(let ((map (make-keymap))) |
747 |
(if calc-emacs-type-lucid |
(if calc-emacs-type-lucid |
748 |
(map-keymap (function |
(map-keymap (function |
749 |
(lambda (keys bind) |
(lambda (keys bind) |
750 |
(define-key calc-digit-map keys |
(define-key map keys |
751 |
(if (eq bind 'undefined) |
(if (eq bind 'undefined) |
752 |
'undefined 'calcDigit-nondigit)))) |
'undefined 'calcDigit-nondigit)))) |
753 |
calc-mode-map) |
calc-mode-map) |
754 |
(let ((cmap (if calc-emacs-type-19 (nth 1 calc-mode-map) calc-mode-map)) |
(let ((cmap (if calc-emacs-type-19 (nth 1 calc-mode-map) calc-mode-map)) |
755 |
(dmap (if calc-emacs-type-19 (nth 1 calc-digit-map) |
(dmap (if calc-emacs-type-19 (nth 1 map) map)) |
|
calc-digit-map)) |
|
756 |
(i 0)) |
(i 0)) |
757 |
(while (< i 128) |
(while (< i 128) |
758 |
(aset dmap i |
(aset dmap i |
759 |
(if (eq (aref cmap i) 'undefined) |
(if (eq (aref cmap i) 'undefined) |
760 |
'undefined 'calcDigit-nondigit)) |
'undefined 'calcDigit-nondigit)) |
761 |
(setq i (1+ i))))) |
(setq i (1+ i))))) |
762 |
(mapcar (function |
(mapcar (lambda (x) (define-key map (char-to-string x) 'calcDigit-key)) |
|
(lambda (x) |
|
|
(define-key calc-digit-map (char-to-string x) |
|
|
'calcDigit-key))) |
|
763 |
"_0123456789.e+-:n#@oh'\"mspM") |
"_0123456789.e+-:n#@oh'\"mspM") |
764 |
(mapcar (function |
(mapcar (lambda (x) (define-key map (char-to-string x) 'calcDigit-letter)) |
|
(lambda (x) |
|
|
(define-key calc-digit-map (char-to-string x) |
|
|
'calcDigit-letter))) |
|
765 |
"abcdfgijklqrtuvwxyzABCDEFGHIJKLNOPQRSTUVWXYZ") |
"abcdfgijklqrtuvwxyzABCDEFGHIJKLNOPQRSTUVWXYZ") |
766 |
(define-key calc-digit-map "'" 'calcDigit-algebraic) |
(define-key map "'" 'calcDigit-algebraic) |
767 |
(define-key calc-digit-map "`" 'calcDigit-edit) |
(define-key map "`" 'calcDigit-edit) |
768 |
(define-key calc-digit-map "\C-g" 'abort-recursive-edit) |
(define-key map "\C-g" 'abort-recursive-edit) |
769 |
|
map)) |
770 |
|
|
771 |
(mapcar (function |
(mapcar (lambda (x) |
|
(lambda (x) |
|
772 |
(condition-case err |
(condition-case err |
773 |
(progn |
(progn |
774 |
(define-key calc-digit-map x 'calcDigit-backspace) |
(define-key calc-digit-map x 'calcDigit-backspace) |
784 |
(vconcat "\e" x)) |
(vconcat "\e" x)) |
785 |
(concat "\e" x)) |
(concat "\e" x)) |
786 |
'calc-pop-above)) |
'calc-pop-above)) |
787 |
(error nil)))) |
(error nil))) |
788 |
(if calc-scan-for-dels |
(if calc-scan-for-dels |
789 |
(append (where-is-internal 'delete-backward-char global-map) |
(append (where-is-internal 'delete-backward-char global-map) |
790 |
(where-is-internal 'backward-delete-char global-map) |
(where-is-internal 'backward-delete-char global-map) |
791 |
'("\C-d")) |
'("\C-d")) |
792 |
'("\177" "\C-d"))) |
'("\177" "\C-d"))) |
793 |
|
|
794 |
(setq calc-dispatch-map (make-keymap)) |
(defvar calc-dispatch-map |
795 |
(mapcar (function |
(let ((map (make-keymap))) |
796 |
(lambda (x) |
(mapcar (lambda (x) |
797 |
(define-key calc-dispatch-map (char-to-string (car x)) (cdr x)) |
(define-key map (char-to-string (car x)) (cdr x)) |
798 |
(if (string-match "abcdefhijklnopqrstuwxyz" |
(when (string-match "abcdefhijklnopqrstuwxyz" |
799 |
(char-to-string (car x))) |
(char-to-string (car x))) |
800 |
(define-key calc-dispatch-map |
(define-key map (char-to-string (- (car x) ?a -1)) (cdr x))) |
801 |
(char-to-string (- (car x) ?a -1)) (cdr x))) |
(define-key map (format "\e%c" (car x)) (cdr x))) |
|
(define-key calc-dispatch-map (format "\e%c" (car x)) (cdr x)))) |
|
802 |
'( ( ?a . calc-embedded-activate ) |
'( ( ?a . calc-embedded-activate ) |
803 |
( ?b . calc-big-or-small ) |
( ?b . calc-big-or-small ) |
804 |
( ?c . calc ) |
( ?c . calc ) |
832 |
( ?0 . calc-reset ) |
( ?0 . calc-reset ) |
833 |
( ?# . calc-same-interface ) |
( ?# . calc-same-interface ) |
834 |
( ?? . calc-dispatch-help ) )) |
( ?? . calc-dispatch-help ) )) |
835 |
) |
map)) |
836 |
|
|
837 |
(autoload 'calc-extensions "calc-ext") |
(autoload 'calc-extensions "calc-ext") |
838 |
(autoload 'calc-need-macros "calc-macs") |
(autoload 'calc-need-macros "calc-macs") |
839 |
|
|
840 |
;;;; (Autoloads here) |
;;;; (Autoloads here) |
841 |
(mapcar (function (lambda (x) |
(mapcar |
842 |
(mapcar (function (lambda (func) |
(lambda (x) (dolist (func (cdr x)) (autoload func (car x)))) |
|
(autoload func (car x)))) (cdr x)))) |
|
843 |
'( |
'( |
844 |
|
|
845 |
("calc-aent" calc-Need-calc-aent calc-alg-digit-entry calc-alg-entry |
("calc-aent" calc-Need-calc-aent calc-alg-digit-entry calc-alg-entry |
846 |
calc-check-user-syntax calc-do-alg-entry calc-do-calc-eval |
calc-check-user-syntax calc-do-alg-entry calc-do-calc-eval |
847 |
calc-do-quick-calc calc-match-user-syntax math-build-parse-table |
calc-do-quick-calc calc-match-user-syntax math-build-parse-table |
848 |
math-find-user-tokens math-read-expr-list math-read-exprs math-read-if |
math-find-user-tokens math-read-expr-list math-read-exprs math-read-if |
849 |
math-read-token math-remove-dashes) |
math-read-token math-remove-dashes) |
850 |
|
|
851 |
("calc-misc" calc-Need-calc-misc |
("calc-misc" calc-Need-calc-misc |
852 |
calc-do-handle-whys calc-do-refresh calc-num-prefix-name |
calc-do-handle-whys calc-do-refresh calc-num-prefix-name |
853 |
calc-record-list calc-record-why calc-report-bug calc-roll-down-stack |
calc-record-list calc-record-why calc-report-bug calc-roll-down-stack |
854 |
calc-roll-up-stack calc-temp-minibuffer-message calcFunc-floor |
calc-roll-up-stack calc-temp-minibuffer-message calcFunc-floor |
855 |
calcFunc-inv calcFunc-trunc math-concat math-constp math-div2 |
calcFunc-inv calcFunc-trunc math-concat math-constp math-div2 |
856 |
math-div2-bignum math-do-working math-evenp math-fixnatnump |
math-div2-bignum math-do-working math-evenp math-fixnatnump |
857 |
math-fixnump math-floor math-imod math-ipow math-looks-negp math-mod |
math-fixnump math-floor math-imod math-ipow math-looks-negp math-mod |
858 |
math-negp math-posp math-pow math-read-radix-digit math-reject-arg |
math-negp math-posp math-pow math-read-radix-digit math-reject-arg |
859 |
math-trunc math-zerop) |
math-trunc math-zerop))) |
|
|
|
|
)) |
|
860 |
|
|
861 |
(mapcar (function (lambda (x) |
(mapcar |
862 |
(mapcar (function (lambda (cmd) |
(lambda (x) (dolist (cmd (cdr x)) (autoload cmd (car x) nil t))) |
|
(autoload cmd (car x) nil t))) (cdr x)))) |
|
863 |
'( |
'( |
864 |
|
|
865 |
("calc-aent" calc-algebraic-entry calc-auto-algebraic-entry |
("calc-aent" calc-algebraic-entry calc-auto-algebraic-entry |
866 |
calcDigit-algebraic calcDigit-edit) |
calcDigit-algebraic calcDigit-edit) |
867 |
|
|
868 |
("calc-misc" another-calc calc-big-or-small calc-dispatch-help |
("calc-misc" another-calc calc-big-or-small calc-dispatch-help |
869 |
calc-help calc-info calc-info-summary calc-inv calc-last-args-stub |
calc-help calc-info calc-info-summary calc-inv calc-last-args-stub |
870 |
calc-missing-key calc-mod calc-other-window calc-over calc-percent |
calc-missing-key calc-mod calc-other-window calc-over calc-percent |
871 |
calc-pop-above calc-power calc-roll-down calc-roll-up |
calc-pop-above calc-power calc-roll-down calc-roll-up |
872 |
calc-shift-Y-prefix-help calc-tutorial calcDigit-letter |
calc-shift-Y-prefix-help calc-tutorial calcDigit-letter |
873 |
report-calc-bug)))) |
report-calc-bug))) |
|
|
|
|
(calc-init-base) |
|
874 |
|
|
875 |
|
|
876 |
;;;###autoload (global-set-key "\e#" 'calc-dispatch) |
;;;###autoload (global-set-key "\e#" 'calc-dispatch) |
882 |
(sit-for echo-keystrokes) |
(sit-for echo-keystrokes) |
883 |
(condition-case err ; look for other keys bound to calc-dispatch |
(condition-case err ; look for other keys bound to calc-dispatch |
884 |
(let ((keys (this-command-keys))) |
(let ((keys (this-command-keys))) |
885 |
(or (not (stringp keys)) |
(unless (or (not (stringp keys)) |
886 |
(string-match "\\`\C-u\\|\\`\e[-0-9#]\\|`[\M--\M-0-\M-9]" keys) |
(string-match "\\`\C-u\\|\\`\e[-0-9#]\\|`[\M--\M-0-\M-9]" keys) |
887 |
(eq (lookup-key calc-dispatch-map keys) 'calc-same-interface) |
(eq (lookup-key calc-dispatch-map keys) 'calc-same-interface)) |
888 |
(progn |
(when (and (string-match "\\`[\C-@-\C-_]" keys) |
889 |
(and (string-match "\\`[\C-@-\C-_]" keys) |
(symbolp |
890 |
(symbolp |
(lookup-key calc-dispatch-map (substring keys 0 1)))) |
891 |
(lookup-key calc-dispatch-map (substring keys 0 1))) |
(define-key calc-dispatch-map (substring keys 0 1) nil)) |
892 |
(define-key calc-dispatch-map (substring keys 0 1) nil)) |
(define-key calc-dispatch-map keys 'calc-same-interface))) |
|
(define-key calc-dispatch-map keys 'calc-same-interface)))) |
|
893 |
(error nil)) |
(error nil)) |
894 |
(calc-do-dispatch arg)) |
(calc-do-dispatch arg)) |
895 |
|
|
970 |
(mapcar (function (lambda (v) (make-local-variable v))) calc-local-var-list) |
(mapcar (function (lambda (v) (make-local-variable v))) calc-local-var-list) |
971 |
(make-local-variable 'overlay-arrow-position) |
(make-local-variable 'overlay-arrow-position) |
972 |
(make-local-variable 'overlay-arrow-string) |
(make-local-variable 'overlay-arrow-string) |
973 |
|
(add-hook 'change-major-mode-hook 'font-lock-defontify nil t) |
974 |
(setq truncate-lines t) |
(setq truncate-lines t) |
975 |
(setq buffer-read-only t) |
(setq buffer-read-only t) |
976 |
(setq major-mode 'calc-mode) |
(setq major-mode 'calc-mode) |
1000 |
(calc-refresh t) |
(calc-refresh t) |
1001 |
(calc-set-mode-line) |
(calc-set-mode-line) |
1002 |
;; The calc-defs variable is a relic. Use calc-define properties instead. |
;; The calc-defs variable is a relic. Use calc-define properties instead. |
1003 |
(if (and (boundp 'calc-defs) |
(when (and (boundp 'calc-defs) |
1004 |
calc-defs) |
calc-defs) |
1005 |
(progn |
(message "Evaluating calc-defs...") |
1006 |
(message "Evaluating calc-defs...") |
(calc-need-macros) |
1007 |
(calc-need-macros) |
(eval (cons 'progn calc-defs)) |
1008 |
(eval (cons 'progn calc-defs)) |
(setq calc-defs nil) |
1009 |
(setq calc-defs nil) |
(calc-set-mode-line)) |
|
(calc-set-mode-line))) |
|
1010 |
(calc-check-defines)) |
(calc-check-defines)) |
1011 |
|
|
1012 |
(defvar calc-check-defines 'calc-check-defines) ; suitable for run-hooks |
(defvar calc-check-defines 'calc-check-defines) ; suitable for run-hooks |
1047 |
(setq buffer-read-only t) |
(setq buffer-read-only t) |
1048 |
(make-local-variable 'overlay-arrow-position) |
(make-local-variable 'overlay-arrow-position) |
1049 |
(make-local-variable 'overlay-arrow-string) |
(make-local-variable 'overlay-arrow-string) |
1050 |
(if buf |
(set (make-local-variable 'font-lock-defaults) |
1051 |
(progn |
'(nil t nil nil nil (font-lock-core-only . t))) |
1052 |
(make-local-variable 'calc-main-buffer) |
(when buf |
1053 |
(setq calc-main-buffer buf))) |
(set (make-local-variable 'calc-main-buffer) buf)) |
1054 |
(if (= (buffer-size) 0) |
(when (= (buffer-size) 0) |
1055 |
(let ((buffer-read-only nil)) |
(let ((buffer-read-only nil)) |
1056 |
(insert "Emacs Calculator v" calc-version " by Dave Gillespie\n"))) |
(insert (propertize (concat "Emacs Calculator v" calc-version |
1057 |
|
" by Dave Gillespie\n") |
1058 |
|
'font-lock-face 'italic)))) |
1059 |
(run-hooks 'calc-trail-mode-hook)) |
(run-hooks 'calc-trail-mode-hook)) |
1060 |
|
|
1061 |
(defun calc-create-buffer () |
(defun calc-create-buffer () |
1063 |
(or (eq major-mode 'calc-mode) |
(or (eq major-mode 'calc-mode) |
1064 |
(calc-mode)) |
(calc-mode)) |
1065 |
(setq max-lisp-eval-depth (max max-lisp-eval-depth 1000)) |
(setq max-lisp-eval-depth (max max-lisp-eval-depth 1000)) |
1066 |
(if calc-always-load-extensions |
(when calc-always-load-extensions |
1067 |
(calc-extensions)) |
(calc-extensions)) |
1068 |
(if calc-language |
(when calc-language |
1069 |
(progn |
(calc-extensions) |
1070 |
(calc-extensions) |
(calc-set-language calc-language calc-language-option t))) |
|
(calc-set-language calc-language calc-language-option t)))) |
|
1071 |
|
|
1072 |
;;;###autoload |
;;;###autoload |
1073 |
(defun calc (&optional arg full-display interactive) |
(defun calc (&optional arg full-display interactive) |
1074 |
"The Emacs Calculator. Full documentation is listed under \"calc-mode\"." |
"The Emacs Calculator. Full documentation is listed under \"calc-mode\"." |
1075 |
(interactive "P") |
(interactive "P") |
1076 |
(if arg |
(if arg |
1077 |
(or (eq arg 0) |
(unless (eq arg 0) |
1078 |
(progn |
(calc-extensions) |
1079 |
(calc-extensions) |
(if (= (prefix-numeric-value arg) -1) |
1080 |
(if (= (prefix-numeric-value arg) -1) |
(calc-grab-region (region-beginning) (region-end) nil) |
1081 |
(calc-grab-region (region-beginning) (region-end) nil) |
(when (= (prefix-numeric-value arg) -2) |
1082 |
(if (= (prefix-numeric-value arg) -2) |
(calc-keypad)))) |
1083 |
(calc-keypad))))) |
(when (get-buffer-window "*Calc Keypad*") |
1084 |
(if (get-buffer-window "*Calc Keypad*") |
(calc-keypad) |
1085 |
(progn |
(set-buffer (window-buffer (selected-window)))) |
|
(calc-keypad) |
|
|
(set-buffer (window-buffer (selected-window))))) |
|
1086 |
(if (eq major-mode 'calc-mode) |
(if (eq major-mode 'calc-mode) |
1087 |
(calc-quit) |
(calc-quit) |
1088 |
(let ((oldbuf (current-buffer))) |
(let ((oldbuf (current-buffer))) |
1118 |
(window-point full-display) |
(window-point full-display) |
1119 |
(select-window full-display)) |
(select-window full-display)) |
1120 |
(calc-check-defines) |
(calc-check-defines) |
1121 |
(and calc-said-hello |
(when (and calc-said-hello |
1122 |
(or (interactive-p) interactive) |
(or (interactive-p) interactive)) |
1123 |
(progn |
(sit-for 2) |
1124 |
(sit-for 2) |
(message "")) |
|
(message ""))) |
|
1125 |
(setq calc-said-hello t))))) |
(setq calc-said-hello t))))) |
1126 |
|
|
1127 |
;;;###autoload |
;;;###autoload |
1216 |
|
|
1217 |
(defvar calc-aborted-prefix nil) |
(defvar calc-aborted-prefix nil) |
1218 |
(defvar calc-start-time nil) |
(defvar calc-start-time nil) |
1219 |
|
(defvar calc-command-flags) |
1220 |
|
(defvar calc-final-point-line) |
1221 |
|
(defvar calc-final-point-column) |
1222 |
;;; Note that modifications to this function may break calc-pass-errors. |
;;; Note that modifications to this function may break calc-pass-errors. |
1223 |
(defun calc-do (do-body &optional do-slow) |
(defun calc-do (do-body &optional do-slow) |
1224 |
(calc-check-defines) |
(calc-check-defines) |
1227 |
(calc-extensions) |
(calc-extensions) |
1228 |
(current-time-string))) |
(current-time-string))) |
1229 |
(gc-cons-threshold (max gc-cons-threshold |
(gc-cons-threshold (max gc-cons-threshold |
1230 |
(if calc-timing 2000000 100000)))) |
(if calc-timing 2000000 100000))) |
1231 |
|
calc-final-point-line calc-final-point-column) |
1232 |
(setq calc-aborted-prefix "") |
(setq calc-aborted-prefix "") |
1233 |
(unwind-protect |
(unwind-protect |
1234 |
(condition-case err |
(condition-case err |
1256 |
(error "Computation got stuck or ran too long. Type `M' to increase the limit") |
(error "Computation got stuck or ran too long. Type `M' to increase the limit") |
1257 |
(setq calc-aborted-prefix nil) |
(setq calc-aborted-prefix nil) |
1258 |
(signal (car err) (cdr err))))) |
(signal (car err) (cdr err))))) |
|
(setq calc-old-aborted-prefix calc-aborted-prefix) |
|
1259 |
(when calc-aborted-prefix |
(when calc-aborted-prefix |
1260 |
(calc-record "<Aborted>" calc-aborted-prefix)) |
(calc-record "<Aborted>" calc-aborted-prefix)) |
1261 |
(and calc-start-time |
(and calc-start-time |
1278 |
(progn |
(progn |
1279 |
(goto-line calc-final-point-line) |
(goto-line calc-final-point-line) |
1280 |
(move-to-column calc-final-point-column)) |
(move-to-column calc-final-point-column)) |
1281 |
(save-excursion |
(save-current-buffer |
1282 |
(calc-select-buffer) |
(calc-select-buffer) |
1283 |
(goto-line calc-final-point-line) |
(goto-line calc-final-point-line) |
1284 |
(move-to-column calc-final-point-column)))) |
(move-to-column calc-final-point-column)))) |
1547 |
(delete-region (point) (point-max)))) |
(delete-region (point) (point-max)))) |
1548 |
(calc-set-command-flag 'renum-stack)))))) |
(calc-set-command-flag 'renum-stack)))))) |
1549 |
|
|
1550 |
|
(defvar sel-mode) |
1551 |
(defun calc-get-stack-element (x) |
(defun calc-get-stack-element (x) |
1552 |
(cond ((eq sel-mode 'entry) |
(cond ((eq sel-mode 'entry) |
1553 |
x) |
x) |
1616 |
stack (cdr stack)))))) |
stack (cdr stack)))))) |
1617 |
(and calc-embedded-info (calc-embedded-stack-change))) |
(and calc-embedded-info (calc-embedded-stack-change))) |
1618 |
|
|
1619 |
|
(defvar calc-any-evaltos nil) |
1620 |
(defun calc-refresh (&optional align) |
(defun calc-refresh (&optional align) |
1621 |
(interactive) |
(interactive) |
1622 |
(and (eq major-mode 'calc-mode) |
(and (eq major-mode 'calc-mode) |
1625 |
(save-point (point)) |
(save-point (point)) |
1626 |
(save-mark (condition-case err (mark) (error nil))) |
(save-mark (condition-case err (mark) (error nil))) |
1627 |
(save-aligned (looking-at "\\.$")) |
(save-aligned (looking-at "\\.$")) |
1628 |
(thing calc-stack)) |
(thing calc-stack) |
1629 |
(setq calc-any-selections nil |
(calc-any-evaltos nil)) |
1630 |
calc-any-evaltos nil) |
(setq calc-any-selections nil) |
1631 |
(erase-buffer) |
(erase-buffer) |
1632 |
(when calc-show-banner |
(when calc-show-banner |
1633 |
(insert "--- Emacs Calculator Mode ---\n")) |
(insert (propertize "--- Emacs Calculator Mode ---\n" |
1634 |
|
'font-lock-face 'italic))) |
1635 |
(while thing |
(while thing |
1636 |
(goto-char (point-min)) |
(goto-char (point-min)) |
1637 |
(when calc-show-banner |
(when calc-show-banner |
1897 |
|
|
1898 |
|
|
1899 |
;;;; Reading a number using the minibuffer. |
;;;; Reading a number using the minibuffer. |
1900 |
|
(defvar calc-buffer) |
1901 |
|
(defvar calc-prev-char) |
1902 |
|
(defvar calc-prev-prev-char) |
1903 |
|
(defvar calc-digit-value) |
1904 |
(defun calcDigit-start () |
(defun calcDigit-start () |
1905 |
(interactive) |
(interactive) |
1906 |
(calc-wrapper |
(calc-wrapper |
2182 |
;;; Also, [Public] marks routines intended to be called from outside. |
;;; Also, [Public] marks routines intended to be called from outside. |
2183 |
;;; [This notation has been neglected in many recent routines.] |
;;; [This notation has been neglected in many recent routines.] |
2184 |
|
|
2185 |
|
(defvar math-eval-rules-cache) |
2186 |
|
(defvar math-eval-rules-cache-other) |
2187 |
;;; Reduce an object to canonical (normalized) form. [O o; Z Z] [Public] |
;;; Reduce an object to canonical (normalized) form. [O o; Z Z] [Public] |
2188 |
(defun math-normalize (a) |
(defun math-normalize (a) |
2189 |
(cond |
(cond |
2575 |
(defun math-sub-bignum (a b) ; [l l l] |
(defun math-sub-bignum (a b) ; [l l l] |
2576 |
(if b |
(if b |
2577 |
(if a |
(if a |
2578 |
(let* ((a (copy-sequence a)) (aa a) (borrow nil) sum) |
(let* ((a (copy-sequence a)) (aa a) (borrow nil) sum diff) |
2579 |
(while (and aa b) |
(while (and aa b) |
2580 |
(if borrow |
(if borrow |
2581 |
(if (>= (setq diff (- (car aa) (car b))) 1) |
(if (>= (setq diff (- (car aa) (car b))) 1) |
2897 |
|
|
2898 |
|
|
2899 |
|
|
2900 |
|
(defvar calc-selection-cache-entry) |
2901 |
;;; Format the number A as a string. [X N; X Z] [Public] |
;;; Format the number A as a string. [X N; X Z] [Public] |
2902 |
(defun math-format-stack-value (entry) |
(defun math-format-stack-value (entry) |
2903 |
(setq calc-selection-cache-entry calc-selection-cache-default-entry) |
(setq calc-selection-cache-entry calc-selection-cache-default-entry) |
2906 |
(c (cond ((null a) "<nil>") |
(c (cond ((null a) "<nil>") |
2907 |
((eq calc-display-raw t) (format "%s" a)) |
((eq calc-display-raw t) (format "%s" a)) |
2908 |
((stringp a) a) |
((stringp a) a) |
2909 |
((eq a 'top-of-stack) ".") |
((eq a 'top-of-stack) (propertize "." 'font-lock-face 'bold)) |
2910 |
(calc-prepared-composition |
(calc-prepared-composition |
2911 |
calc-prepared-composition) |
calc-prepared-composition) |
2912 |
((and (Math-scalarp a) |
((and (Math-scalarp a) |
2920 |
(and math-comp-selected (setq calc-any-selections t)) |
(and math-comp-selected (setq calc-any-selections t)) |
2921 |
(setq w (cdr off) |
(setq w (cdr off) |
2922 |
off (car off)) |
off (car off)) |
2923 |
(if (> off 0) |
(when (> off 0) |
2924 |
(setq c (math-comp-concat (make-string off ? ) c))) |
(setq c (math-comp-concat (make-string off ? ) c))) |
2925 |
(or (equal calc-left-label "") |
(or (equal calc-left-label "") |
2926 |
(setq c (math-comp-concat (if (eq a 'top-of-stack) |
(setq c (math-comp-concat (if (eq a 'top-of-stack) |
2927 |
(make-string (length calc-left-label) ? ) |
(make-string (length calc-left-label) ? ) |
2928 |
calc-left-label) |
calc-left-label) |
2929 |
c))) |
c))) |
2930 |
(if calc-line-numbering |
(when calc-line-numbering |
2931 |
(setq c (math-comp-concat (if (eq calc-language 'big) |
(setq c (math-comp-concat (if (eq calc-language 'big) |
2932 |
(if math-comp-selected |
(if math-comp-selected |
2933 |
'(tag t "1: ") "1: ") |
'(tag t "1: ") |
2934 |
" ") |
"1: ") |
2935 |
c))) |
" ") |
2936 |
(or (equal calc-right-label "") |
c))) |
2937 |
(eq a 'top-of-stack) |
(unless (or (equal calc-right-label "") |
2938 |
(progn |
(eq a 'top-of-stack)) |
2939 |
(calc-extensions) |
(calc-extensions) |
2940 |
(setq c (list 'horiz c |
(setq c (list 'horiz c |
2941 |
(make-string (max (- w (math-comp-width c) |
(make-string (max (- w (math-comp-width c) |
2942 |
(length calc-right-label)) 0) ? ) |
(length calc-right-label)) 0) ? ) |
2943 |
'(break -1) |
'(break -1) |
2944 |
calc-right-label)))) |
calc-right-label))) |
2945 |
(setq s (if (stringp c) |
(setq s (if (stringp c) |
2946 |
(if calc-display-raw |
(if calc-display-raw |
2947 |
(prin1-to-string c) |
(prin1-to-string c) |
2948 |
c) |
c) |
2949 |
(math-composition-to-string c w))) |
(math-composition-to-string c w))) |
2950 |
(if calc-language-output-filter |
(when calc-language-output-filter |
2951 |
(setq s (funcall calc-language-output-filter s))) |
(setq s (funcall calc-language-output-filter s))) |
2952 |
(if (eq calc-language 'big) |
(if (eq calc-language 'big) |
2953 |
(setq s (concat s "\n")) |
(setq s (concat s "\n")) |
2954 |
(if calc-line-numbering |
(when calc-line-numbering |
2955 |
(progn |
(aset s 0 ?1) |
2956 |
(aset s 0 ?1) |
(aset s 1 ?:))) |
|
(aset s 1 ?:)))) |
|
2957 |
(setcar (cdr entry) (calc-count-lines s)) |
(setcar (cdr entry) (calc-count-lines s)) |
2958 |
s)) |
s)) |
2959 |
|
|
2966 |
(calc-extensions) |
(calc-extensions) |
2967 |
(math-stack-value-offset-fancy)) |
(math-stack-value-offset-fancy)) |
2968 |
(setq off (or calc-display-origin 0)) |
(setq off (or calc-display-origin 0)) |
2969 |
(if (integerp calc-line-breaking) |
(when (integerp calc-line-breaking) |
2970 |
(setq wid calc-line-breaking))) |
(setq wid calc-line-breaking))) |
2971 |
(cons (max (- off (length calc-left-label)) 0) |
(cons (max (- off (length calc-left-label)) 0) |
2972 |
(+ wid num)))) |
(+ wid num)))) |
2973 |
|
|
2974 |
(defun calc-count-lines (s) |
(defun calc-count-lines (s) |
2975 |
(let ((pos 0) |
(let ((pos 0) |
2976 |
(num 1)) |
(num 1)) |
2977 |
(while (setq newpos (string-match "\n" s pos)) |
(while (setq pos (string-match "\n" s pos)) |
2978 |
(setq pos (1+ newpos) |
(setq pos (1+ pos) |
2979 |
num (1+ num))) |
num (1+ num))) |
2980 |
num)) |
num)) |
2981 |
|
|
3082 |
(when calc-group-digits |
(when calc-group-digits |
3083 |
(require 'calc-ext) |
(require 'calc-ext) |
3084 |
(setq str (math-group-float str)))) |
(setq str (math-group-float str)))) |
3085 |
(if (< figs 0) |
(when (< figs 0) |
3086 |
(setq figs (+ calc-internal-prec figs))) |
(setq figs (+ calc-internal-prec figs))) |
3087 |
(if (> figs 0) |
(when (> figs 0) |
3088 |
(let ((adj (- figs (math-numdigs mant)))) |
(let ((adj (- figs (math-numdigs mant)))) |
3089 |
(if (< adj 0) |
(when (< adj 0) |
3090 |
(setq mant (math-scale-rounding mant adj) |
(setq mant (math-scale-rounding mant adj) |
3091 |
exp (- exp adj))))) |
exp (- exp adj))))) |
3092 |
(setq str (if (integerp mant) |
(setq str (if (integerp mant) |
3093 |
(int-to-string mant) |
(int-to-string mant) |
3094 |
(math-format-bignum-decimal (cdr mant)))) |
(math-format-bignum-decimal (cdr mant)))) |
3328 |
(interactive "P") |
(interactive "P") |
3329 |
(calc-do-embedded-activate arg cbuf)) |
(calc-do-embedded-activate arg cbuf)) |
3330 |
|
|
|
|
|
3331 |
(defun calc-user-invocation () |
(defun calc-user-invocation () |
3332 |
(interactive) |
(interactive) |
3333 |
(or (stringp calc-invocation-macro) |
(unless (stringp calc-invocation-macro) |
3334 |
(error "Use `Z I' inside Calc to define a `M-# Z' keyboard macro")) |
(error "Use `Z I' inside Calc to define a `M-# Z' keyboard macro")) |
3335 |
(execute-kbd-macro calc-invocation-macro nil)) |
(execute-kbd-macro calc-invocation-macro nil)) |
3336 |
|
|
|
|
|
|
|
|
|
|
|
3337 |
;;; User-programmability. |
;;; User-programmability. |
3338 |
|
|
3339 |
;;;###autoload |
;;;###autoload |
3341 |
(calc-extensions) |
(calc-extensions) |
3342 |
(math-do-defmath func args body)) |
(math-do-defmath func args body)) |
3343 |
|
|
|
|
|
3344 |
;;; Functions needed for Lucid Emacs support. |
;;; Functions needed for Lucid Emacs support. |
3345 |
|
|
3346 |
(defun calc-read-key (&optional optkey) |
(defun calc-read-key (&optional optkey) |
3364 |
(push (or input last-command-event) unread-command-events))) |
(push (or input last-command-event) unread-command-events))) |
3365 |
|
|
3366 |
(defun calc-clear-unread-commands () |
(defun calc-clear-unread-commands () |
3367 |
(if (featurep 'xemacs) |
(if (featurep 'xemacs) |
3368 |
(calc-emacs-type-lucid (setq unread-command-event nil)) |
(calc-emacs-type-lucid (setq unread-command-event nil)) |
3369 |
(setq unread-command-events nil))) |
(setq unread-command-events nil))) |
3370 |
|
|
3371 |
(if calc-always-load-extensions |
(when calc-always-load-extensions |
3372 |
(progn |
(calc-extensions) |
3373 |
(calc-extensions) |
(calc-load-everything)) |
|
(calc-load-everything))) |
|
3374 |
|
|
3375 |
|
|
3376 |
(run-hooks 'calc-load-hook) |
(run-hooks 'calc-load-hook) |