1 ;;; calc-embed.el --- embed Calc in a buffer
3 ;; Copyright (C) 1990-1993, 2001-2015 Free Software Foundation, Inc.
5 ;; Author: David Gillespie <daveg@synaptics.com>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; This file is autoloaded from calc-ext.el.
30 (autoload 'thing-at-point-looking-at "thingatpt")
33 (defun calc-show-plain (n)
36 (calc-set-command-flag 'renum-stack)
37 (message (if (calc-change-mode 'calc-show-plain n nil t)
38 "Including \"plain\" formulas in Calc Embedded mode"
39 "Omitting \"plain\" formulas in Calc Embedded mode"))))
42 (defvar calc-embedded-modes nil)
43 (defvar calc-embedded-globals nil)
44 (defvar calc-embedded-active nil)
45 (defvar calc-embedded-all-active nil)
46 (make-variable-buffer-local 'calc-embedded-all-active)
47 (defvar calc-embedded-some-active nil)
48 (make-variable-buffer-local 'calc-embedded-some-active)
50 ;; The following variables are customizable and defined in calc.el.
51 (defvar calc-embedded-announce-formula)
52 (defvar calc-embedded-open-formula)
53 (defvar calc-embedded-close-formula)
54 (defvar calc-embedded-open-plain)
55 (defvar calc-embedded-close-plain)
56 (defvar calc-embedded-open-new-formula)
57 (defvar calc-embedded-close-new-formula)
58 (defvar calc-embedded-open-mode)
59 (defvar calc-embedded-close-mode)
60 (defvar calc-embedded-word-regexp)
62 (defvar math-embed-the-language)
63 (defvar math-embed-the-display-just)
64 (defconst calc-embedded-mode-vars '(("twos-complement" . calc-twos-complement-mode)
65 ("precision" . calc-internal-prec)
66 ("word-size" . calc-word-size)
67 ("angles" . calc-angle-mode)
68 ("symbolic" . calc-symbolic-mode)
69 ("matrix" . calc-matrix-mode)
70 ("fractions" . calc-prefer-frac)
71 ("complex" . calc-complex-mode)
72 ("simplify" . calc-simplify-mode)
73 ("language" . math-embed-the-language)
74 ("plain" . calc-show-plain)
75 ("break" . calc-line-breaking)
76 ("justify" . math-embed-the-display-just)
77 ("left-label" . calc-left-label)
78 ("right-label" . calc-right-label)
79 ("radix" . calc-number-radix)
80 ("leading-zeros" . calc-leading-zeros)
81 ("grouping" . calc-group-digits)
82 ("group-char" . calc-group-char)
83 ("point-char" . calc-point-char)
84 ("frac-format" . calc-frac-format)
85 ("float-format" . calc-float-format)
86 ("complex-format" . calc-complex-format)
87 ("hms-format" . calc-hms-format)
88 ("date-format" . calc-date-format)
89 ("matrix-justify" . calc-matrix-just)
90 ("full-vectors" . calc-full-vectors)
91 ("break-vectors" . calc-break-vectors)
92 ("vector-commas" . calc-vector-commas)
93 ("vector-brackets" . calc-vector-brackets)
94 ("matrix-brackets" . calc-matrix-brackets)
95 ("strings" . calc-display-strings)
99 ;; Format of calc-embedded-info vector:
101 ;; 1 Calculator buffer.
102 ;; 2 Top of current formula (marker).
103 ;; 3 Bottom of current formula (marker).
104 ;; 4 Top of current formula's delimiters (marker).
105 ;; 5 Bottom of current formula's delimiters (marker).
106 ;; 6 String representation of current formula.
107 ;; 7 Non-nil if formula is embedded within a single line.
108 ;; 8 Internal representation of current formula.
109 ;; 9 Variable assigned by this formula, or nil.
110 ;; 10 List of variables upon which this formula depends.
111 ;; 11 Evaluated value of the formula, or nil.
112 ;; 12 Mode settings for current formula.
113 ;; 13 Local mode settings for current formula.
114 ;; 14 Permanent mode settings for current formula.
115 ;; 15 Global mode settings for editing buffer.
118 ;; calc-embedded-active is an a-list keyed on buffers; each cdr is a
119 ;; sorted list of calc-embedded-infos in that buffer. We do this
120 ;; rather than using buffer-local variables because the latter are
121 ;; thrown away when a buffer changes major modes.
123 (defvar calc-embedded-original-modes nil
124 "The mode settings for Calc buffer when put in embedded mode.")
126 (defun calc-embedded-save-original-modes ()
127 "Save the current Calc modes when entering embedded mode."
128 (let ((calcbuf (save-excursion
133 (with-current-buffer calcbuf
135 (cons calc-language calc-language-option))
137 (list (cons 'calc-display-just
139 (cons 'calc-display-origin
140 calc-display-origin)))
141 (let ((v calc-embedded-mode-vars))
143 (let ((var (cdr (car v))))
144 (unless (memq var '(math-embed-the-language math-embed-the-display-just))
146 (cons (cons var (symbol-value var))
149 (setq calc-embedded-original-modes (cons lang modes)))
150 (setq calc-embedded-original-modes nil))))
152 (defun calc-embedded-preserve-modes ()
153 "Preserve the current modes when leaving embedded mode."
155 (if calc-embedded-info
157 (calc-embedded-save-original-modes)
158 (message "Current modes will be preserved when leaving embedded mode."))
159 (message "Not in embedded mode.")))
161 (defun calc-embedded-restore-original-modes (calcbuf)
162 "Restore the original Calc modes when leaving embedded mode."
164 (lang (car calc-embedded-original-modes))
165 (modes (cdr calc-embedded-original-modes)))
166 (if (and calcbuf calc-embedded-original-modes)
167 (with-current-buffer calcbuf
169 (equal calc-language (car lang))
170 (equal calc-language-option (cdr lang)))
171 (calc-set-language (car lang) (cdr lang))
174 (let ((mode (car modes)))
175 (unless (equal (symbol-value (car mode)) (cdr mode))
176 (set (car mode) (cdr mode))
178 (setq modes (cdr modes)))
181 (calc-set-mode-line))))
182 (setq calc-embedded-original-modes nil)))
184 ;; The variables calc-embed-outer-top, calc-embed-outer-bot,
185 ;; calc-embed-top and calc-embed-bot are
186 ;; local to calc-do-embedded, calc-embedded-mark-formula,
187 ;; calc-embedded-duplicate, calc-embedded-new-formula and
188 ;; calc-embedded-make-info, but are used by calc-embedded-find-bounds,
189 ;; which is called (directly or indirectly) by the above functions.
190 (defvar calc-embed-outer-top)
191 (defvar calc-embed-outer-bot)
192 (defvar calc-embed-top)
193 (defvar calc-embed-bot)
195 ;; The variable calc-embed-arg is local to calc-do-embedded,
196 ;; calc-embedded-update-formula, calc-embedded-edit and
197 ;; calc-do-embedded-activate, but is used by
198 ;; calc-embedded-make-info, which is called by the above
200 (defvar calc-embed-arg)
202 (defvar calc-embedded-quiet nil)
204 (defvar calc-embedded-firsttime)
205 (defvar calc-embedded-firsttime-buf)
206 (defvar calc-embedded-firsttime-formula)
208 ;; The following is to take care of any minor modes which override
210 (defvar calc-override-minor-modes-map
212 "A list of keybindings that might be overwritten by minor modes.")
214 ;; Add any keys that might be overwritten here.
215 (define-key calc-override-minor-modes-map "`" 'calc-edit)
217 (defvar calc-override-minor-modes
218 (cons t calc-override-minor-modes-map))
220 (defun calc-do-embedded (calc-embed-arg end obeg oend)
221 (if calc-embedded-info
223 ;; Turn embedded mode off or switch to a new buffer.
224 (cond ((eq (current-buffer) (aref calc-embedded-info 1))
225 (let ((calcbuf (current-buffer))
226 ) ;(buf (aref calc-embedded-info 0)))
227 (calc-embedded-original-buffer t)
229 (switch-to-buffer calcbuf)))
231 ((eq (current-buffer) (aref calc-embedded-info 0))
232 (let* ((info calc-embedded-info)
233 (mode calc-embedded-modes)
234 (calcbuf (aref calc-embedded-info 1)))
235 (with-current-buffer (aref info 1)
236 (if (and (> (calc-stack-size) 0)
237 (equal (calc-top 1 'full) (aref info 8)))
238 (let ((calc-no-refresh-evaltos t))
239 (if (calc-top 1 'sel)
241 (calc-embedded-set-modes
242 (aref info 15) (aref info 12) (aref info 14))
243 (let ((calc-embedded-info nil))
244 (calc-wrapper (calc-pop-stack))))
245 (calc-set-mode-line)))
246 (setq calc-embedded-info nil
247 mode-line-buffer-identification (car mode)
248 truncate-lines (nth 2 mode)
249 buffer-read-only nil)
250 (use-local-map (nth 1 mode))
251 (set-buffer-modified-p (buffer-modified-p))
252 (calc-embedded-restore-original-modes calcbuf)
253 (or calc-embedded-quiet
254 (message "Back to %s mode" mode-name))))
257 (if (buffer-name (aref calc-embedded-info 0))
258 (with-current-buffer (aref calc-embedded-info 0)
259 (or (y-or-n-p (format "Cancel Calc Embedded mode in buffer %s? "
262 (calc-embedded nil)))
263 (calc-embedded calc-embed-arg end obeg oend)))
265 ;; Turn embedded mode on.
266 (calc-plain-buffer-only)
267 (let ((modes (list mode-line-buffer-identification
270 (calc-embedded-firsttime (not calc-embedded-active))
271 (calc-embedded-firsttime-buf nil)
272 (calc-embedded-firsttime-formula nil)
273 calc-embed-top calc-embed-bot calc-embed-outer-top calc-embed-outer-bot
275 (barf-if-buffer-read-only)
276 (calc-embedded-save-original-modes)
277 (or calc-embedded-globals
280 (calc-embedded-make-info (point) nil t calc-embed-arg end obeg oend))
281 (if (eq (car-safe (aref info 8)) 'error)
283 (setq calc-embedded-original-modes nil)
284 (goto-char (nth 1 (aref info 8)))
285 (error (nth 2 (aref info 8)))))
286 (let ((mode-line-buffer-identification mode-line-buffer-identification)
287 (calc-embedded-info info)
288 ;; (calc-embedded-no-reselect t) ; appears unused --SY
292 (calc-no-refresh-evaltos t))
295 (calc-push (calc-normalize (aref info 8)))
296 (setq chg (calc-embedded-set-modes
297 (aref info 15) (aref info 12) (aref info 13))))
298 (setq chg (calc-embedded-set-modes
299 (aref info 15) (aref info 12) (aref info 13)))
301 (setq calc-undo-list nil
303 ident mode-line-buffer-identification)))
304 (setq calc-embedded-info info
305 calc-embedded-modes modes
306 mode-line-buffer-identification ident
309 (set-buffer-modified-p (buffer-modified-p))
310 (use-local-map calc-mode-map)
311 (setq calc-no-refresh-evaltos nil)
312 (and chg calc-any-evaltos (calc-wrapper (calc-refresh-evaltos)))
316 (setq str mode-line-buffer-identification))
317 (unless (equal str mode-line-buffer-identification)
318 (setq mode-line-buffer-identification str)
319 (set-buffer-modified-p (buffer-modified-p))))
320 (if calc-embedded-firsttime
321 (run-hooks 'calc-embedded-mode-hook))
322 (if calc-embedded-firsttime-buf
323 (run-hooks 'calc-embedded-new-buffer-hook))
324 (if calc-embedded-firsttime-formula
325 (run-hooks 'calc-embedded-new-formula-hook))
326 (or (eq calc-embedded-quiet t)
328 "Embedded Calc mode enabled; "
329 (if calc-embedded-quiet
331 "Give this command again")
332 " to return to normal")))))
333 (scroll-down 0)) ; fix a bug which occurs when truncate-lines is changed.
336 (defun calc-embedded-select (arg)
339 (and calc-embedded-info
340 (eq (car-safe (aref calc-embedded-info 8)) 'calcFunc-evalto)
341 (calc-select-part 1))
342 (and calc-embedded-info
343 (or (eq (car-safe (aref calc-embedded-info 8)) 'calcFunc-assign)
344 (and (eq (car-safe (aref calc-embedded-info 8)) 'calcFunc-evalto)
345 (eq (car-safe (nth 1 (aref calc-embedded-info 8)))
347 (calc-select-part 2)))
350 (defun calc-embedded-update-formula (calc-embed-arg)
353 (let ((entry (assq (current-buffer) calc-embedded-active)))
354 (while (setq entry (cdr entry))
355 (and (eq (car-safe (aref (car entry) 8)) 'calcFunc-evalto)
356 (or (not (consp calc-embed-arg))
357 (and (<= (aref (car entry) 2) (region-beginning))
358 (>= (aref (car entry) 3) (region-end))))
360 (calc-embedded-update (car entry) 14 t t)))))
361 (if (and calc-embedded-info
362 (eq (current-buffer) (aref calc-embedded-info 0))
363 (>= (point) (aref calc-embedded-info 4))
364 (<= (point) (aref calc-embedded-info 5)))
367 (info (calc-embedded-make-info (point) nil t))
368 (pt (- opt (aref info 4))))
369 (or (eq (car-safe (aref info 8)) 'error)
372 (calc-embedded-update info 14 'eval t))
373 (goto-char (+ (aref info 4) pt))))))))
376 (defun calc-embedded-edit (calc-embed-arg)
378 (let ((info (calc-embedded-make-info (point) nil t calc-embed-arg))
380 (if (eq (car-safe (aref info 8)) 'error)
382 (goto-char (nth 1 (aref info 8)))
383 (error (nth 2 (aref info 8)))))
385 (setq str (math-showing-full-precision
386 (math-format-nice-expr (aref info 8) (frame-width))))
387 (calc-edit-mode (list 'calc-embedded-finish-edit info))
389 (calc-show-edit-buffer))
391 (defvar calc-original-buffer)
392 (defvar calc-edit-top)
393 (defun calc-embedded-finish-edit (info)
394 (let ((buf (current-buffer))
395 (str (buffer-substring calc-edit-top (point-max)))
397 (switch-to-buffer calc-original-buffer)
398 (let ((val (with-current-buffer (aref info 1)
399 (let ((calc-language nil)
400 (math-expr-opers (math-standard-ops)))
401 (math-read-expr str)))))
402 (if (eq (car-safe val) 'error)
404 (switch-to-buffer buf)
405 (goto-char (+ start (nth 1 val)))
406 (error (nth 2 val))))
407 (calc-embedded-original-buffer t info)
409 (calc-embedded-update info 14 t t))))
412 (defun calc-do-embedded-activate (calc-embed-arg cbuf)
413 (calc-plain-buffer-only)
415 (calc-embedded-forget))
417 (if (< (prefix-numeric-value calc-embed-arg) 0)
418 (message "Deactivating %s for Calc Embedded mode" (buffer-name))
419 (message "Activating %s for Calc Embedded mode..." (buffer-name))
421 (let* ((active (assq (current-buffer) calc-embedded-active))
423 (pat " := \\| \\\\gets \\| => \\| \\\\evalto "))
424 (if calc-embedded-announce-formula
425 (setq pat (format "%s\\|\\(%s\\)"
426 pat calc-embedded-announce-formula)))
427 (while (setq info (cdr info))
428 (or (equal (buffer-substring (aref (car info) 2) (aref (car info) 3))
430 (setcdr active (delq (car info) (cdr active)))))
431 (goto-char (point-min))
432 (while (re-search-forward pat nil t)
433 (setq info (calc-embedded-make-info (point) cbuf nil))
434 (or (eq (car-safe (aref info 8)) 'error)
435 (goto-char (aref info 5))))))
436 (message "Activating %s for Calc Embedded mode...done" (buffer-name)))
437 (calc-embedded-active-state t))
439 (defun calc-plain-buffer-only ()
440 (if (memq major-mode '(calc-mode calc-trail-mode calc-edit-mode))
441 (error "This command should be used in a normal editing buffer")))
443 (defun calc-embedded-active-state (state)
444 (or (assq 'calc-embedded-all-active minor-mode-alist)
445 (setq minor-mode-alist
446 (cons '(calc-embedded-all-active " Active")
447 (cons '(calc-embedded-some-active " ~Active")
449 (let ((active (assq (current-buffer) calc-embedded-active)))
452 (and (eq state 'more) calc-embedded-all-active (setq state t))
453 (setq calc-embedded-all-active (eq state t)
454 calc-embedded-some-active (not (memq state '(nil t))))
455 (set-buffer-modified-p (buffer-modified-p)))
458 (defun calc-embedded-original-buffer (switch &optional info)
459 (or info (setq info calc-embedded-info))
460 (or (buffer-name (aref info 0))
462 (error "Calc embedded mode: Original buffer has been killed")))
464 (set-buffer (aref info 0))))
466 (defun calc-embedded-word ()
468 (calc-embedded '(t)))
470 (defun calc-embedded-mark-formula (&optional body-only)
471 "Put point at the beginning of this Calc formula, mark at the end.
472 This normally marks the whole formula, including surrounding delimiters.
473 With any prefix argument, marks only the formula itself."
475 (and (eq major-mode 'calc-mode)
476 (error "This command should be used in a normal editing buffer"))
477 (let (calc-embed-top calc-embed-bot calc-embed-outer-top calc-embed-outer-bot)
479 (calc-embedded-find-bounds body-only))
480 (push-mark (if body-only calc-embed-bot calc-embed-outer-bot) t)
481 (goto-char (if body-only calc-embed-top calc-embed-outer-top))))
483 (defun calc-embedded-find-bounds (&optional plain)
484 ;; (while (and (bolp) (eq (following-char) ?\n))
486 (and (eolp) (bolp) (not (eq (char-after (- (point) 2)) ?\n))
488 (let ((home (point)))
489 (or (and (looking-at calc-embedded-open-formula)
490 (not (looking-at calc-embedded-close-formula)))
491 (re-search-backward calc-embedded-open-formula nil t)
492 (error "Can't find start of formula"))
493 (and (eq (preceding-char) ?\$) ; backward search for \$\$? won't back
494 (eq (following-char) ?\$) ; up over a second $, so do it by hand.
496 (setq calc-embed-outer-top (point))
497 (goto-char (match-end 0))
498 (if (looking-at "[ \t]*$")
500 (if (eq (following-char) ?\n)
503 (while (eq (following-char) ?\ )
505 (or (eq plain 'plain)
506 (if (looking-at (regexp-quote calc-embedded-open-plain))
508 (goto-char (match-end 0))
509 (search-forward calc-embedded-close-plain))))
510 (setq calc-embed-top (point))
511 (or (re-search-forward calc-embedded-close-formula nil t)
512 (error "Can't find end of formula"))
514 (error "Not inside a formula"))
515 (and (eq (following-char) ?\n) (not (bolp))
517 (setq calc-embed-outer-bot (point))
518 (goto-char (match-beginning 0))
519 (if (eq (preceding-char) ?\n)
522 (while (eq (preceding-char) ?\ )
524 (setq calc-embed-bot (point))))
526 (defun calc-embedded-kill-formula ()
527 "Kill the formula surrounding point.
528 If Calc Embedded mode was active, this deactivates it.
529 The formula (including its surrounding delimiters) is saved in the kill ring.
530 The command \\[yank] can retrieve it from there."
532 (and calc-embedded-info
534 (calc-embedded-mark-formula)
535 (kill-region (point) (mark))
538 (defun calc-embedded-copy-formula-as-kill ()
539 "Save the formula surrounding point as if killed, but don't kill it."
542 (calc-embedded-mark-formula)
543 (copy-region-as-kill (point) (mark))
546 (defun calc-embedded-duplicate ()
548 (let ((already calc-embedded-info)
549 calc-embed-top calc-embed-bot calc-embed-outer-top calc-embed-outer-bot new-top)
550 (if calc-embedded-info
552 (setq calc-embed-top (+ (aref calc-embedded-info 2))
553 calc-embed-bot (+ (aref calc-embedded-info 3))
554 calc-embed-outer-top (+ (aref calc-embedded-info 4))
555 calc-embed-outer-bot (+ (aref calc-embedded-info 5)))
557 (calc-embedded-find-bounds))
558 (goto-char calc-embed-outer-bot)
560 (setq new-top (point))
561 (insert-buffer-substring (current-buffer)
562 calc-embed-outer-top calc-embed-outer-bot)
563 (goto-char (+ new-top (- calc-embed-top calc-embed-outer-top)))
564 (let ((calc-embedded-quiet (if already t 'x)))
565 (calc-embedded (+ new-top (- calc-embed-top calc-embed-outer-top))
566 (+ new-top (- calc-embed-bot calc-embed-outer-top))
568 (+ new-top (- calc-embed-outer-bot calc-embed-outer-top))))))
570 (defun calc-embedded-next (arg)
572 (setq arg (prefix-numeric-value arg))
573 (let* ((active (cdr (assq (current-buffer) calc-embedded-active)))
575 (num (length active)))
577 (error "No active formulas in buffer"))
580 (if (<= (point) (aref (car active) 3))
581 (goto-char (aref (nth (1- num) active) 2))
583 (> (point) (aref (nth 1 p) 3)))
585 (goto-char (aref (car p) 2))))
587 (calc-embedded-next -1)
588 (calc-embedded-next (+ (* num 1000) arg 1)))
590 (setq arg (1+ (% (1- arg) num)))
591 (while (and p (>= (point) (aref (car p) 2)))
593 (while (> (setq arg (1- arg)) 0)
594 (setq p (if p (cdr p) (cdr active))))
595 (goto-char (aref (car (or p active)) 2))))))
597 (defun calc-embedded-previous (arg)
599 (calc-embedded-next (- (prefix-numeric-value arg))))
601 (defun calc-embedded-new-formula ()
603 (and (eq major-mode 'calc-mode)
604 (error "This command should be used in a normal editing buffer"))
605 (if calc-embedded-info
607 (let (calc-embed-top calc-embed-bot calc-embed-outer-top calc-embed-outer-bot)
608 (if (and (eq (preceding-char) ?\n)
609 (string-match "\\`\n" calc-embedded-open-new-formula))
611 (setq calc-embed-outer-top (1- (point)))
613 (insert (substring calc-embedded-open-new-formula 1)))
614 (setq calc-embed-outer-top (point))
615 (insert calc-embedded-open-new-formula))
616 (setq calc-embed-top (point))
618 (setq calc-embed-bot (point))
619 (insert calc-embedded-close-new-formula)
620 (if (and (eq (following-char) ?\n)
621 (string-match "\n\\'" calc-embedded-close-new-formula))
623 (setq calc-embed-outer-bot (point))
624 (goto-char calc-embed-top)
625 (let ((calc-embedded-quiet 'x))
626 (calc-embedded calc-embed-top calc-embed-bot calc-embed-outer-top calc-embed-outer-bot))))
628 (defun calc-embedded-forget ()
630 (setq calc-embedded-active (delq (assq (current-buffer) calc-embedded-active)
631 calc-embedded-active))
632 (calc-embedded-active-state nil))
634 ;; The variables calc-embed-prev-modes is local to calc-embedded-update,
635 ;; but is used by calc-embedded-set-modes.
636 (defvar calc-embed-prev-modes)
638 (defun calc-embedded-set-modes (gmodes modes local-modes &optional temp)
639 (let ((math-embed-the-language (calc-embedded-language))
640 (math-embed-the-display-just (calc-embedded-justify))
645 (or (symbolp (car v))
646 (and (setq found (assq (car (car v)) modes))
647 (not (eq (cdr found) 'default)))
648 (and (setq found (assq (car (car v)) local-modes))
649 (not (eq (cdr found) 'default)))
651 (if (eq (setq value (cdr (car v))) 'default)
652 (setq value (list (nth 1 (assq (car (car v)) calc-mode-var-list)))))
653 (equal (symbol-value (car (car v))) value))
656 (if temp (setq calc-embed-prev-modes
657 (cons (cons (car (car v))
658 (symbol-value (car (car v))))
659 calc-embed-prev-modes)))
660 (set (car (car v)) value)))
664 (or (and (setq found (assq (car (car v)) local-modes))
665 (not (eq (cdr found) 'default)))
666 (eq (setq value (cdr (car v))) 'default)
667 (equal (symbol-value (car (car v))) value)
670 (if temp (setq calc-embed-prev-modes (cons (cons (car (car v))
671 (symbol-value (car (car v))))
672 calc-embed-prev-modes)))
673 (set (car (car v)) value)))
677 (or (eq (setq value (cdr (car v))) 'default)
678 (equal (symbol-value (car (car v))) value)
681 (if temp (setq calc-embed-prev-modes (cons (cons (car (car v))
682 (symbol-value (car (car v))))
683 calc-embed-prev-modes)))
684 (set (car (car v)) value)))
686 (and changed (not (eq temp t))
688 (calc-embedded-set-justify math-embed-the-display-just)
689 (calc-embedded-set-language math-embed-the-language)))
690 (and changed (not temp)
692 (setq calc-full-float-format (list (if (eq (car calc-float-format)
695 (car calc-float-format))
700 (defun calc-embedded-language ()
701 (if calc-language-option
702 (list calc-language calc-language-option)
705 (defun calc-embedded-set-language (lang)
708 (setq option (nth 1 lang)
710 (or (and (eq lang calc-language)
711 (equal option calc-language-option))
712 (calc-set-language lang option t))))
714 (defun calc-embedded-justify ()
715 (if calc-display-origin
716 (list calc-display-just calc-display-origin)
719 (defun calc-embedded-set-justify (just)
721 (setq calc-display-origin (nth 1 just)
722 calc-display-just (car just))
723 (setq calc-display-just just
724 calc-display-origin nil)))
727 (defun calc-find-globals ()
729 (and (eq major-mode 'calc-mode)
730 (error "This command should be used in a normal editing buffer"))
731 (make-local-variable 'calc-embedded-globals)
732 (let ((case-fold-search nil)
736 (goto-char (point-min))
737 (while (re-search-forward "\\[calc-global-mode: *\\([-a-z]+\\): *\\(\"\\([^\"\n\\]\\|\\\\.\\)*\"\\|[- ()a-zA-Z0-9]+\\)\\]" nil t)
738 (and (setq found (assoc (buffer-substring (match-beginning 1)
740 calc-embedded-mode-vars))
741 (or (assq (cdr found) modes)
742 (setq modes (cons (cons (cdr found)
743 (car (read-from-string
748 (setq calc-embedded-globals (cons t modes))
749 (goto-char save-pt)))
751 (defun calc-embedded-find-modes ()
752 (let ((case-fold-search nil)
759 (while (and no-defaults (search-backward "[calc-" nil t))
761 (or (and (looking-at "mode: *\\([-a-z]+\\): *\\(\"\\([^\"\n\\]\\|\\\\.\\)*\"\\|[- ()a-zA-Z0-9]+\\)]")
762 (setq found (assoc (buffer-substring (match-beginning 1)
764 calc-embedded-mode-vars))
765 (or (assq (cdr found) modes)
766 (setq modes (cons (cons (cdr found)
767 (car (read-from-string
772 (and (looking-at "perm-mode: *\\([-a-z]+\\): *\\(\"\\([^\"\n\\]\\|\\\\.\\)*\"\\|[- ()a-zA-Z0-9]+\\)]")
773 (setq found (assoc (buffer-substring (match-beginning 1)
775 calc-embedded-mode-vars))
776 (or (assq (cdr found) pmodes)
777 (setq pmodes (cons (cons (cdr found)
778 (car (read-from-string
783 (and (looking-at "edit-mode: *\\([-a-z]+\\): *\\(\"\\([^\"\n\\]\\|\\\\.\\)*\"\\|[- ()a-zA-Z0-9]+\\)]")
784 (setq found (assoc (buffer-substring (match-beginning 1)
786 calc-embedded-mode-vars))
787 (or (assq (cdr found) emodes)
788 (setq emodes (cons (cons (cdr found)
789 (car (read-from-string
794 (and (looking-at "defaults]")
795 (setq no-defaults nil)))
798 (unless (assq 'math-embed-the-language modes)
799 (let ((lang (assoc major-mode calc-language-alist)))
801 (setq modes (cons (cons 'math-embed-the-language (cdr lang))
803 (list modes emodes pmodes)))
805 ;; The variable calc-embed-vars-used is local to calc-embedded-make-info,
806 ;; calc-embedded-evaluate-expr and calc-embedded-update, but is
807 ;; used by calc-embedded-find-vars, which is called by the above functions.
808 (defvar calc-embed-vars-used)
810 (defun calc-embedded-make-info (point cbuf fresh &optional
811 calc-embed-top calc-embed-bot
812 calc-embed-outer-top calc-embed-outer-bot)
813 (let* ((bufentry (assq (current-buffer) calc-embedded-active))
815 (force (and fresh calc-embed-top (null (equal calc-embed-top '(t)))))
816 (fixed calc-embed-top)
821 (setq found (list (current-buffer))
822 calc-embedded-active (cons found calc-embedded-active)
823 calc-embedded-firsttime-buf t)
824 (let ((newann (assoc major-mode calc-embedded-announce-formula-alist))
825 (newform (assoc major-mode calc-embedded-open-close-formula-alist))
826 (newword (assoc major-mode calc-embedded-word-regexp-alist))
827 (newplain (assoc major-mode calc-embedded-open-close-plain-alist))
829 (assoc major-mode calc-embedded-open-close-new-formula-alist))
830 (newmode (assoc major-mode calc-embedded-open-close-mode-alist)))
832 (make-local-variable 'calc-embedded-announce-formula)
833 (setq calc-embedded-announce-formula (cdr newann)))
835 (make-local-variable 'calc-embedded-open-formula)
836 (make-local-variable 'calc-embedded-close-formula)
837 (setq calc-embedded-open-formula (nth 0 (cdr newform)))
838 (setq calc-embedded-close-formula (nth 1 (cdr newform))))
840 (make-local-variable 'calc-embedded-word-regexp)
841 (setq calc-embedded-word-regexp (nth 1 newword)))
843 (make-local-variable 'calc-embedded-open-plain)
844 (make-local-variable 'calc-embedded-close-plain)
845 (setq calc-embedded-open-plain (nth 0 (cdr newplain)))
846 (setq calc-embedded-close-plain (nth 1 (cdr newplain))))
848 (make-local-variable 'calc-embedded-open-new-formula)
849 (make-local-variable 'calc-embedded-close-new-formula)
850 (setq calc-embedded-open-new-formula (nth 0 (cdr newnewform)))
851 (setq calc-embedded-close-new-formula (nth 1 (cdr newnewform))))
853 (make-local-variable 'calc-embedded-open-mode)
854 (make-local-variable 'calc-embedded-close-mode)
855 (setq calc-embedded-open-mode (nth 0 (cdr newmode)))
856 (setq calc-embedded-close-mode (nth 1 (cdr newmode)))))))
857 (while (and (cdr found)
858 (> point (aref (car (cdr found)) 3)))
859 (setq found (cdr found)))
861 (>= point (aref (nth 1 found) 2)))
862 (setq info (nth 1 found))
863 (setq calc-embedded-firsttime-formula t)
864 (setq info (make-vector 16 nil)
867 (aset info 0 (current-buffer))
868 (aset info 1 (or cbuf (save-excursion
872 (or (integerp calc-embed-top) (equal calc-embed-top '(4)))
873 (not calc-embed-bot))
874 ; started with a user-supplied argument
876 (if (equal calc-embed-top '(4))
878 (aset info 2 (copy-marker (line-beginning-position)))
879 (aset info 3 (copy-marker (line-end-position))))
880 (if (= (setq calc-embed-arg (prefix-numeric-value calc-embed-arg)) 0)
882 (aset info 2 (copy-marker (region-beginning)))
883 (aset info 3 (copy-marker (region-end))))
884 (aset info (if (> calc-embed-arg 0) 2 3) (point-marker))
885 (if (> calc-embed-arg 0)
887 (forward-line (1- calc-embed-arg))
889 (forward-line (1+ calc-embed-arg)))
890 (aset info (if (> calc-embed-arg 0) 3 2) (point-marker))))
891 (aset info 4 (copy-marker (aref info 2)))
892 (aset info 5 (copy-marker (aref info 3))))
894 (setq calc-embed-top (aref info 2)
895 fixed calc-embed-top)
896 (if (consp calc-embed-top)
899 (if (thing-at-point-looking-at calc-embedded-word-regexp)
901 (setq calc-embed-top (copy-marker (match-beginning 0)))
902 (setq calc-embed-bot (copy-marker (match-end 0)))
903 (setq calc-embed-outer-top calc-embed-top)
904 (setq calc-embed-outer-bot calc-embed-bot))
905 (setq calc-embed-top (point-marker))
906 (setq calc-embed-bot (point-marker))
907 (setq calc-embed-outer-top calc-embed-top)
908 (setq calc-embed-outer-bot calc-embed-bot)))
910 (calc-embedded-find-bounds 'plain)))
911 (aset info 2 (copy-marker (min calc-embed-top calc-embed-bot)))
912 (aset info 3 (copy-marker (max calc-embed-top calc-embed-bot)))
913 (aset info 4 (copy-marker (or calc-embed-outer-top (aref info 2))))
914 (aset info 5 (copy-marker (or calc-embed-outer-bot (aref info 3))))))
915 (goto-char (aref info 2))
918 (or (bolp) (aset info 7 t))
919 (goto-char (aref info 3))
920 (or (bolp) (eolp) (aset info 7 t))))
922 (let ((modes (calc-embedded-find-modes)))
923 (aset info 12 (car modes))
924 (aset info 13 (nth 1 modes))
925 (aset info 14 (nth 2 modes))))
926 (aset info 15 calc-embedded-globals)
927 (setq str (buffer-substring (aref info 2) (aref info 3)))
929 (not (equal str (aref info 6))))
930 (if (and fixed (aref info 6))
933 (calc-embedded-make-info point cbuf nil)
935 (let* ((open-plain calc-embedded-open-plain)
936 (close-plain calc-embedded-close-plain)
937 (pref-len (length open-plain))
938 (calc-embed-vars-used nil)
940 (with-current-buffer (aref info 1)
941 (calc-embedded-set-modes (aref info 15)
942 (aref info 12) (aref info 14))
943 (if (and (> (length str) pref-len)
944 (equal (substring str 0 pref-len) open-plain)
945 (setq suff-pos (string-match (regexp-quote close-plain)
947 (setq val (math-read-plain-expr
948 (substring str pref-len suff-pos)))
949 (if (string-match "[^ \t\n]" str)
951 val (condition-case nil
952 (math-read-big-expr str)
953 (error (math-read-expr str))))
955 (if (eq (car-safe val) 'error)
956 (setq val (list 'error
957 (+ (aref info 2) pref-len (nth 1 val))
962 (if (eq (car-safe temp) 'calcFunc-evalto)
963 (setq temp (nth 1 temp))
964 (if (eq (car-safe temp) 'error)
967 (setcdr found (delq info (cdr found)))
968 (calc-embedded-active-state 'less))))
969 (aset info 9 (and (eq (car-safe temp) 'calcFunc-assign)
971 (if (memq (car-safe val) '(calcFunc-evalto calcFunc-assign))
972 (calc-embedded-find-vars val))
973 (aset info 10 calc-embed-vars-used)
974 (aset info 11 nil))))
977 (setcdr found (cons info (cdr found)))
978 (calc-embedded-active-state 'more)))
981 (defun calc-embedded-find-vars (x)
982 (cond ((Math-primp x)
983 (and (eq (car-safe x) 'var)
984 (not (assoc x calc-embed-vars-used))
985 (setq calc-embed-vars-used (cons (list x) calc-embed-vars-used))))
986 ((eq (car x) 'calcFunc-evalto)
987 (calc-embedded-find-vars (nth 1 x)))
988 ((eq (car x) 'calcFunc-assign)
989 (calc-embedded-find-vars (nth 2 x)))
991 (and (eq (car x) 'calcFunc-subscr)
992 (eq (car-safe (nth 1 x)) 'var)
993 (Math-primp (nth 2 x))
994 (not (assoc x calc-embed-vars-used))
995 (setq calc-embed-vars-used (cons (list x) calc-embed-vars-used)))
996 (while (setq x (cdr x))
997 (calc-embedded-find-vars (car x))))))
999 (defvar math-ms-args)
1000 (defun calc-embedded-evaluate-expr (x)
1001 (let ((calc-embed-vars-used (aref calc-embedded-info 10)))
1002 (or calc-embed-vars-used (calc-embedded-find-vars x))
1003 (if calc-embed-vars-used
1004 (let ((active (assq (aref calc-embedded-info 0) calc-embedded-active))
1007 (calc-embedded-original-buffer t)
1010 (calc-embedded-activate)
1011 (setq active (assq (aref calc-embedded-info 0)
1012 calc-embedded-active))))
1013 (while calc-embed-vars-used
1014 (calc-embedded-eval-get-var (car (car calc-embed-vars-used)) active)
1015 (setq calc-embed-vars-used (cdr calc-embed-vars-used))))
1016 (calc-embedded-subst x))
1017 (calc-normalize (math-evaluate-expr-rec x)))))
1019 (defun calc-embedded-subst (x)
1020 (if (and (eq (car-safe x) 'calcFunc-evalto) (cdr x))
1021 (let ((rhs (calc-embedded-subst (nth 1 x))))
1022 (list 'calcFunc-evalto
1024 (if (eq (car-safe rhs) 'calcFunc-assign) (nth 2 rhs) rhs)))
1025 (if (and (eq (car-safe x) 'calcFunc-assign) (= (length x) 3))
1026 (list 'calcFunc-assign
1028 (calc-embedded-subst (nth 2 x)))
1029 (calc-normalize (math-evaluate-expr-rec (math-multi-subst-rec x))))))
1031 (defun calc-embedded-eval-get-var (var base)
1033 (point (aref calc-embedded-info 2))
1036 (while (and (setq entry (cdr entry))
1037 (or (not (equal var (aref (car entry) 9)))
1038 (and (> point (aref (car entry) 3))
1039 (setq last entry)))))
1044 (setq entry (car entry))
1045 (if (equal (buffer-substring (aref entry 2) (aref entry 3))
1050 (calc-embedded-update entry 14 t nil)))
1051 (setq val (aref entry 11))
1052 (if (eq (car-safe val) 'calcFunc-evalto)
1053 (setq val (nth 2 val)))
1054 (if (eq (car-safe val) 'calcFunc-assign)
1055 (setq val (nth 2 val)))
1056 (setq math-ms-args (cons (cons var val) math-ms-args)))
1057 (calc-embedded-activate)
1058 (calc-embedded-eval-get-var var base))))))
1061 (defun calc-embedded-update (info which need-eval need-display
1062 &optional str entry old-val)
1063 (let* ((calc-embed-prev-modes nil)
1064 (open-plain calc-embedded-open-plain)
1065 (close-plain calc-embedded-close-plain)
1066 (calc-embed-vars-used nil)
1069 (old-eval (aref info 11)))
1070 (or old-val (setq old-val val))
1071 (if (eq (car-safe val) 'calcFunc-evalto)
1072 (setq need-display t))
1075 (set-buffer (aref info 1))
1077 (calc-embedded-set-modes (aref info 15) (aref info 12)
1079 (if need-display 'full t)))
1080 (if (memq (car-safe val) '(calcFunc-evalto calcFunc-assign))
1081 (calc-embedded-find-vars val))
1083 (let ((calc-embedded-info info))
1084 (setq val (math-evaluate-expr val)
1086 (if (or (eq need-eval 'eval) (eq (car-safe val) 'calcFunc-evalto))
1089 (aset info 10 calc-embed-vars-used)
1091 (if (or need-display (eq (car-safe val) 'calcFunc-evalto))
1092 (let ((extra (if (eq calc-language 'big) 1 0)))
1093 (or entry (setq entry (list val 1 nil)))
1095 (setq str (let ((calc-line-numbering nil))
1096 (math-format-stack-value entry)))
1097 (if (eq calc-language 'big)
1098 (setq str (substring str 0 -1)))))
1099 (and calc-show-plain
1100 (setq str (concat open-plain
1101 (math-showing-full-precision
1102 (math-format-flat-expr val 0))
1106 (calc-embedded-original-buffer t info)
1107 (or (equal str (aref info 6))
1108 (let ((delta (- (aref info 5) (aref info 3)))
1110 (buffer-read-only nil))
1111 (goto-char (aref info 2))
1112 (delete-region (point) (aref info 3))
1113 (and (> (nth 1 entry) (1+ extra))
1116 (delete-horizontal-space)
1117 (if (looking-at "\n")
1118 ;; If there's a newline there, don't add one
1121 (delete-horizontal-space)
1123 (backward-char 1))))
1125 (set-marker (aref info 3) (+ (point) adjbot))
1126 (set-marker (aref info 5) (+ (point) delta))
1127 (aset info 6 str))))))
1128 (if (eq (car-safe val) 'calcFunc-evalto)
1130 (setq evalled (nth 2 val)
1132 (if (eq (car-safe val) 'calcFunc-assign)
1134 (aset info 9 (nth 1 val))
1135 (aset info 11 (or evalled
1136 (let ((calc-embedded-info info))
1137 (math-evaluate-expr (nth 2 val)))))
1138 (or (equal old-eval (aref info 11))
1139 (calc-embedded-var-change (nth 1 val) (aref info 0))))
1140 (if (eq (car-safe old-val) 'calcFunc-evalto)
1141 (setq old-val (nth 1 old-val)))
1142 (if (eq (car-safe old-val) 'calcFunc-assign)
1143 (calc-embedded-var-change (nth 1 old-val) (aref info 0)))))
1144 (set-buffer (aref info 1))
1145 (while calc-embed-prev-modes
1146 (cond ((eq (car (car calc-embed-prev-modes)) 'math-embed-the-language)
1148 (calc-embedded-set-language (cdr (car calc-embed-prev-modes)))))
1149 ((eq (car (car calc-embed-prev-modes)) 'math-embed-the-display-just)
1151 (calc-embedded-set-justify (cdr (car calc-embed-prev-modes)))))
1153 (set (car (car calc-embed-prev-modes))
1154 (cdr (car calc-embed-prev-modes)))))
1155 (setq calc-embed-prev-modes (cdr calc-embed-prev-modes))))))
1160 ;;; These are hooks called by the main part of Calc.
1162 (defvar calc-embedded-no-reselect nil)
1163 (defun calc-embedded-select-buffer ()
1164 (if (eq (current-buffer) (aref calc-embedded-info 0))
1165 (let ((info calc-embedded-info)
1167 (if (and (or (< (point) (aref info 4))
1168 (> (point) (aref info 5)))
1169 (not calc-embedded-no-reselect))
1170 (let ((calc-embedded-quiet t))
1171 (message "(Switching Calc Embedded mode to new formula.)")
1173 (calc-embedded nil)))
1174 (setq horiz (max (min (current-column) (- (point) (aref info 2))) 0)
1175 vert (if (<= (aref info 2) (point))
1176 (- (count-lines (aref info 2) (point))
1179 (set-buffer (aref info 1))
1183 (setq vert (1- vert))))
1184 (calc-cursor-stack-index 1)
1185 (if calc-line-numbering
1186 (setq horiz (+ horiz 4)))
1188 (forward-line vert))
1189 (forward-char (min horiz
1190 (- (point-max) (point)))))
1191 (calc-select-buffer)))
1193 (defun calc-embedded-finish-command ()
1194 (let ((buf (current-buffer))
1196 (with-current-buffer (aref calc-embedded-info 1)
1197 (if (> (calc-stack-size) 0)
1199 (col (current-column))
1201 (calc-cursor-stack-index 0)
1204 (calc-cursor-stack-index 1)
1207 (setq horiz (- col (if calc-line-numbering 4 0))
1208 vert (- (count-lines (point) pt)
1211 (setq vert (max 1 (1+ vert))))))))
1215 (set-buffer (aref calc-embedded-info 0))
1216 (goto-char (aref calc-embedded-info 2))
1218 (forward-line vert))
1219 (forward-char (max horiz 0))
1220 (set-buffer buf)))))
1222 (defun calc-embedded-stack-change ()
1223 (or calc-executing-macro
1224 (with-current-buffer (aref calc-embedded-info 1)
1225 (let* ((info calc-embedded-info)
1226 (extra-line (if (eq calc-language 'big) 1 0))
1227 (empty (= (calc-stack-size) 0))
1229 (list '(var empty var-empty) 1 nil)
1230 (calc-top 1 'entry)))
1231 (old-val (aref info 8))
1236 (calc-cursor-stack-index 1)
1238 (calc-cursor-stack-index 0)
1239 (setq bot (- (point) extra-line))
1240 (setq str (buffer-substring top (- bot 1))))
1241 (if calc-line-numbering
1243 (setq str (substring str 4))
1244 (while (setq pos (string-match "\n...." str pos))
1245 (setq str (concat (substring str 0 (1+ pos))
1246 (substring str (+ pos 5)))
1248 (calc-embedded-original-buffer t)
1249 (aset info 8 (car entry))
1250 (calc-embedded-update info 13 nil t str entry old-val)))))
1252 (defun calc-embedded-mode-line-change ()
1253 (let ((str mode-line-buffer-identification))
1255 (calc-embedded-original-buffer t)
1256 (setq mode-line-buffer-identification str)
1257 (set-buffer-modified-p (buffer-modified-p)))))
1259 (defun calc-embedded-modes-change (vars)
1260 (if (eq (car vars) 'calc-language) (setq vars '(math-embed-the-language)))
1261 (if (eq (car vars) 'calc-display-just) (setq vars '(math-embed-the-display-just)))
1263 (not (rassq (car vars) calc-embedded-mode-vars)))
1264 (setq vars (cdr vars)))
1265 (if (and vars calc-mode-save-mode (not (eq calc-mode-save-mode 'save)))
1267 (let* ((save-mode calc-mode-save-mode)
1268 (header (if (eq save-mode 'local)
1270 (format "calc-%s-mode:" save-mode)))
1271 (math-embed-the-language (calc-embedded-language))
1272 (math-embed-the-display-just (calc-embedded-justify))
1273 (values (mapcar 'symbol-value vars))
1274 (num (cond ((eq save-mode 'local) 12)
1275 ((eq save-mode 'edit) 13)
1276 ((eq save-mode 'perm) 14)
1278 base limit mname mlist)
1279 (calc-embedded-original-buffer t)
1281 (if (eq save-mode 'global)
1282 (setq base (point-max)
1284 mlist calc-embedded-globals)
1285 (goto-char (aref calc-embedded-info 4))
1288 limit (max (- (point) 1000) (point-min))
1289 mlist (and num (aref calc-embedded-info num)))
1290 (and (re-search-backward
1291 (format "\\(%s\\)[^\001]*\\(%s\\)\\|\\[calc-defaults]"
1292 calc-embedded-open-formula
1293 calc-embedded-close-formula) limit t)
1294 (setq limit (point))))
1297 (if (setq mname (car (rassq (car vars)
1298 calc-embedded-mode-vars)))
1299 (let ((buffer-read-only nil)
1300 (found (assq (car vars) mlist)))
1302 (setcdr found (car values))
1303 (setq mlist (cons (cons (car vars) (car values)) mlist))
1305 (aset calc-embedded-info num mlist)
1306 (if (eq save-mode 'global)
1307 (setq calc-embedded-globals mlist))))
1308 (if (re-search-backward
1309 (format "\\[%s *%s: *\\(\"\\([^\"\n\\]\\|\\\\.\\)*\"\\|[- ()a-zA-Z0-9]+\\)]"
1313 (goto-char (match-beginning 1))
1314 (delete-region (point) (match-end 1))
1315 (insert (prin1-to-string (car values))))
1317 (insert-before-markers
1318 calc-embedded-open-mode
1319 "[" header " " mname ": "
1320 (prin1-to-string (car values)) "]"
1321 calc-embedded-close-mode))))
1322 (setq vars (cdr vars)
1323 values (cdr values))))))
1324 (when (and vars (eq calc-mode-save-mode 'save))
1325 (calc-embedded-save-original-modes))))
1327 (defun calc-embedded-var-change (var &optional buf)
1329 (setq var (list 'var
1330 (if (string-match "\\`var-.+\\'"
1332 (intern (substring (symbol-name var) 4))
1336 (let ((manual (not calc-auto-recompute))
1337 (bp calc-embedded-active)
1339 (if buf (setq bp (memq (assq buf bp) bp)))
1341 (let ((calc-embedded-no-reselect t)
1342 (p (and (buffer-name (car (car bp)))
1345 (if (assoc var (aref (car p) 10))
1347 (if (aref (car p) 11)
1349 (aset (car p) 11 nil)
1350 (if (aref (car p) 9)
1351 (calc-embedded-var-change (aref (car p) 9)))))
1352 (set-buffer (aref (car p) 0))
1353 (if (equal (buffer-substring (aref (car p) 2)
1356 (let ((calc-embedded-info nil))
1357 (or calc-embedded-quiet
1358 (message "Recomputing..."))
1361 (set-buffer (aref (car p) 0))
1362 (calc-embedded-update (car p) 14 t nil)))
1363 (setcdr (car bp) (delq (car p) (cdr (car bp))))
1365 "(Tried to recompute but formula was changed or missing)"))))
1367 (setq bp (if buf nil (cdr bp))))
1368 (or first calc-embedded-quiet (message "")))))
1370 (provide 'calc-embed)
1373 ;; generated-autoload-file: "calc-loaddefs.el"
1376 ;;; calc-embed.el ends here