2020-10-10 20:00:51 +00:00
|
|
|
|
;;; calc-store.el --- value storage functions for Calc -*- lexical-binding:t -*-
|
2001-11-19 07:44:56 +00:00
|
|
|
|
|
2024-01-02 01:47:10 +00:00
|
|
|
|
;; Copyright (C) 1990-1993, 2001-2024 Free Software Foundation, Inc.
|
2001-11-19 07:44:56 +00:00
|
|
|
|
|
|
|
|
|
;; Author: David Gillespie <daveg@synaptics.com>
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 03:16:00 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2007-03-19 20:59:53 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 03:16:00 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
2007-03-19 20:59:53 +00:00
|
|
|
|
|
2001-11-06 18:59:06 +00:00
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
2007-03-19 20:59:53 +00:00
|
|
|
|
;; 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
|
2017-09-13 22:52:52 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
2001-11-19 07:44:56 +00:00
|
|
|
|
;;; Commentary:
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
2001-11-19 07:44:56 +00:00
|
|
|
|
;;; Code:
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
;; This file is autoloaded from calc-ext.el.
|
|
|
|
|
|
2004-11-30 17:25:00 +00:00
|
|
|
|
(require 'calc-ext)
|
2001-11-06 18:59:06 +00:00
|
|
|
|
(require 'calc-macs)
|
|
|
|
|
|
|
|
|
|
;;; Memory commands.
|
|
|
|
|
|
2001-11-19 07:44:56 +00:00
|
|
|
|
(defvar calc-store-keep nil)
|
2001-11-06 18:59:06 +00:00
|
|
|
|
(defun calc-store (&optional var)
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((calc-store-keep t))
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-store-into var)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
2001-11-19 07:44:56 +00:00
|
|
|
|
(defvar calc-given-value-flag nil)
|
2004-11-26 22:35:35 +00:00
|
|
|
|
(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))
|
2005-05-15 05:20:59 +00:00
|
|
|
|
(let ((msg
|
|
|
|
|
(calc-store-value var (or calc-given-value (calc-top 1))
|
|
|
|
|
"" calc-given-value-flag)))
|
2015-09-20 16:40:35 +00:00
|
|
|
|
(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
|
2005-05-15 05:20:59 +00:00
|
|
|
|
(let ((msg
|
|
|
|
|
(calc-store-value (car (car var)) (cdr (car var))
|
|
|
|
|
(if (not (cdr var)) "")
|
|
|
|
|
(if (not (cdr var)) 1))))
|
2015-09-20 16:40:35 +00:00
|
|
|
|
(message "Stored to variable \"%s\"%s"
|
|
|
|
|
(calc-var-name (car (car var))) msg))
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(setq var (cdr var))))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-store-plus (&optional var)
|
|
|
|
|
(interactive)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-store-binary var "+" '+))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-store-minus (&optional var)
|
|
|
|
|
(interactive)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-store-binary var "-" '-))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-store-times (&optional var)
|
|
|
|
|
(interactive)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-store-binary var "*" '*))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-store-div (&optional var)
|
|
|
|
|
(interactive)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-store-binary var "/" '/))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-store-power (&optional var)
|
|
|
|
|
(interactive)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-store-binary var "^" '^))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-store-concat (&optional var)
|
|
|
|
|
(interactive)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-store-binary var "|" '|))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-store-neg (n &optional var)
|
|
|
|
|
(interactive "p")
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-store-binary var "n" '/ (- n)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-store-inv (n &optional var)
|
|
|
|
|
(interactive "p")
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-store-binary var "&" '^ (- n)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-store-incr (n &optional var)
|
|
|
|
|
(interactive "p")
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-store-binary var "n" '- (- n)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-store-decr (n &optional var)
|
|
|
|
|
(interactive "p")
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-store-binary var "n" '- n))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-store-value (var value tag &optional pop)
|
2005-05-15 05:20:59 +00:00
|
|
|
|
(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))
|
2007-09-26 00:07:05 +00:00
|
|
|
|
(setq msg (format " (Note: Built-in definition of %s has been lost)"
|
2005-05-15 05:20:59 +00:00
|
|
|
|
(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)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
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)))
|
2005-05-15 05:20:59 +00:00
|
|
|
|
(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))
|
2005-05-15 05:20:59 +00:00
|
|
|
|
(message "Variable \"%s\" changed" (calc-var-name var)))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
2021-12-08 16:15:28 +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.")
|
2004-11-26 22:35:35 +00:00
|
|
|
|
|
|
|
|
|
(defvar calc-store-opers)
|
|
|
|
|
|
2008-03-26 20:26:50 +00:00
|
|
|
|
(defvar calc-read-var-name-history nil
|
|
|
|
|
"History for reading variable names.")
|
|
|
|
|
|
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)
|
2020-10-10 20:00:51 +00:00
|
|
|
|
(let* ((calc-store-opers store-opers)
|
|
|
|
|
(var (concat
|
2004-12-27 05:02:08 +00:00
|
|
|
|
"var-"
|
2021-11-11 05:16:52 +00:00
|
|
|
|
(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))
|
2010-06-22 07:41:10 +00:00
|
|
|
|
(read-from-minibuffer
|
|
|
|
|
prompt nil calc-var-name-map nil
|
2008-03-26 20:26:50 +00:00
|
|
|
|
'calc-read-var-name-history)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
(setq calc-aborted-prefix "")
|
2004-12-27 05:02:08 +00:00
|
|
|
|
(and (not (equal var "var-"))
|
2010-05-15 04:50:25 +00:00
|
|
|
|
(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))
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(intern var)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calcVar-digit ()
|
|
|
|
|
(interactive)
|
2004-12-31 20:36:48 +00:00
|
|
|
|
(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))
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(self-insert-command 1)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calcVar-oper ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(if (and (eq calc-store-opers t)
|
2004-12-31 20:36:48 +00:00
|
|
|
|
(calc-minibuffer-contains "\\'"))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
(progn
|
|
|
|
|
(erase-buffer)
|
|
|
|
|
(self-insert-and-exit))
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(self-insert-command 1)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-store-map (&optional oper var)
|
|
|
|
|
(interactive)
|
|
|
|
|
(calc-wrapper
|
2012-09-20 03:44:57 +00:00
|
|
|
|
(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
|
2005-05-15 05:20:59 +00:00
|
|
|
|
(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)
|
2005-05-15 05:20:59 +00:00
|
|
|
|
(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
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(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)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(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)))
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(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)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
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))))
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-push value)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-store-quick ()
|
|
|
|
|
(interactive)
|
2009-01-09 03:57:12 +00:00
|
|
|
|
(calc-store (intern (format "var-q%c" last-command-event))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-store-into-quick ()
|
|
|
|
|
(interactive)
|
2009-01-09 03:57:12 +00:00
|
|
|
|
(calc-store-into (intern (format "var-q%c" last-command-event))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-recall-quick ()
|
|
|
|
|
(interactive)
|
2009-01-09 03:57:12 +00:00
|
|
|
|
(calc-recall (intern (format "var-q%c" last-command-event))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
2005-05-16 03:55:11 +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
|
2007-09-26 00:07:05 +00:00
|
|
|
|
(format "Copy special constant %s, to: "
|
2005-05-16 03:55:11 +00:00
|
|
|
|
sconst))))
|
|
|
|
|
(if var
|
|
|
|
|
(let ((msg (calc-store-value var value "")))
|
2019-03-07 17:02:15 +00:00
|
|
|
|
(message "Special constant \"%s\" copied to \"%s\"%s"
|
|
|
|
|
sconst (calc-var-name var) msg))))))))
|
2005-05-16 03:55:11 +00:00
|
|
|
|
|
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
|
2004-12-30 17:43:09 +00:00
|
|
|
|
(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
|
2007-09-26 00:07:05 +00:00
|
|
|
|
(format "Copy variable: %s, to: "
|
2004-12-30 17:43:09 +00:00
|
|
|
|
(calc-var-name var1)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
(if var2
|
2005-05-15 05:20:59 +00:00
|
|
|
|
(let ((msg (calc-store-value var2 value "")))
|
2015-09-20 16:40:35 +00:00
|
|
|
|
(message "Variable \"%s\" copied to \"%s\"%s"
|
|
|
|
|
(calc-var-name var1) (calc-var-name var2) msg)))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
2001-11-19 07:44:56 +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)
|
2021-01-04 05:01:58 +00:00
|
|
|
|
(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
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(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)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-edit-variable 'var-Decls))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-edit-EvalRules ()
|
|
|
|
|
(interactive)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-edit-variable 'var-EvalRules))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-edit-FitRules ()
|
|
|
|
|
(interactive)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-edit-variable 'var-FitRules))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-edit-GenCount ()
|
|
|
|
|
(interactive)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-edit-variable 'var-GenCount))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-edit-Holidays ()
|
|
|
|
|
(interactive)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-edit-variable 'var-Holidays))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-edit-IntegLimit ()
|
|
|
|
|
(interactive)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-edit-variable 'var-IntegLimit))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-edit-LineStyles ()
|
|
|
|
|
(interactive)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-edit-variable 'var-LineStyles))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-edit-PointStyles ()
|
|
|
|
|
(interactive)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-edit-variable 'var-PointStyles))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-edit-PlotRejects ()
|
|
|
|
|
(interactive)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-edit-variable 'var-PlotRejects))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-edit-AlgSimpRules ()
|
|
|
|
|
(interactive)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-edit-variable 'var-AlgSimpRules))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-edit-TimeZone ()
|
|
|
|
|
(interactive)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-edit-variable 'var-TimeZone))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-edit-Units ()
|
|
|
|
|
(interactive)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-edit-variable 'var-Units))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-edit-ExtSimpRules ()
|
|
|
|
|
(interactive)
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(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))
|
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)
|
2005-01-24 18:23:33 +00:00
|
|
|
|
(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)))))))
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-refresh-evaltos 'var-Decls))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
2001-11-19 07:44:56 +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))
|
|
|
|
|
|
2004-11-26 22:35:35 +00:00
|
|
|
|
;; 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
|
2021-10-05 01:34:08 +00:00
|
|
|
|
(or var (setq var (calc-read-var-name (format-prompt "Save variable" "all"))))
|
2004-11-26 22:35:35 +00:00
|
|
|
|
(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)))))
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(save-buffer))))
|
2001-11-19 07:44:56 +00:00
|
|
|
|
|
|
|
|
|
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-insert-permanent-variable (var)
|
|
|
|
|
(goto-char (point-min))
|
2015-06-29 12:26:29 +00:00
|
|
|
|
(if (let (case-fold-search)
|
|
|
|
|
(search-forward (concat "(setq " (symbol-name var) " '") nil t))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
(progn
|
2004-11-26 22:35:35 +00:00
|
|
|
|
(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))))
|
2004-11-26 22:35:35 +00:00
|
|
|
|
(goto-char (- calc-pv-pos 8 (length (symbol-name var))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
(forward-sexp 1)
|
|
|
|
|
(backward-char 1)
|
2004-11-26 22:35:35 +00:00
|
|
|
|
(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)))
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(forward-line 1))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-insert-variables (buf)
|
|
|
|
|
(interactive "bBuffer in which to save variable values: ")
|
* calc/calc.el (calc, calc-refresh, calc-trail-buffer, calc-record)
(calcDigit-nondigit):
* calc/calc-yank.el (calc-copy-to-buffer):
* calc/calc-units.el (calc-invalidate-units-table):
* calc/calc-trail.el (calc-trail-yank):
* calc/calc-store.el (calc-insert-variables):
* calc/calc-rewr.el (math-rewrite, math-rewrite-phase):
* calc/calc-prog.el (calc-read-parse-table):
* calc/calc-keypd.el (calc-do-keypad, calc-keypad-right-click):
* calc/calc-help.el (calc-describe-bindings, calc-describe-key):
* calc/calc-graph.el (calc-graph-delete, calc-graph-add-curve)
(calc-graph-juggle, calc-graph-count-curves, calc-graph-plot)
(calc-graph-plot, calc-graph-format-data, calc-graph-set-styles)
(calc-graph-name, calc-graph-find-command, calc-graph-view)
(calc-graph-view, calc-gnuplot-command, calc-graph-init):
* calc/calc-ext.el (calc-realign):
* calc/calc-embed.el (calc-do-embedded, calc-do-embedded)
(calc-embedded-finish-edit, calc-embedded-make-info)
(calc-embedded-finish-command, calc-embedded-stack-change):
* calc/calc-aent.el (calcAlg-enter): Use with-current-buffer.
2009-10-28 18:35:33 +00:00
|
|
|
|
(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
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-binary-op ":=" 'calcFunc-assign arg)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-evalto (arg)
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(calc-slow-wrapper
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-unary-op "=>" 'calcFunc-evalto arg)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
(defun calc-subscript (arg)
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(calc-slow-wrapper
|
2001-11-14 09:09:09 +00:00
|
|
|
|
(calc-binary-op "sub" 'calcFunc-subscr arg)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
2004-11-30 17:25:00 +00:00
|
|
|
|
(provide 'calc-store)
|
|
|
|
|
|
2001-11-14 09:09:09 +00:00
|
|
|
|
;;; calc-store.el ends here
|