1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-21 06:55:39 +00:00
emacs/lisp/calc/calc-store.el

679 lines
23 KiB
EmacsLisp
Raw Normal View History

* lisp/calc/: Use lexical scoping in all the files Includes the following pervasive changes: - Move some defvars earlier in the file so they cover earlier let-bindings - Change dynamically scoped `calc-FOO` or `math-FOO` function arguments to just FOO and then let-bind the `calc-FOO` or `math-FOO` variable explicitly in the body of the function. In some cases, the beginning of the function was changed to refer to FOO so as to delay the binding to a nearby `let` when I could ensure that it did not make a difference. - Add an underscore in front of unused vars or comment them out altogether. - Replace unused `err` arg to `condition-case` with nil. Plus the additional itemized changes below. * lisp/calc/calc-map.el (calcFunc-reducer): * lisp/calc/calc-arith.el (math-setup-declarations): * lisp/calc/calc-help.el (calc-full-help, calc-help-index-entries) (calc-full-help): Use `ignore-errors`. * lisp/calc/calc-embed.el (calc-embedded-modes-change): Declare `the-language` and `the-display-just` as dynamically scoped. * lisp/calc/calc-forms.el (math-setup-year-holidays): Use `dolist`. * lisp/calc/calc-graph.el (calc-graph-set-styles): Use `symbol-value` rather than `eval.` (calc-graph-delete-temps, calc-graph-set-styles): Use ignore-errors. * lisp/calc/calc-macs.el (calc-with-trail-buffer): Add artificial use of `save-buf` to silence compiler warnings in all the cases where `body` doesn't make use of it. * lisp/calc/calc-math.el (math-largest-emacs-expt) (math-smallest-emacs-expt, math-use-emacs-fn): Use ignore-errors. * lisp/calc/calc-mode.el (calc-total-algebraic-mode): Remove "P" from interactive spec since it's not used anyway. * lisp/calc/calc-rewr.el (calc-match): Simplify. * lisp/calc/calc.el (calc-buffer): Give it a global nil value, so it's automatically declared dynbound in any file that requires `calc`. (calcDigit-nondigit): Adjust accordingly. * lisp/calc/calcalg2.el (calcFunc-table): Declare `var-dummy` as dynbound. (math-scan-for-limits): Comment out dead code. * lisp/calc/calcalg3.el (math-general-fit): Declare `var-YVAL` and `var-YVALX` as dynbound.
2020-10-10 20:00:51 +00:00
;;; calc-store.el --- value storage functions for Calc -*- lexical-binding:t -*-
2024-01-02 01:47:10 +00:00
;; Copyright (C) 1990-1993, 2001-2024 Free Software Foundation, Inc.
;; Author: David Gillespie <daveg@synaptics.com>
2001-11-06 18:59:06 +00:00
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
2001-11-06 18:59:06 +00:00
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
2001-11-06 18:59:06 +00:00
;;; Commentary:
2001-11-06 18:59:06 +00:00
;;; Code:
2001-11-06 18:59:06 +00:00
;; This file is autoloaded from calc-ext.el.
(require 'calc-ext)
2001-11-06 18:59:06 +00:00
(require 'calc-macs)
;;; Memory commands.
(defvar calc-store-keep nil)
2001-11-06 18:59:06 +00:00
(defun calc-store (&optional var)
(interactive)
(let ((calc-store-keep t))
(calc-store-into var)))
2001-11-06 18:59:06 +00:00
(defvar calc-given-value-flag nil)
(defvar calc-given-value)
2001-11-06 18:59:06 +00:00
(defun calc-store-into (&optional var)
(interactive)
(calc-wrapper
(let ((calc-given-value nil)
(calc-given-value-flag 1))
(or var (setq var (calc-read-var-name "Store: " t)))
(if var
(let ((found (assq var '( ( + . calc-store-plus )
( - . calc-store-minus )
( * . calc-store-times )
( / . calc-store-div )
( ^ . calc-store-power )
( | . calc-store-concat ) ))))
(if found
(funcall (cdr found))
(let ((msg
(calc-store-value var (or calc-given-value (calc-top 1))
"" calc-given-value-flag)))
(message "Stored to variable \"%s\"%s"
(calc-var-name var) msg))))
2001-11-06 18:59:06 +00:00
(setq var (calc-is-assignments (calc-top 1)))
(if var
(while var
(let ((msg
(calc-store-value (car (car var)) (cdr (car var))
(if (not (cdr var)) "")
(if (not (cdr var)) 1))))
(message "Stored to variable \"%s\"%s"
(calc-var-name (car (car var))) msg))
(setq var (cdr var))))))))
2001-11-06 18:59:06 +00:00
(defun calc-store-plus (&optional var)
(interactive)
(calc-store-binary var "+" '+))
2001-11-06 18:59:06 +00:00
(defun calc-store-minus (&optional var)
(interactive)
(calc-store-binary var "-" '-))
2001-11-06 18:59:06 +00:00
(defun calc-store-times (&optional var)
(interactive)
(calc-store-binary var "*" '*))
2001-11-06 18:59:06 +00:00
(defun calc-store-div (&optional var)
(interactive)
(calc-store-binary var "/" '/))
2001-11-06 18:59:06 +00:00
(defun calc-store-power (&optional var)
(interactive)
(calc-store-binary var "^" '^))
2001-11-06 18:59:06 +00:00
(defun calc-store-concat (&optional var)
(interactive)
(calc-store-binary var "|" '|))
2001-11-06 18:59:06 +00:00
(defun calc-store-neg (n &optional var)
(interactive "p")
(calc-store-binary var "n" '/ (- n)))
2001-11-06 18:59:06 +00:00
(defun calc-store-inv (n &optional var)
(interactive "p")
(calc-store-binary var "&" '^ (- n)))
2001-11-06 18:59:06 +00:00
(defun calc-store-incr (n &optional var)
(interactive "p")
(calc-store-binary var "n" '- (- n)))
2001-11-06 18:59:06 +00:00
(defun calc-store-decr (n &optional var)
(interactive "p")
(calc-store-binary var "n" '- n))
2001-11-06 18:59:06 +00:00
(defun calc-store-value (var value tag &optional pop)
(let ((msg ""))
(if var
(let ((old (calc-var-value var)))
(set var value)
(if pop (or calc-store-keep (calc-pop-stack pop)))
(calc-record-undo (list 'store (symbol-name var) old))
(if tag
(let ((calc-full-trail-vectors nil))
(calc-record value (format ">%s%s" tag (calc-var-name var)))))
(cond
((and (memq var '(var-e var-i var-pi var-phi var-gamma))
(eq (car-safe old) 'special-const))
(setq msg (format " (Note: Built-in definition of %s has been lost)"
(calc-var-name var))))
((and (memq var '(var-inf var-uinf var-nan))
(null old))
(setq msg (format " (Note: %s has built-in meanings which may interfere)"
(calc-var-name var)))))
(calc-refresh-evaltos var)))
msg))
2001-11-06 18:59:06 +00:00
(defun calc-var-name (var)
(if (symbolp var) (setq var (symbol-name var)))
(if (string-match "\\`var-." var)
(substring var 4)
var))
2001-11-06 18:59:06 +00:00
(defun calc-store-binary (var tag func &optional val)
(calc-wrapper
(let ((calc-simplify-mode (if (eq calc-simplify-mode 'none)
'num calc-simplify-mode))
(value (or val (calc-top 1))))
(or var (setq var (calc-read-var-name (format "Store %s: " tag))))
(if var
(let ((old (calc-var-value var)))
(if (eq (car-safe old) 'special-const)
(error "\"%s\" is a special constant" (calc-var-name var)))
(if (not old)
(if (memq var '(var-inf var-uinf var-nan))
(error "\"%s\" is a special variable" (calc-var-name var))
(error "No such variable: \"%s\"" (calc-var-name var))))
2001-11-06 18:59:06 +00:00
(if (stringp old)
(setq old (math-read-expr old)))
(if (eq (car-safe old) 'error)
(error "Bad format in variable contents: %s" (nth 2 old)))
(calc-store-value var
(calc-normalize (if (calc-is-inverse)
(list func value old)
(list func old value)))
tag (and (not val) 1))
(message "Variable \"%s\" changed" (calc-var-name var)))))))
2001-11-06 18:59:06 +00:00
(defvar calc-var-name-map
(let ((map (copy-keymap minibuffer-local-completion-map)))
(define-key map " " #'self-insert-command)
(mapc (lambda (x)
(define-key map (char-to-string x)
#'calcVar-digit))
"0123456789")
(mapc (lambda (x)
(define-key map (char-to-string x)
#'calcVar-oper))
"+-*/^|")
map)
"Keymap for reading Calc variable names.")
(defvar calc-store-opers)
(defvar calc-read-var-name-history nil
"History for reading variable names.")
* lisp/calc/: Use lexical scoping in all the files Includes the following pervasive changes: - Move some defvars earlier in the file so they cover earlier let-bindings - Change dynamically scoped `calc-FOO` or `math-FOO` function arguments to just FOO and then let-bind the `calc-FOO` or `math-FOO` variable explicitly in the body of the function. In some cases, the beginning of the function was changed to refer to FOO so as to delay the binding to a nearby `let` when I could ensure that it did not make a difference. - Add an underscore in front of unused vars or comment them out altogether. - Replace unused `err` arg to `condition-case` with nil. Plus the additional itemized changes below. * lisp/calc/calc-map.el (calcFunc-reducer): * lisp/calc/calc-arith.el (math-setup-declarations): * lisp/calc/calc-help.el (calc-full-help, calc-help-index-entries) (calc-full-help): Use `ignore-errors`. * lisp/calc/calc-embed.el (calc-embedded-modes-change): Declare `the-language` and `the-display-just` as dynamically scoped. * lisp/calc/calc-forms.el (math-setup-year-holidays): Use `dolist`. * lisp/calc/calc-graph.el (calc-graph-set-styles): Use `symbol-value` rather than `eval.` (calc-graph-delete-temps, calc-graph-set-styles): Use ignore-errors. * lisp/calc/calc-macs.el (calc-with-trail-buffer): Add artificial use of `save-buf` to silence compiler warnings in all the cases where `body` doesn't make use of it. * lisp/calc/calc-math.el (math-largest-emacs-expt) (math-smallest-emacs-expt, math-use-emacs-fn): Use ignore-errors. * lisp/calc/calc-mode.el (calc-total-algebraic-mode): Remove "P" from interactive spec since it's not used anyway. * lisp/calc/calc-rewr.el (calc-match): Simplify. * lisp/calc/calc.el (calc-buffer): Give it a global nil value, so it's automatically declared dynbound in any file that requires `calc`. (calcDigit-nondigit): Adjust accordingly. * lisp/calc/calcalg2.el (calcFunc-table): Declare `var-dummy` as dynbound. (math-scan-for-limits): Comment out dead code. * lisp/calc/calcalg3.el (math-general-fit): Declare `var-YVAL` and `var-YVALX` as dynbound.
2020-10-10 20:00:51 +00:00
(defun calc-read-var-name (prompt &optional store-opers)
2001-11-06 18:59:06 +00:00
(setq calc-given-value nil
calc-aborted-prefix nil)
* lisp/calc/: Use lexical scoping in all the files Includes the following pervasive changes: - Move some defvars earlier in the file so they cover earlier let-bindings - Change dynamically scoped `calc-FOO` or `math-FOO` function arguments to just FOO and then let-bind the `calc-FOO` or `math-FOO` variable explicitly in the body of the function. In some cases, the beginning of the function was changed to refer to FOO so as to delay the binding to a nearby `let` when I could ensure that it did not make a difference. - Add an underscore in front of unused vars or comment them out altogether. - Replace unused `err` arg to `condition-case` with nil. Plus the additional itemized changes below. * lisp/calc/calc-map.el (calcFunc-reducer): * lisp/calc/calc-arith.el (math-setup-declarations): * lisp/calc/calc-help.el (calc-full-help, calc-help-index-entries) (calc-full-help): Use `ignore-errors`. * lisp/calc/calc-embed.el (calc-embedded-modes-change): Declare `the-language` and `the-display-just` as dynamically scoped. * lisp/calc/calc-forms.el (math-setup-year-holidays): Use `dolist`. * lisp/calc/calc-graph.el (calc-graph-set-styles): Use `symbol-value` rather than `eval.` (calc-graph-delete-temps, calc-graph-set-styles): Use ignore-errors. * lisp/calc/calc-macs.el (calc-with-trail-buffer): Add artificial use of `save-buf` to silence compiler warnings in all the cases where `body` doesn't make use of it. * lisp/calc/calc-math.el (math-largest-emacs-expt) (math-smallest-emacs-expt, math-use-emacs-fn): Use ignore-errors. * lisp/calc/calc-mode.el (calc-total-algebraic-mode): Remove "P" from interactive spec since it's not used anyway. * lisp/calc/calc-rewr.el (calc-match): Simplify. * lisp/calc/calc.el (calc-buffer): Give it a global nil value, so it's automatically declared dynbound in any file that requires `calc`. (calcDigit-nondigit): Adjust accordingly. * lisp/calc/calcalg2.el (calcFunc-table): Declare `var-dummy` as dynbound. (math-scan-for-limits): Comment out dead code. * lisp/calc/calcalg3.el (math-general-fit): Declare `var-YVAL` and `var-YVALX` as dynbound.
2020-10-10 20:00:51 +00:00
(let* ((calc-store-opers store-opers)
(var (concat
"var-"
(minibuffer-with-setup-hook
(lambda ()
(setq-local minibuffer-completion-table
(mapcar (lambda (x) (substring x 4))
(all-completions "var-" obarray)))
(setq-local minibuffer-completion-predicate
(lambda (x)
(boundp (intern (concat "var-" x)))))
(setq-local minibuffer-completion-confirm t))
(read-from-minibuffer
prompt nil calc-var-name-map nil
'calc-read-var-name-history)))))
2001-11-06 18:59:06 +00:00
(setq calc-aborted-prefix "")
(and (not (equal var "var-"))
(if (string-match "\\`\\([-a-zA-Zα-ωΑ-Ω0-9]+\\) *:?=" var)
2001-11-06 18:59:06 +00:00
(if (null calc-given-value-flag)
(error "Assignment is not allowed in this command")
(let ((svar (intern (substring var 0 (match-end 1)))))
(setq calc-given-value-flag 0
calc-given-value (math-read-expr
(substring var (match-end 0))))
(if (eq (car-safe calc-given-value) 'error)
(error "Bad format: %s" (nth 2 calc-given-value)))
(setq calc-given-value (math-evaluate-expr calc-given-value))
svar))
(intern var)))))
2001-11-06 18:59:06 +00:00
(defun calcVar-digit ()
(interactive)
(if (calc-minibuffer-contains "\\'")
2001-11-06 18:59:06 +00:00
(if (eq calc-store-opers 0)
(beep)
(insert "q")
(self-insert-and-exit))
(self-insert-command 1)))
2001-11-06 18:59:06 +00:00
(defun calcVar-oper ()
(interactive)
(if (and (eq calc-store-opers t)
(calc-minibuffer-contains "\\'"))
2001-11-06 18:59:06 +00:00
(progn
(erase-buffer)
(self-insert-and-exit))
(self-insert-command 1)))
2001-11-06 18:59:06 +00:00
(defun calc-store-map (&optional oper var)
(interactive)
(calc-wrapper
(let* ((calc-dollar-values (mapcar #'calc-get-stack-element
2001-11-06 18:59:06 +00:00
(nthcdr calc-stack-top calc-stack)))
(calc-dollar-used 0)
(oper (or oper (calc-get-operator "Store Mapping")))
(nargs (car oper)))
(or var (setq var (calc-read-var-name (format "Store Mapping %s: "
(nth 2 oper)))))
(if var
(let ((old (calc-var-value var)))
(if (eq (car-safe old) 'special-const)
(error "\"%s\" is a special constant" (calc-var-name var)))
(if (not old)
(if (memq var '(var-inf var-uinf var-nan))
(error "\"%s\" is a special variable" (calc-var-name var))
(error "No such variable: \"%s\"" (calc-var-name var))))
(let ((calc-simplify-mode (if (eq calc-simplify-mode 'none)
'num calc-simplify-mode))
(values (and (> nargs 1)
(calc-top-list (1- nargs) (1+ calc-dollar-used)))))
(message "Working...")
(calc-set-command-flag 'clear-message)
(if (stringp old)
(setq old (math-read-expr old)))
(if (eq (car-safe old) 'error)
(error "Bad format in variable contents: %s" (nth 2 old)))
(setq values (if (calc-is-inverse)
(append values (list old))
(append (list old) values)))
(calc-store-value var
(calc-normalize (cons (nth 1 oper) values))
(nth 2 oper)
(+ calc-dollar-used (1- nargs)))
(message "Variable \"%s\" changed" (calc-var-name var))))))))
2001-11-06 18:59:06 +00:00
(defun calc-store-exchange (&optional var)
(interactive)
(calc-wrapper
(let ((calc-given-value nil)
(calc-given-value-flag 1)
top)
(or var (setq var (calc-read-var-name "Exchange with: ")))
(if var
(let ((value (calc-var-value var)))
(if (eq (car-safe value) 'special-const)
(error "\"%s\" is a special constant" (calc-var-name var)))
(if (not value)
(if (memq var '(var-inf var-uinf var-nan))
(error "\"%s\" is a special variable" (calc-var-name var))
(error "No such variable: \"%s\"" (calc-var-name var))))
2001-11-06 18:59:06 +00:00
(setq top (or calc-given-value (calc-top 1)))
(calc-store-value var top nil)
(calc-pop-push-record calc-given-value-flag
(concat "<>" (calc-var-name var)) value))))))
2001-11-06 18:59:06 +00:00
(defun calc-unstore (&optional var)
(interactive)
(calc-wrapper
(or var (setq var (calc-read-var-name "Unstore: ")))
(if var
(progn
(and (memq var '(var-e var-i var-pi var-phi var-gamma))
(eq (car-safe (calc-var-value var)) 'special-const)
(message "(Note: Built-in definition of %s has been lost)" var))
(if (and (boundp var) (symbol-value var))
(message "Unstored variable \"%s\"" (calc-var-name var))
(message "Variable \"%s\" remains unstored" (calc-var-name var)))
(makunbound var)
(calc-refresh-evaltos var)))))
2001-11-06 18:59:06 +00:00
(defun calc-let (&optional var)
(interactive)
(calc-wrapper
(let* ((calc-given-value nil)
(calc-given-value-flag 1)
thing value)
(or var (setq var (calc-read-var-name "Let variable: ")))
(if calc-given-value
(setq value calc-given-value
thing (calc-top 1))
(setq value (calc-top 1)
thing (calc-top 2)))
(setq var (if var
(list (cons var value))
(calc-is-assignments value)))
(if var
(calc-pop-push-record
(1+ calc-given-value-flag)
(concat "=" (calc-var-name (car (car var))))
Don't quote lambdas with 'function' in calc/*.el * lisp/calc/calc-aent.el (calc-do-quick-calc) (calc-do-calc-eval, math-build-parse-table): * lisp/calc/calc-alg.el (math-polynomial-base): * lisp/calc/calc-alg.el (math-is-poly-rec): * lisp/calc/calc-arith.el (calcFunc-scf): * lisp/calc/calc-arith.el (math-ceiling, math-round): * lisp/calc/calc-arith.el (math-trunc-fancy, math-floor-fancy): * lisp/calc/calc-ext.el (calc-init-extensions, calc-reset) (calc-refresh-top, calc-z-prefix-help, calc-binary-op-fancy) (calc-unary-op-fancy): * lisp/calc/calc-forms.el (math-make-mod): * lisp/calc/calc-frac.el (calcFunc-frac): * lisp/calc/calc-funcs.el (calcFunc-euler): * lisp/calc/calc-help.el (calc-full-help): * lisp/calc/calc-lang.el (c, pascal, fortran, tex, latex, eqn) (yacas, maxima, giac, math, maple): * lisp/calc/calc-macs.el (calc-wrapper, calc-slow-wrapper): * lisp/calc/calc-map.el (calc-get-operator, calcFunc-mapeqr) (calcFunc-reducea, calcFunc-rreducea, calcFunc-reduced) (calcFunc-rreduced, calcFunc-outer): * lisp/calc/calc-misc.el (another-calc, calc-do-handle-whys): * lisp/calc/calc-mode.el (calc-save-modes): * lisp/calc/calc-mtx.el (math-col-matrix, math-mul-mat-vec): * lisp/calc/calc-poly.el (math-sort-terms, math-poly-div-list) (math-mul-list, math-sort-poly-base-list) (math-partial-fractions): * lisp/calc/calc-prog.el (calc-user-define-formula): * lisp/calc/calc-rewr.el (math-rewrite, math-compile-patterns) (math-compile-rewrites, math-parse-schedule) (math-rwcomp-pattern): * lisp/calc/calc-store.el (calc-var-name-map, calc-let) (calc-permanent-variable, calc-insert-variables): * lisp/calc/calc-stuff.el (calc-flush-caches, calcFunc-pclean) (calcFunc-pfrac): * lisp/calc/calc-units.el (math-build-units-table) (math-decompose-units): * lisp/calc/calc-vec.el (calcFunc-mrow, math-mat-col) (calcFunc-mcol, math-mat-less-col, math-mimic-ident): * lisp/calc/calc-yank.el (calc-edit): * lisp/calc/calc.el (calc-mode-var-list-restore-default-values) (calc-mode-var-list-restore-saved-values, calc-mode, calc-quit): * lisp/calc/calccomp.el (math-compose-expr) (math-compose-matrix, math-vector-to-string): Don't quote lambdas with 'function'.
2020-11-17 01:51:30 +00:00
(let ((saved-val (mapcar (lambda (v)
(and (boundp (car v))
(symbol-value (car v))))
2001-11-06 18:59:06 +00:00
var)))
(unwind-protect
(let ((vv var))
(while vv
(set (car (car vv)) (calc-normalize (cdr (car vv))))
(calc-refresh-evaltos (car (car vv)))
(setq vv (cdr vv)))
(math-evaluate-expr thing))
(while saved-val
(if (car saved-val)
(set (car (car var)) (car saved-val))
(makunbound (car (car var))))
(setq saved-val (cdr saved-val)
var (cdr var)))
(calc-handle-whys))))))))
2001-11-06 18:59:06 +00:00
(defun calc-is-assignments (value)
(if (memq (car-safe value) '(calcFunc-eq calcFunc-assign))
(and (eq (car-safe (nth 1 value)) 'var)
(list (cons (nth 2 (nth 1 value)) (nth 2 value))))
(if (eq (car-safe value) 'vec)
(let ((vv nil))
(while (and (setq value (cdr value))
(memq (car-safe (car value))
'(calcFunc-eq calcFunc-assign))
(eq (car-safe (nth 1 (car value))) 'var))
(setq vv (cons (cons (nth 2 (nth 1 (car value)))
(nth 2 (car value)))
vv)))
(and (not value)
vv)))))
2001-11-06 18:59:06 +00:00
(defun calc-recall (&optional var)
(interactive)
(calc-wrapper
(or var (setq var (calc-read-var-name "Recall: ")))
(if var
(let ((value (calc-var-value var)))
(or value
(error "No such variable: \"%s\"" (calc-var-name var)))
(if (stringp value)
(setq value (math-read-expr value)))
(if (eq (car-safe value) 'error)
(error "Bad format in variable contents: %s" (nth 2 value)))
(setq value (calc-normalize value))
(let ((calc-full-trail-vectors nil))
(calc-record value (concat "<" (calc-var-name var))))
(calc-push value)))))
2001-11-06 18:59:06 +00:00
(defun calc-store-quick ()
(interactive)
(calc-store (intern (format "var-q%c" last-command-event))))
2001-11-06 18:59:06 +00:00
(defun calc-store-into-quick ()
(interactive)
(calc-store-into (intern (format "var-q%c" last-command-event))))
2001-11-06 18:59:06 +00:00
(defun calc-recall-quick ()
(interactive)
(calc-recall (intern (format "var-q%c" last-command-event))))
2001-11-06 18:59:06 +00:00
(defun calc-copy-special-constant (&optional sconst var)
(interactive)
(let ((sc '(("")
("e" . (special-const (math-e)))
("pi" . (special-const (math-pi)))
("i" . (special-const (math-imaginary 1)))
("phi" . (special-const (math-phi)))
("gamma" . (special-const (math-gamma-const))))))
(calc-wrapper
(or sconst (setq sconst (completing-read "Special constant: " sc nil t)))
(unless (string= sconst "")
(let ((value (cdr (assoc sconst sc))))
(or var (setq var (calc-read-var-name
(format "Copy special constant %s, to: "
sconst))))
(if var
(let ((msg (calc-store-value var value "")))
(message "Special constant \"%s\" copied to \"%s\"%s"
sconst (calc-var-name var) msg))))))))
2001-11-06 18:59:06 +00:00
(defun calc-copy-variable (&optional var1 var2)
(interactive)
(calc-wrapper
(or var1 (setq var1 (calc-read-var-name "Copy variable: ")))
(if var1
(let ((value (calc-var-value var1)))
(or value
(error "No such variable: \"%s\"" (calc-var-name var1)))
2001-11-06 18:59:06 +00:00
(or var2 (setq var2 (calc-read-var-name
(format "Copy variable: %s, to: "
(calc-var-name var1)))))
2001-11-06 18:59:06 +00:00
(if var2
(let ((msg (calc-store-value var2 value "")))
(message "Variable \"%s\" copied to \"%s\"%s"
(calc-var-name var1) (calc-var-name var2) msg)))))))
2001-11-06 18:59:06 +00:00
(defvar calc-last-edited-variable nil)
2001-11-06 18:59:06 +00:00
(defun calc-edit-variable (&optional var)
(interactive)
(calc-wrapper
Use `format-prompt' when prompting with default values * lisp/woman.el (woman-file-name): * lisp/wid-edit.el (widget-file-prompt-value) (widget-coding-system-prompt-value): * lisp/w32-fns.el (w32-set-system-coding-system): * lisp/vc/vc.el (vc-print-root-log): * lisp/vc/vc-annotate.el (vc-annotate): * lisp/vc/emerge.el (emerge-read-file-name): * lisp/vc/ediff.el (ediff-directories) (ediff-directory-revisions, ediff-directories3) (ediff-merge-directories, ) (ediff-merge-directories-with-ancestor) (ediff-merge-directory-revisions) (ediff-merge-directory-revisions-with-ancestor) (ediff-merge-revisions, ediff-merge-revisions-with-ancestor) (ediff-revision): * lisp/vc/ediff-util.el (ediff-toggle-regexp-match): * lisp/vc/ediff-mult.el (ediff-filegroup-action): * lisp/vc/add-log.el (prompt-for-change-log-name): * lisp/textmodes/table.el (table-insert-row-column) (table-span-cell, table-split-cell-horizontally) (table-split-cell, table-justify, table-generate-source) (table-insert-sequence, table-capture) (table--read-from-minibuffer, table--query-justification): * lisp/textmodes/sgml-mode.el (sgml-tag, sgml-tag-help): * lisp/textmodes/reftex-ref.el (reftex-goto-label): * lisp/textmodes/refer.el (refer-get-bib-files): * lisp/textmodes/css-mode.el (css-lookup-symbol): * lisp/term.el (serial-read-name, serial-read-speed): * lisp/speedbar.el (speedbar-change-initial-expansion-list): * lisp/simple.el (previous-matching-history-element) (set-variable): * lisp/ses.el (ses-read-cell, ses-set-column-width): * lisp/replace.el (query-replace-read-from) (occur-read-primary-args): * lisp/rect.el (string-rectangle, string-insert-rectangle): * lisp/progmodes/tcl.el (tcl-help-on-word): * lisp/progmodes/sh-script.el (sh-set-shell): * lisp/progmodes/python.el (python-eldoc-at-point): * lisp/progmodes/octave.el (octave-completing-read) (octave-update-function-file-comment, octave-insert-defun): * lisp/progmodes/inf-lisp.el (lisp-symprompt): * lisp/progmodes/cperl-mode.el (cperl-info-on-command) (cperl-perldoc): * lisp/progmodes/compile.el (compilation-find-file): * lisp/net/rcirc.el (rcirc-prompt-for-encryption): * lisp/net/eww.el (eww): * lisp/net/browse-url.el (browse-url-with-browser-kind): * lisp/man.el (man): * lisp/mail/sendmail.el (sendmail-query-user-about-smtp): * lisp/mail/mailalias.el (build-mail-aliases): * lisp/mail/mailabbrev.el (merge-mail-abbrevs) (rebuild-mail-abbrevs): * lisp/locate.el (locate-prompt-for-search-string): * lisp/isearch.el (isearch-occur): * lisp/international/ogonek.el (ogonek-read-encoding) (ogonek-read-prefix): * lisp/international/mule.el (read-buffer-file-coding-system) (set-terminal-coding-system, set-keyboard-coding-system) (set-next-selection-coding-system, recode-region): * lisp/international/mule-cmds.el () (universal-coding-system-argument, search-unencodable-char) (select-safe-coding-system-interactively): * lisp/info.el (Info-search, Info-search-backward, Info-menu): * lisp/info-look.el (info-lookup-interactive-arguments): * lisp/imenu.el (imenu--completion-buffer): * lisp/ibuf-ext.el (mode, used-mode, ibuffer-mark-by-mode): * lisp/hi-lock.el (hi-lock-unface-buffer) (hi-lock-read-face-name): * lisp/help.el (view-emacs-news, where-is): * lisp/help-fns.el (describe-variable, describe-symbol) (describe-keymap): * lisp/gnus/mm-decode.el (mm-save-part): * lisp/gnus/gnus-sum.el (gnus-summary-browse-url): * lisp/gnus/gnus-group.el (gnus-group--read-bug-ids) (gnus-group-set-current-level): * lisp/frame.el (make-frame-on-monitor) (close-display-connection, select-frame-by-name): * lisp/format.el (format-encode-buffer, format-encode-region): * lisp/files.el (recode-file-name): * lisp/files-x.el (read-file-local-variable) (read-file-local-variable-value, ) (read-file-local-variable-mode): * lisp/ffap.el (ffap-menu-ask): * lisp/faces.el (face-read-string): * lisp/facemenu.el (facemenu-set-charset): * lisp/erc/erc-dcc.el (erc-dcc-do-GET-command): * lisp/emulation/edt-mapper.el (edt-mapper): * lisp/emacs-lisp/trace.el (trace--read-args) (trace-function-foreground, trace-function-background): * lisp/emacs-lisp/smie.el (smie-config-set-indent): * lisp/emacs-lisp/re-builder.el (reb-change-syntax): * lisp/emacs-lisp/package.el (describe-package): * lisp/emacs-lisp/find-func.el (read-library-name) (find-function-read): * lisp/emacs-lisp/ert.el (ert-read-test-name) (ert-run-tests-interactively): * lisp/emacs-lisp/disass.el (disassemble): * lisp/emacs-lisp/debug.el (debug-on-entry) (debug-on-variable-change): * lisp/emacs-lisp/advice.el (ad-read-advised-function) (ad-read-advice-class, ad-read-advice-name, ad-read-regexp): * lisp/dired-x.el (dired--mark-suffix-interactive-spec): * lisp/dired-aux.el (dired-diff): * lisp/cus-edit.el (custom-variable-prompt, customize-mode) (customize-changed-options): * lisp/completion.el (interactive-completion-string-reader): * lisp/calendar/timeclock.el (timeclock-ask-for-project): * lisp/calc/calcalg3.el (calc-get-fit-variables): * lisp/calc/calc-store.el (calc-edit-variable): * lisp/calc/calc-bin.el (calc-word-size): * lisp/bookmark.el (bookmark-set-internal): * lisp/abbrev.el (read-abbrev-file): Use `format-prompt' for prompting (bug#12443).
2020-09-06 14:56:44 +00:00
(unless var
(setq var (calc-read-var-name
(format-prompt "Edit" (and calc-last-edited-variable
(calc-var-name
calc-last-edited-variable))))))
2001-11-06 18:59:06 +00:00
(or var (setq var calc-last-edited-variable))
(if var
(let* ((value (calc-var-value var)))
(if (eq (car-safe value) 'special-const)
(error "%s is a special constant" var))
(setq calc-last-edited-variable var)
(calc--edit-mode (lambda () (calc-finish-stack-edit var))
t
(format-message
"Editing variable `%s'" (calc-var-name var)))
2001-11-06 18:59:06 +00:00
(and value
(insert (math-format-nice-expr value (frame-width)) "\n")))))
(calc-show-edit-buffer))
2001-11-06 18:59:06 +00:00
(defun calc-edit-Decls ()
(interactive)
(calc-edit-variable 'var-Decls))
2001-11-06 18:59:06 +00:00
(defun calc-edit-EvalRules ()
(interactive)
(calc-edit-variable 'var-EvalRules))
2001-11-06 18:59:06 +00:00
(defun calc-edit-FitRules ()
(interactive)
(calc-edit-variable 'var-FitRules))
2001-11-06 18:59:06 +00:00
(defun calc-edit-GenCount ()
(interactive)
(calc-edit-variable 'var-GenCount))
2001-11-06 18:59:06 +00:00
(defun calc-edit-Holidays ()
(interactive)
(calc-edit-variable 'var-Holidays))
2001-11-06 18:59:06 +00:00
(defun calc-edit-IntegLimit ()
(interactive)
(calc-edit-variable 'var-IntegLimit))
2001-11-06 18:59:06 +00:00
(defun calc-edit-LineStyles ()
(interactive)
(calc-edit-variable 'var-LineStyles))
2001-11-06 18:59:06 +00:00
(defun calc-edit-PointStyles ()
(interactive)
(calc-edit-variable 'var-PointStyles))
2001-11-06 18:59:06 +00:00
(defun calc-edit-PlotRejects ()
(interactive)
(calc-edit-variable 'var-PlotRejects))
2001-11-06 18:59:06 +00:00
(defun calc-edit-AlgSimpRules ()
(interactive)
(calc-edit-variable 'var-AlgSimpRules))
2001-11-06 18:59:06 +00:00
(defun calc-edit-TimeZone ()
(interactive)
(calc-edit-variable 'var-TimeZone))
2001-11-06 18:59:06 +00:00
(defun calc-edit-Units ()
(interactive)
(calc-edit-variable 'var-Units))
2001-11-06 18:59:06 +00:00
(defun calc-edit-ExtSimpRules ()
(interactive)
(calc-edit-variable 'var-ExtSimpRules))
2001-11-06 18:59:06 +00:00
(defun calc-declare-variable (&optional var)
(interactive)
(calc-wrapper
(or var (setq var (calc-read-var-name "Declare: " 0)))
(or var (setq var 'var-All))
* lisp/calc/: Use lexical scoping in all the files Includes the following pervasive changes: - Move some defvars earlier in the file so they cover earlier let-bindings - Change dynamically scoped `calc-FOO` or `math-FOO` function arguments to just FOO and then let-bind the `calc-FOO` or `math-FOO` variable explicitly in the body of the function. In some cases, the beginning of the function was changed to refer to FOO so as to delay the binding to a nearby `let` when I could ensure that it did not make a difference. - Add an underscore in front of unused vars or comment them out altogether. - Replace unused `err` arg to `condition-case` with nil. Plus the additional itemized changes below. * lisp/calc/calc-map.el (calcFunc-reducer): * lisp/calc/calc-arith.el (math-setup-declarations): * lisp/calc/calc-help.el (calc-full-help, calc-help-index-entries) (calc-full-help): Use `ignore-errors`. * lisp/calc/calc-embed.el (calc-embedded-modes-change): Declare `the-language` and `the-display-just` as dynamically scoped. * lisp/calc/calc-forms.el (math-setup-year-holidays): Use `dolist`. * lisp/calc/calc-graph.el (calc-graph-set-styles): Use `symbol-value` rather than `eval.` (calc-graph-delete-temps, calc-graph-set-styles): Use ignore-errors. * lisp/calc/calc-macs.el (calc-with-trail-buffer): Add artificial use of `save-buf` to silence compiler warnings in all the cases where `body` doesn't make use of it. * lisp/calc/calc-math.el (math-largest-emacs-expt) (math-smallest-emacs-expt, math-use-emacs-fn): Use ignore-errors. * lisp/calc/calc-mode.el (calc-total-algebraic-mode): Remove "P" from interactive spec since it's not used anyway. * lisp/calc/calc-rewr.el (calc-match): Simplify. * lisp/calc/calc.el (calc-buffer): Give it a global nil value, so it's automatically declared dynbound in any file that requires `calc`. (calcDigit-nondigit): Adjust accordingly. * lisp/calc/calcalg2.el (calcFunc-table): Declare `var-dummy` as dynbound. (math-scan-for-limits): Comment out dead code. * lisp/calc/calcalg3.el (math-general-fit): Declare `var-YVAL` and `var-YVALX` as dynbound.
2020-10-10 20:00:51 +00:00
(let* (dp decl row rp) ;; def
2001-11-06 18:59:06 +00:00
(or (and (calc-var-value 'var-Decls)
(eq (car-safe var-Decls) 'vec))
(setq var-Decls (list 'vec)))
(setq dp var-Decls)
(while (and (setq dp (cdr dp))
(or (not (eq (car-safe (car dp)) 'vec))
(/= (length (car dp)) 3)
(progn
(setq row (nth 1 (car dp))
rp row)
(if (eq (car-safe row) 'vec)
(progn
(while
(and (setq rp (cdr rp))
(or (not (eq (car-safe (car rp)) 'var))
(not (eq (nth 2 (car rp)) var)))))
(setq rp (car rp)))
(if (or (not (eq (car-safe row) 'var))
(not (eq (nth 2 row) var)))
(setq rp nil)))
(not rp)))))
(calc-unread-command ?\C-a)
(setq decl (read-string (format "Declare: %s to be: " (calc-var-name var))
2001-11-06 18:59:06 +00:00
(and rp
(math-format-flat-expr (nth 2 (car dp)) 0))))
(setq decl (and (string-match "[^ \t]" decl)
(math-read-exprs decl)))
(if (eq (car-safe decl) 'error)
(error "Bad format in declaration: %s" (nth 2 decl)))
(if (cdr decl)
(setq decl (cons 'vec decl))
(setq decl (car decl)))
(and (eq (car-safe decl) 'vec)
(= (length decl) 2)
(setq decl (nth 1 decl)))
(calc-record (append '(vec) (list (math-build-var-name var))
(and decl (list decl)))
"decl")
(setq var-Decls (copy-sequence var-Decls))
(if (eq (car-safe row) 'vec)
(progn
(setcdr row (delq rp (cdr row)))
(or (cdr row)
(setq var-Decls (delq (car dp) var-Decls))))
(setq var-Decls (delq (car dp) var-Decls)))
(if decl
(progn
(setq dp (and (not (eq var 'var-All)) var-Decls))
(while (and (setq dp (cdr dp))
(or (not (eq (car-safe (car dp)) 'vec))
(/= (length (car dp)) 3)
(not (equal (nth 2 (car dp)) decl)))))
(if dp
(setcar (cdr (car dp))
(append (if (eq (car-safe (nth 1 (car dp))) 'vec)
(nth 1 (car dp))
(list 'vec (nth 1 (car dp))))
(list (math-build-var-name var))))
(setq var-Decls (append var-Decls
(list (list 'vec
(math-build-var-name var)
decl)))))))
(calc-refresh-evaltos 'var-Decls))))
2001-11-06 18:59:06 +00:00
(defvar calc-dont-insert-variables '(var-FitRules var-FactorRules
var-CommuteRules var-JumpRules
var-DistribRules var-MergeRules
var-NegateRules var-InvertRules
var-IntegAfterRules
var-TimeZone var-PlotRejects
var-PlotData1 var-PlotData2
var-PlotData3 var-PlotData4
var-PlotData5 var-PlotData6
var-DUMMY))
;; The variable calc-pv-pos is local to calc-permanent-variable, but
;; used by calc-insert-permanent-variable, which is called by
;; calc-permanent-variable.
(defvar calc-pv-pos)
2001-11-06 18:59:06 +00:00
(defun calc-permanent-variable (&optional var)
(interactive)
(calc-wrapper
Use format-prompt for many more prompts * lisp/bookmark.el (bookmark-completing-read): * lisp/calc/calc-prog.el (calc-user-define-formula): * lisp/calc/calc-store.el (calc-permanent-variable): * lisp/calc/calc-units.el (calc-convert-units) (calc-convert-exact-units, calc-convert-temperature): * lisp/cedet/semantic/complete.el (semantic-complete-read-tag-engine): * lisp/cus-edit.el (customize-read-group): * lisp/dired-aux.el (dired-do-chxxx): * lisp/dired-x.el (dired-mark-unmarked-files): * lisp/emacs-lisp/debug.el (cancel-debug-on-entry) (cancel-debug-on-variable-change): * lisp/emacs-lisp/edebug.el (edebug-cancel-on-entry) (edebug-remove-instrumentation): * lisp/epa.el (epa-read-file-name, epa-export-keys): * lisp/faces.el (read-face-name): * lisp/format.el (format-decode-buffer, format-decode-region): * lisp/gnus/gnus-art.el (gnus-read-save-file-name): * lisp/gnus/gnus-util.el (gnus-completing-read): * lisp/gnus/message.el (message-check-news-header-syntax): * lisp/info.el (Info-follow-reference): * lisp/international/mule-diag.el (describe-font) (describe-fontset): * lisp/international/quail.el (quail-show-keyboard-layout): * lisp/language/cyril-util.el (standard-display-cyrillic-translit): * lisp/mail/rmailkwd.el (rmail-read-label): * lisp/mail/rmailmm.el (rmail-mime-save): * lisp/mail/rmailout.el (rmail-output-read-file-name): * lisp/man.el (Man-goto-section, Man-follow-manual-reference): * lisp/menu-bar.el (emacs-index--prompt): * lisp/net/ange-ftp.el (ange-ftp-get-passwd): * lisp/proced.el (proced-send-signal): * lisp/progmodes/cpp.el (cpp-choose-face): * lisp/progmodes/ebrowse.el (ebrowse-set-tree-indentation): * lisp/progmodes/etags.el (visit-tags-table) (visit-tags-table-buffer): * lisp/progmodes/grep.el (grep-read-files): * lisp/progmodes/hideif.el (hide-ifdef-define): * lisp/progmodes/pascal.el (pascal-goto-defun): * lisp/progmodes/prolog.el (prolog-read-predicate): * lisp/progmodes/sql.el (sql-get-login-ext): * lisp/ses.el (ses-define-local-printer): * lisp/textmodes/artist.el (artist-figlet-choose-font): * lisp/textmodes/tex-mode.el (tex-compile): * lisp/vc/diff.el (diff): * lisp/vc/ediff-ptch.el (ediff-prompt-for-patch-file): * lisp/vc/ediff-util.el (ediff-read-file-name): * lisp/vc/pcvs.el (cvs-mode-mark-on-state): * lisp/vc/vc.el (vc-diff-build-argument-list-internal) (vc-revision-other-window, vc-retrieve-tag): * lisp/wid-edit.el: Prefer format-prompt unconditionally. * lisp/org/org-capture.el (org-capture-fill-template): * lisp/org/org-refile.el (org-refile-get-location): * lisp/progmodes/python.el (python-eldoc-at-point): * lisp/progmodes/verilog-mode.el (verilog-surelint-off) (verilog-goto-defun): * lisp/progmodes/xref.el (xref--read-identifier): Prefer format-prompt when it is fboundp.
2021-10-05 01:34:08 +00:00
(or var (setq var (calc-read-var-name (format-prompt "Save variable" "all"))))
(let (calc-pv-pos)
2001-11-06 18:59:06 +00:00
(and var (or (and (boundp var) (symbol-value var))
(error "No such variable")))
(set-buffer (find-file-noselect (substitute-in-file-name
calc-settings-file)))
(if var
(calc-insert-permanent-variable var)
Don't quote lambdas with 'function' in calc/*.el * lisp/calc/calc-aent.el (calc-do-quick-calc) (calc-do-calc-eval, math-build-parse-table): * lisp/calc/calc-alg.el (math-polynomial-base): * lisp/calc/calc-alg.el (math-is-poly-rec): * lisp/calc/calc-arith.el (calcFunc-scf): * lisp/calc/calc-arith.el (math-ceiling, math-round): * lisp/calc/calc-arith.el (math-trunc-fancy, math-floor-fancy): * lisp/calc/calc-ext.el (calc-init-extensions, calc-reset) (calc-refresh-top, calc-z-prefix-help, calc-binary-op-fancy) (calc-unary-op-fancy): * lisp/calc/calc-forms.el (math-make-mod): * lisp/calc/calc-frac.el (calcFunc-frac): * lisp/calc/calc-funcs.el (calcFunc-euler): * lisp/calc/calc-help.el (calc-full-help): * lisp/calc/calc-lang.el (c, pascal, fortran, tex, latex, eqn) (yacas, maxima, giac, math, maple): * lisp/calc/calc-macs.el (calc-wrapper, calc-slow-wrapper): * lisp/calc/calc-map.el (calc-get-operator, calcFunc-mapeqr) (calcFunc-reducea, calcFunc-rreducea, calcFunc-reduced) (calcFunc-rreduced, calcFunc-outer): * lisp/calc/calc-misc.el (another-calc, calc-do-handle-whys): * lisp/calc/calc-mode.el (calc-save-modes): * lisp/calc/calc-mtx.el (math-col-matrix, math-mul-mat-vec): * lisp/calc/calc-poly.el (math-sort-terms, math-poly-div-list) (math-mul-list, math-sort-poly-base-list) (math-partial-fractions): * lisp/calc/calc-prog.el (calc-user-define-formula): * lisp/calc/calc-rewr.el (math-rewrite, math-compile-patterns) (math-compile-rewrites, math-parse-schedule) (math-rwcomp-pattern): * lisp/calc/calc-store.el (calc-var-name-map, calc-let) (calc-permanent-variable, calc-insert-variables): * lisp/calc/calc-stuff.el (calc-flush-caches, calcFunc-pclean) (calcFunc-pfrac): * lisp/calc/calc-units.el (math-build-units-table) (math-decompose-units): * lisp/calc/calc-vec.el (calcFunc-mrow, math-mat-col) (calcFunc-mcol, math-mat-less-col, math-mimic-ident): * lisp/calc/calc-yank.el (calc-edit): * lisp/calc/calc.el (calc-mode-var-list-restore-default-values) (calc-mode-var-list-restore-saved-values, calc-mode, calc-quit): * lisp/calc/calccomp.el (math-compose-expr) (math-compose-matrix, math-vector-to-string): Don't quote lambdas with 'function'.
2020-11-17 01:51:30 +00:00
(mapatoms (lambda (x)
(and (string-match "\\`var-" (symbol-name x))
(not (memq x calc-dont-insert-variables))
(calc-var-value x)
(not (eq (car-safe (symbol-value x)) 'special-const))
(calc-insert-permanent-variable x)))))
(save-buffer))))
2001-11-06 18:59:06 +00:00
(defun calc-insert-permanent-variable (var)
(goto-char (point-min))
(if (let (case-fold-search)
(search-forward (concat "(setq " (symbol-name var) " '") nil t))
2001-11-06 18:59:06 +00:00
(progn
(setq calc-pv-pos (point-marker))
2001-11-06 18:59:06 +00:00
(forward-line -1)
(if (looking-at ";;; Variable .* stored by Calc on ")
(progn
(delete-region (match-end 0) (progn (end-of-line) (point)))
(insert (current-time-string))))
(goto-char (- calc-pv-pos 8 (length (symbol-name var))))
2001-11-06 18:59:06 +00:00
(forward-sexp 1)
(backward-char 1)
(delete-region calc-pv-pos (point)))
2001-11-06 18:59:06 +00:00
(goto-char (point-max))
(insert "\n;;; Variable \""
(symbol-name var)
"\" stored by Calc on "
(current-time-string)
"\n(setq "
(symbol-name var)
" ')\n")
(backward-char 2))
(insert (prin1-to-string (calc-var-value var)))
(forward-line 1))
2001-11-06 18:59:06 +00:00
(defun calc-insert-variables (buf)
(interactive "bBuffer in which to save variable values: ")
(with-current-buffer buf
Don't quote lambdas with 'function' in calc/*.el * lisp/calc/calc-aent.el (calc-do-quick-calc) (calc-do-calc-eval, math-build-parse-table): * lisp/calc/calc-alg.el (math-polynomial-base): * lisp/calc/calc-alg.el (math-is-poly-rec): * lisp/calc/calc-arith.el (calcFunc-scf): * lisp/calc/calc-arith.el (math-ceiling, math-round): * lisp/calc/calc-arith.el (math-trunc-fancy, math-floor-fancy): * lisp/calc/calc-ext.el (calc-init-extensions, calc-reset) (calc-refresh-top, calc-z-prefix-help, calc-binary-op-fancy) (calc-unary-op-fancy): * lisp/calc/calc-forms.el (math-make-mod): * lisp/calc/calc-frac.el (calcFunc-frac): * lisp/calc/calc-funcs.el (calcFunc-euler): * lisp/calc/calc-help.el (calc-full-help): * lisp/calc/calc-lang.el (c, pascal, fortran, tex, latex, eqn) (yacas, maxima, giac, math, maple): * lisp/calc/calc-macs.el (calc-wrapper, calc-slow-wrapper): * lisp/calc/calc-map.el (calc-get-operator, calcFunc-mapeqr) (calcFunc-reducea, calcFunc-rreducea, calcFunc-reduced) (calcFunc-rreduced, calcFunc-outer): * lisp/calc/calc-misc.el (another-calc, calc-do-handle-whys): * lisp/calc/calc-mode.el (calc-save-modes): * lisp/calc/calc-mtx.el (math-col-matrix, math-mul-mat-vec): * lisp/calc/calc-poly.el (math-sort-terms, math-poly-div-list) (math-mul-list, math-sort-poly-base-list) (math-partial-fractions): * lisp/calc/calc-prog.el (calc-user-define-formula): * lisp/calc/calc-rewr.el (math-rewrite, math-compile-patterns) (math-compile-rewrites, math-parse-schedule) (math-rwcomp-pattern): * lisp/calc/calc-store.el (calc-var-name-map, calc-let) (calc-permanent-variable, calc-insert-variables): * lisp/calc/calc-stuff.el (calc-flush-caches, calcFunc-pclean) (calcFunc-pfrac): * lisp/calc/calc-units.el (math-build-units-table) (math-decompose-units): * lisp/calc/calc-vec.el (calcFunc-mrow, math-mat-col) (calcFunc-mcol, math-mat-less-col, math-mimic-ident): * lisp/calc/calc-yank.el (calc-edit): * lisp/calc/calc.el (calc-mode-var-list-restore-default-values) (calc-mode-var-list-restore-saved-values, calc-mode, calc-quit): * lisp/calc/calccomp.el (math-compose-expr) (math-compose-matrix, math-vector-to-string): Don't quote lambdas with 'function'.
2020-11-17 01:51:30 +00:00
(mapatoms (lambda (x)
(and (string-match "\\`var-" (symbol-name x))
(not (memq x calc-dont-insert-variables))
(calc-var-value x)
(not (eq (car-safe (symbol-value x)) 'special-const))
(or (not (eq x 'var-Decls))
(not (equal var-Decls '(vec))))
(or (not (eq x 'var-Holidays))
(not (equal var-Holidays '(vec (var sat var-sat)
(var sun var-sun)))))
(insert "(setq "
(symbol-name x)
" "
(prin1-to-string
(let ((calc-language
(if (memq calc-language '(nil big))
'flat
calc-language)))
(math-format-value (symbol-value x) 100000)))
")\n"))))))
2001-11-06 18:59:06 +00:00
(defun calc-assign (arg)
(interactive "P")
(calc-slow-wrapper
(calc-binary-op ":=" 'calcFunc-assign arg)))
2001-11-06 18:59:06 +00:00
(defun calc-evalto (arg)
(interactive "P")
(calc-slow-wrapper
(calc-unary-op "=>" 'calcFunc-evalto arg)))
2001-11-06 18:59:06 +00:00
(defun calc-subscript (arg)
(interactive "P")
(calc-slow-wrapper
(calc-binary-op "sub" 'calcFunc-subscr arg)))
2001-11-06 18:59:06 +00:00
(provide 'calc-store)
;;; calc-store.el ends here