summaryrefslogtreecommitdiff
path: root/lisp/calc
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2005-06-06 02:39:45 +0000
committerMiles Bader <miles@gnu.org>2005-06-06 02:39:45 +0000
commitfdffd346262841cb194225ea0acd8059c57ec2d4 (patch)
treed8b3699131f7d1b94bc46c7d8be62af6b8b5ebfe /lisp/calc
parenta5c508fe3a3f456c987283156315d0384d38fe9e (diff)
parenta9b4333620eb259e974445066a8e64cee0c21d69 (diff)
downloademacs-fdffd346262841cb194225ea0acd8059c57ec2d4.tar.gz
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-57
Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 324-352) - Merge from gnus--rel--5.10 - Update from CVS - etc/emacs-buffer.gdb: Remove RCS keywords * gnus--rel--5.10 (patch 70-79) - Update from CVS - Merge from emacs--cvs-trunk--0
Diffstat (limited to 'lisp/calc')
-rw-r--r--lisp/calc/calc-aent.el3
-rw-r--r--lisp/calc/calc-embed.el58
-rw-r--r--lisp/calc/calc-ext.el6
-rw-r--r--lisp/calc/calc-misc.el2
-rw-r--r--lisp/calc/calc-prog.el25
-rw-r--r--lisp/calc/calc-stuff.el1
-rw-r--r--lisp/calc/calc-yank.el2
-rw-r--r--lisp/calc/calc.el79
-rw-r--r--lisp/calc/calcalg2.el2
9 files changed, 105 insertions, 73 deletions
diff --git a/lisp/calc/calc-aent.el b/lisp/calc/calc-aent.el
index b947b597acf..8af03c4d206 100644
--- a/lisp/calc/calc-aent.el
+++ b/lisp/calc/calc-aent.el
@@ -947,6 +947,9 @@ in Calc algebraic input.")
first nil))
x))
+;; calc-arg-values is defined in calc-ext.el, but is used here.
+(defvar calc-arg-values)
+
(defun calc-check-user-syntax (&optional x prec)
(let ((p calc-user-parse-table)
(matches nil)
diff --git a/lisp/calc/calc-embed.el b/lisp/calc/calc-embed.el
index 6b94cd0af0c..c6e0e33e559 100644
--- a/lisp/calc/calc-embed.el
+++ b/lisp/calc/calc-embed.el
@@ -192,8 +192,15 @@
(defvar calc-embed-top)
(defvar calc-embed-bot)
+;; The variable calc-embed-arg is local to calc-do-embedded,
+;; calc-embedded-update-formula, calc-embedded-edit and
+;; calc-do-embedded-activate, but is used by
+;; calc-embedded-make-info, which is called by the above
+;; functions.
+(defvar calc-embed-arg)
+
(defvar calc-embedded-quiet nil)
-(defun calc-do-embedded (arg end obeg oend)
+(defun calc-do-embedded (calc-embed-arg end obeg oend)
(if calc-embedded-info
;; Turn embedded mode off or switch to a new buffer.
@@ -237,7 +244,7 @@
(buffer-name)))
(keyboard-quit))
(calc-embedded nil)))
- (calc-embedded arg end obeg oend)))
+ (calc-embedded calc-embed-arg end obeg oend)))
;; Turn embedded mode on.
(calc-plain-buffer-only)
@@ -250,7 +257,8 @@
(calc-embedded-save-original-modes)
(or calc-embedded-globals
(calc-find-globals))
- (setq info (calc-embedded-make-info (point) nil t arg end obeg oend))
+ (setq info
+ (calc-embedded-make-info (point) nil t calc-embed-arg end obeg oend))
(if (eq (car-safe (aref info 8)) 'error)
(progn
(setq calc-embedded-original-modes nil)
@@ -311,13 +319,13 @@
(calc-select-part 2)))
-(defun calc-embedded-update-formula (arg)
+(defun calc-embedded-update-formula (calc-embed-arg)
(interactive "P")
- (if arg
+ (if calc-embed-arg
(let ((entry (assq (current-buffer) calc-embedded-active)))
(while (setq entry (cdr entry))
(and (eq (car-safe (aref (car entry) 8)) 'calcFunc-evalto)
- (or (not (consp arg))
+ (or (not (consp calc-embed-arg))
(and (<= (aref (car entry) 2) (region-beginning))
(>= (aref (car entry) 3) (region-end))))
(save-excursion
@@ -337,9 +345,9 @@
(goto-char (+ (aref info 4) pt))))))))
-(defun calc-embedded-edit (arg)
+(defun calc-embedded-edit (calc-embed-arg)
(interactive "P")
- (let ((info (calc-embedded-make-info (point) nil t arg))
+ (let ((info (calc-embedded-make-info (point) nil t calc-embed-arg))
str)
(if (eq (car-safe (aref info 8)) 'error)
(progn
@@ -374,12 +382,12 @@
(aset info 8 val)
(calc-embedded-update info 14 t t))))
-(defun calc-do-embedded-activate (arg cbuf)
+(defun calc-do-embedded-activate (calc-embed-arg cbuf)
(calc-plain-buffer-only)
- (if arg
+ (if calc-embed-arg
(calc-embedded-forget))
(calc-find-globals)
- (if (< (prefix-numeric-value arg) 0)
+ (if (< (prefix-numeric-value calc-embed-arg) 0)
(message "Deactivating %s for Calc Embedded mode" (buffer-name))
(message "Activating %s for Calc Embedded mode..." (buffer-name))
(save-excursion
@@ -432,7 +440,7 @@
(defun calc-embedded-word ()
(interactive)
- (calc-embedded '(4)))
+ (calc-embedded '(t)))
(defun calc-embedded-mark-formula (&optional body-only)
"Put point at the beginning of this Calc formula, mark at the end.
@@ -799,16 +807,26 @@ The command \\[yank] can retrieve it from there."
(aset info 1 (or cbuf (save-excursion
(calc-create-buffer)
(current-buffer)))))
- (if (and (integerp calc-embed-top) (not calc-embed-bot))
+ (if (and
+ (or (integerp calc-embed-top) (equal calc-embed-top '(4)))
+ (not calc-embed-bot))
; started with a user-supplied argument
(progn
- (if (= (setq arg (prefix-numeric-value arg)) 0)
- (progn
- (aset info 2 (copy-marker (region-beginning)))
- (aset info 3 (copy-marker (region-end))))
- (aset info (if (> arg 0) 2 3) (point-marker))
- (forward-line arg)
- (aset info (if (> arg 0) 3 2) (point-marker)))
+ (if (equal calc-embed-top '(4))
+ (progn
+ (aset info 2 (copy-marker (line-beginning-position)))
+ (aset info 3 (copy-marker (line-end-position))))
+ (if (= (setq calc-embed-arg (prefix-numeric-value calc-embed-arg)) 0)
+ (progn
+ (aset info 2 (copy-marker (region-beginning)))
+ (aset info 3 (copy-marker (region-end))))
+ (aset info (if (> calc-embed-arg 0) 2 3) (point-marker))
+ (if (> calc-embed-arg 0)
+ (progn
+ (forward-line (1- calc-embed-arg))
+ (end-of-line))
+ (forward-line (1+ calc-embed-arg)))
+ (aset info (if (> calc-embed-arg 0) 3 2) (point-marker))))
(aset info 4 (copy-marker (aref info 2)))
(aset info 5 (copy-marker (aref info 3))))
(if (aref info 4)
diff --git a/lisp/calc/calc-ext.el b/lisp/calc/calc-ext.el
index adbdf7a96e2..0b177b06dc4 100644
--- a/lisp/calc/calc-ext.el
+++ b/lisp/calc/calc-ext.el
@@ -43,6 +43,9 @@
(defvar math-comp-sel-cpos nil)
(defvar math-compose-hash-args nil)
+(defvar calc-alg-map)
+(defvar calc-alg-esc-map)
+
;;; The following was made a function so that it could be byte-compiled.
(defun calc-init-extensions ()
@@ -1192,8 +1195,9 @@ calc-kill calc-kill-region calc-yank))))
(math-normalize val)))))
+(defvar calc-help-map nil)
-(if (boundp 'calc-help-map)
+(if calc-help-map
nil
(setq calc-help-map (make-keymap))
(define-key calc-help-map "b" 'calc-describe-bindings)
diff --git a/lisp/calc/calc-misc.el b/lisp/calc/calc-misc.el
index e8bdfe2fa5a..ce0da11ecaa 100644
--- a/lisp/calc/calc-misc.el
+++ b/lisp/calc/calc-misc.el
@@ -160,7 +160,7 @@ Calc user interface as before (either M-# C or M-# K; initially M-# C)."
"Go to a node in the Calculator info documentation."
(interactive)
(select-window (get-largest-window))
- (Info-goto-node (concat "(Calc)" node)))
+ (info (concat "(Calc)" node)))
(defun calc-tutorial ()
"Run the Emacs Info system on the Calculator Tutorial."
diff --git a/lisp/calc/calc-prog.el b/lisp/calc/calc-prog.el
index 230b0f6a6c5..8d2fba7fef0 100644
--- a/lisp/calc/calc-prog.el
+++ b/lisp/calc/calc-prog.el
@@ -702,7 +702,7 @@
(get func 'calc-user-defn)))
(kys (concat "z" (char-to-string (car def))))
(intcmd (symbol-name (cdr def)))
- (algcmd (substring (symbol-name func) 9)))
+ (algcmd (if func (substring (symbol-name func) 9) "")))
(if (and defn (calc-valid-formula-func func))
(let ((niceexpr (math-format-nice-expr defn (frame-width))))
(calc-wrapper
@@ -1446,15 +1446,22 @@ Redefine the corresponding command."
(error "Unbalanced Z' in keyboard macro")))
-(defun calc-kbd-report (msg)
- (interactive "sMessage: ")
- (calc-wrapper
- (math-working msg (calc-top-n 1))))
+;; (defun calc-kbd-report (msg)
+;; (interactive "sMessage: ")
+;; (calc-wrapper
+;; (math-working msg (calc-top-n 1))))
-(defun calc-kbd-query (msg)
- (interactive "sPrompt: ")
- (calc-wrapper
- (calc-alg-entry nil (and (not (equal msg "")) msg))))
+(defun calc-kbd-query ()
+ (interactive)
+ (let ((defining-kbd-macro nil)
+ (executing-kbd-macro nil)
+ (msg (calc-top 1)))
+ (if (not (eq (car-safe msg) 'vec))
+ (error "No prompt string provided")
+ (setq msg (math-vector-to-string msg))
+ (calc-wrapper
+ (calc-pop-stack 1)
+ (calc-alg-entry nil (and (not (equal msg "")) msg))))))
;;;; Logical operations.
diff --git a/lisp/calc/calc-stuff.el b/lisp/calc/calc-stuff.el
index c6e8d8bbf27..0564e39ed57 100644
--- a/lisp/calc/calc-stuff.el
+++ b/lisp/calc/calc-stuff.el
@@ -171,6 +171,7 @@ With a prefix, push that prefix as a number onto the stack."
(defvar math-max-digits-cache) ; calc-bin.el
(defvar math-integral-cache) ; calcalg2.el
(defvar math-units-table) ; calc-units.el
+(defvar math-decls-cache-tag) ; calc-arith.el
(defvar math-format-date-cache) ; calc-forms.el
(defvar math-holidays-cache-tag) ; calc-forms.el
diff --git a/lisp/calc/calc-yank.el b/lisp/calc/calc-yank.el
index 84c117a1723..1544e8956c1 100644
--- a/lisp/calc/calc-yank.el
+++ b/lisp/calc/calc-yank.el
@@ -447,7 +447,7 @@ To cancel the edit, simply kill the *Calc Edit* buffer."
(setq truncate-lines nil)
(setq major-mode 'calc-edit-mode)
(setq mode-name "Calc Edit")
- (run-hooks 'calc-edit-mode-hook)
+ (run-mode-hooks 'calc-edit-mode-hook)
(make-local-variable 'calc-original-buffer)
(setq calc-original-buffer oldbuf)
(make-local-variable 'calc-return-buffer)
diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el
index 173785dc912..3a99291fdef 100644
--- a/lisp/calc/calc.el
+++ b/lisp/calc/calc.el
@@ -209,7 +209,8 @@
(defgroup calc nil
"GNU Calc"
:prefix "calc-"
- :tag "Calc")
+ :tag "Calc"
+ :group 'applications)
;;;###autoload
(defcustom calc-settings-file
@@ -324,7 +325,7 @@ This is not required to be present for user-written mode annotations."
:type '(choice (string) (sexp)))
(defvar calc-bug-address "belanger@truman.edu"
- "Address of the author of Calc, for use by `report-calc-bug'.")
+ "Address of the maintainer of Calc, for use by `report-calc-bug'.")
(defvar calc-scan-for-dels t
"If t, scan keymaps to find all DEL-like keys.
@@ -719,6 +720,12 @@ If nil, selections displayed but ignored.")
(defvar calc-load-hook nil
"Hook run when calc.el is loaded.")
+(defvar calc-window-hook nil
+ "Hook called to create the Calc window.")
+
+(defvar calc-trail-window-hook nil
+ "Hook called to create the Calc trail window.")
+
;; Verify that Calc is running on the right kind of system.
(defvar calc-emacs-type-lucid (not (not (string-match "Lucid" emacs-version))))
@@ -830,20 +837,6 @@ If nil, selections displayed but ignored.")
(defvar var-gamma '(special-const (math-gamma-const)))
(defvar var-Modes '(special-const (math-get-modes-vec)))
-(defvar calc-language-alist
- '((latex-mode . latex)
- (tex-mode . tex)
- (plain-tex-mode . tex)
- (context-mode . tex)
- (nroff-mode . eqn)
- (pascal-mode . pascal)
- (c-mode . c)
- (c++-mode . c)
- (fortran-mode . fortran)
- (f90-mode . fortran))
- "Alist of major modes with appropriate Calc languages.")
-
-
(mapcar (lambda (v) (or (boundp v) (set v nil)))
calc-local-var-list)
@@ -1066,7 +1059,7 @@ If nil, selections displayed but ignored.")
(use-global-map glob)
(use-local-map loc)))))
-
+(defvar calc-alg-map) ; Defined in calc-ext.el
(defun calc-mode ()
"Calculator major mode.
@@ -1131,7 +1124,7 @@ Notations: 3.14e6 3.14 * 10^6
(string-match "full" (nth 1 p))
(setq calc-standalone-flag t))
(setq p (cdr p))))
- (run-hooks 'calc-mode-hook)
+ (run-mode-hooks 'calc-mode-hook)
(calc-refresh t)
(calc-set-mode-line)
(calc-check-defines))
@@ -1181,7 +1174,7 @@ commands given here will actually operate on the *Calculator* stack."
(insert (propertize (concat "Emacs Calculator v" calc-version
" by Dave Gillespie\n")
'font-lock-face 'italic))))
- (run-hooks 'calc-trail-mode-hook))
+ (run-mode-hooks 'calc-trail-mode-hook))
(defun calc-create-buffer ()
(set-buffer (get-buffer-create "*Calculator*"))
@@ -1218,18 +1211,20 @@ commands given here will actually operate on the *Calculator* stack."
(switch-to-buffer (current-buffer) t)
(if (get-buffer-window (current-buffer))
(select-window (get-buffer-window (current-buffer)))
- (let ((w (get-largest-window)))
- (if (and pop-up-windows
- (> (window-height w)
- (+ window-min-height calc-window-height 2)))
- (progn
- (setq w (split-window w
- (- (window-height w)
- calc-window-height 2)
- nil))
- (set-window-buffer w (current-buffer))
- (select-window w))
- (pop-to-buffer (current-buffer))))))
+ (if calc-window-hook
+ (run-hooks 'calc-window-hook)
+ (let ((w (get-largest-window)))
+ (if (and pop-up-windows
+ (> (window-height w)
+ (+ window-min-height calc-window-height 2)))
+ (progn
+ (setq w (split-window w
+ (- (window-height w)
+ calc-window-height 2)
+ nil))
+ (set-window-buffer w (current-buffer))
+ (select-window w))
+ (pop-to-buffer (current-buffer)))))))
(save-excursion
(set-buffer (calc-trail-buffer))
(and calc-display-trail
@@ -1836,15 +1831,17 @@ See calc-keypad for details."
(not (if flag (memq flag '(nil 0)) win)))
(if (null win)
(progn
- (let ((w (split-window nil (/ (* (window-width) 2) 3) t)))
- (set-window-buffer w calc-trail-buffer))
- (calc-wrapper
- (setq overlay-arrow-string calc-trail-overlay
- overlay-arrow-position calc-trail-pointer)
- (or no-refresh
- (if interactive
- (calc-do-refresh)
- (calc-refresh))))))
+ (if calc-trail-window-hook
+ (run-hooks 'calc-trail-window-hook)
+ (let ((w (split-window nil (/ (* (window-width) 2) 3) t)))
+ (set-window-buffer w calc-trail-buffer)))
+ (calc-wrapper
+ (setq overlay-arrow-string calc-trail-overlay
+ overlay-arrow-position calc-trail-pointer)
+ (or no-refresh
+ (if interactive
+ (calc-do-refresh)
+ (calc-refresh))))))
(if win
(progn
(delete-window win)
@@ -3444,7 +3441,7 @@ Also looks for the equivalent TeX words, \\gets and \\evalto."
(defun calc-user-invocation ()
(interactive)
- (unless (stringp calc-invocation-macro)
+ (unless calc-invocation-macro
(error "Use `Z I' inside Calc to define a `M-# Z' keyboard macro"))
(execute-kbd-macro calc-invocation-macro nil))
diff --git a/lisp/calc/calcalg2.el b/lisp/calc/calcalg2.el
index 7e502aa1a87..d139dcf28ba 100644
--- a/lisp/calc/calcalg2.el
+++ b/lisp/calc/calcalg2.el
@@ -202,6 +202,8 @@
(defvar math-deriv-var)
(defvar math-deriv-total)
(defvar math-deriv-symb)
+(defvar math-decls-cache)
+(defvar math-decls-all)
(defun math-derivative (expr)
(cond ((equal expr math-deriv-var)