[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/calc/calc-aent.el [lexbind]
From: |
Miles Bader |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/calc/calc-aent.el [lexbind] |
Date: |
Wed, 08 Dec 2004 19:41:26 -0500 |
Index: emacs/lisp/calc/calc-aent.el
diff -c emacs/lisp/calc/calc-aent.el:1.5.4.4
emacs/lisp/calc/calc-aent.el:1.5.4.5
*** emacs/lisp/calc/calc-aent.el:1.5.4.4 Fri Nov 12 04:21:20 2004
--- emacs/lisp/calc/calc-aent.el Wed Dec 8 23:36:21 2004
***************
*** 3,10 ****
;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
;; Author: Dave Gillespie <address@hidden>
! ;; Maintainers: D. Goel <address@hidden>
! ;; Colin Walters <address@hidden>
;; This file is part of GNU Emacs.
--- 3,9 ----
;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
;; Author: Dave Gillespie <address@hidden>
! ;; Maintainer: Jay Belanger <address@hidden>
;; This file is part of GNU Emacs.
***************
*** 28,40 ****
;;; Code:
;; This file is autoloaded from calc.el.
- (require 'calc)
(require 'calc-macs)
- (eval-when-compile '(require calc-macs))
-
- (defun calc-Need-calc-aent () nil)
-
(defun calc-do-quick-calc ()
(calc-check-defines)
--- 27,35 ----
;;; Code:
;; This file is autoloaded from calc.el.
+ (require 'calc)
(require 'calc-macs)
(defun calc-do-quick-calc ()
(calc-check-defines)
***************
*** 52,71 ****
(entry (calc-do-alg-entry "" "Quick calc: " t))
(alg-exp (mapcar (function
(lambda (x)
! (if (and (not calc-extensions-loaded)
calc-previous-alg-entry
(string-match
"\\`[-0-9._+*/^() ]+\\'"
calc-previous-alg-entry))
(calc-normalize x)
! (calc-extensions)
(math-evaluate-expr x))))
entry)))
(when (and (= (length alg-exp) 1)
(eq (car-safe (car alg-exp)) 'calcFunc-assign)
(= (length (car alg-exp)) 3)
(eq (car-safe (nth 1 (car alg-exp))) 'var))
! (calc-extensions)
(set (nth 2 (nth 1 (car alg-exp))) (nth 2 (car alg-exp)))
(calc-refresh-evaltos (nth 2 (nth 1 (car alg-exp))))
(setq alg-exp (list (nth 2 (car alg-exp)))))
--- 47,66 ----
(entry (calc-do-alg-entry "" "Quick calc: " t))
(alg-exp (mapcar (function
(lambda (x)
! (if (and (not (featurep 'calc-ext))
calc-previous-alg-entry
(string-match
"\\`[-0-9._+*/^() ]+\\'"
calc-previous-alg-entry))
(calc-normalize x)
! (require 'calc-ext)
(math-evaluate-expr x))))
entry)))
(when (and (= (length alg-exp) 1)
(eq (car-safe (car alg-exp)) 'calcFunc-assign)
(= (length (car alg-exp)) 3)
(eq (car-safe (nth 1 (car alg-exp))) 'var))
! (require 'calc-ext)
(set (nth 2 (nth 1 (car alg-exp))) (nth 2 (car alg-exp)))
(calc-refresh-evaltos (nth 2 (nth 1 (car alg-exp))))
(setq alg-exp (list (nth 2 (car alg-exp)))))
***************
*** 92,98 ****
"")
")")))
(if (and (< (length buf) (frame-width)) (= (length entry) 1)
! calc-extensions-loaded)
(let ((long (concat (math-format-value (car entry) 1000)
" => " buf)))
(if (<= (length long) (- (frame-width) 8))
--- 87,93 ----
"")
")")))
(if (and (< (length buf) (frame-width)) (= (length entry) 1)
! (featurep 'calc-ext))
(let ((long (concat (math-format-value (car entry) 1000)
" => " buf)))
(if (<= (length long) (- (frame-width) 8))
***************
*** 148,154 ****
((eq separator 'eval)
(eval str))
((eq separator 'macro)
! (calc-extensions)
(let* ((calc-buffer (current-buffer))
(calc-window (get-buffer-window calc-buffer))
(save-window (selected-window)))
--- 143,149 ----
((eq separator 'eval)
(eval str))
((eq separator 'macro)
! (require 'calc-ext)
(let* ((calc-buffer (current-buffer))
(calc-window (get-buffer-window calc-buffer))
(save-window (selected-window)))
***************
*** 209,215 ****
(and (memq 'clear-message calc-command-flags)
(message ""))
(cond ((eq separator 'pred)
! (calc-extensions)
(if (= (length res) 1)
(math-is-true (car res))
(calc-eval-error '(0 "Single value expected"))))
--- 204,210 ----
(and (memq 'clear-message calc-command-flags)
(message ""))
(cond ((eq separator 'pred)
! (require 'calc-ext)
(if (= (length res) 1)
(math-is-true (car res))
(calc-eval-error '(0 "Single value expected"))))
***************
*** 241,249 ****
res (cdr res)))
buf)))))))))
(defun calc-eval-error (msg)
! (if (and (boundp 'calc-eval-error)
! calc-eval-error)
(if (eq calc-eval-error 'string)
(nth 1 msg)
(error "%s" (nth 1 msg)))
--- 236,249 ----
res (cdr res)))
buf)))))))))
+ (defvar calc-eval-error nil
+ "Determines how calc handles errors.
+ NIL means return a list containing the character position of error.
+ STRING means return error message as string rather than list.
+ T means abort and give an error message.")
+
(defun calc-eval-error (msg)
! (if calc-eval-error
(if (eq calc-eval-error 'string)
(nth 1 msg)
(error "%s" (nth 1 msg)))
***************
*** 272,290 ****
(alg-exp (calc-do-alg-entry initial prompt t)))
(if (stringp alg-exp)
(progn
! (calc-extensions)
(calc-alg-edit alg-exp))
(let* ((calc-simplify-mode (if (eq last-command-char ?\C-j)
'none
calc-simplify-mode))
(nvals (mapcar 'calc-normalize alg-exp)))
(while alg-exp
! (calc-record (if calc-extensions-loaded (car alg-exp) (car nvals))
"alg'")
(calc-pop-push-record-list calc-dollar-used
(and (not (equal (car alg-exp)
(car nvals)))
! calc-extensions-loaded
"")
(list (car nvals)))
(setq alg-exp (cdr alg-exp)
--- 272,290 ----
(alg-exp (calc-do-alg-entry initial prompt t)))
(if (stringp alg-exp)
(progn
! (require 'calc-ext)
(calc-alg-edit alg-exp))
(let* ((calc-simplify-mode (if (eq last-command-char ?\C-j)
'none
calc-simplify-mode))
(nvals (mapcar 'calc-normalize alg-exp)))
(while alg-exp
! (calc-record (if (featurep 'calc-ext) (car alg-exp) (car nvals))
"alg'")
(calc-pop-push-record-list calc-dollar-used
(and (not (equal (car alg-exp)
(car nvals)))
! (featurep 'calc-ext)
"")
(list (car nvals)))
(setq alg-exp (cdr alg-exp)
***************
*** 386,391 ****
--- 386,393 ----
(and (> (length calc-alg-exp) 0) (setq calc-previous-alg-entry
calc-alg-exp))
(exit-minibuffer)))
+ (defvar calc-buffer)
+
(defun calcAlg-enter ()
(interactive)
(let* ((str (minibuffer-contents))
***************
*** 443,448 ****
--- 445,454 ----
((eq last-command-char ?@) "0@ ")
(t (char-to-string last-command-char)))))
+ ;; The variable calc-digit-value is initially declared in calc.el,
+ ;; but can be set by calcDigit-algebraic and calcDigit-edit.
+ (defvar calc-digit-value)
+
(defun calcDigit-algebraic ()
(interactive)
(if (calc-minibuffer-contains "address@hidden *[^'m ]+[^'m]*\\'")
***************
*** 459,478 ****
;;; Algebraic expression parsing. [Public]
! ;;; The next few variables are local to math-read-exprs (and math-read-expr)
! ;;; but are set in functions they call.
(defvar math-exp-pos)
(defvar math-exp-str)
(defvar math-exp-old-pos)
(defvar math-exp-token)
(defvar math-exp-keep-spaces)
(defun math-read-exprs (math-exp-str)
(let ((math-exp-pos 0)
(math-exp-old-pos 0)
(math-exp-keep-spaces nil)
math-exp-token math-expr-data)
(if calc-language-input-filter
(setq math-exp-str (funcall calc-language-input-filter math-exp-str)))
(while (setq math-exp-token (string-match "\\.\\.\\([^.]\\|.[^.]\\)"
math-exp-str))
--- 465,553 ----
;;; Algebraic expression parsing. [Public]
! (defvar math-read-replacement-list
! '(;; Misc symbols
! ("±" "+/-") ; plus or minus
! ("Ã" "*") ; multiplication sign
! ("÷" ":") ; division sign
! ("â" "-") ; subtraction sign
! ("â" "/") ; division sign
! ("â" "*") ; asterisk multiplication
! ("â" "inf") ; infinity symbol
! ("â¤" "<=")
! ("â¥" ">=")
! ("â¦" "<=")
! ("â§" ">=")
! ;; fractions
! ("¼" "(1:4)") ; 1/4
! ("½" "(1:2)") ; 1/2
! ("¾" "(3:4)") ; 3/4
! ("â
" "(1:3)") ; 1/3
! ("â
" "(2:3)") ; 2/3
! ("â
" "(1:5)") ; 1/5
! ("â
" "(2:5)") ; 2/5
! ("â
" "(3:5)") ; 3/5
! ("â
" "(4:5)") ; 4/5
! ("â
" "(1:6)") ; 1/6
! ("â
" "(5:6)") ; 5/6
! ("â
" "(1:8)") ; 1/8
! ("â
" "(3:8)") ; 3/8
! ("â
" "(5:8)") ; 5/8
! ("â
" "(7:8)") ; 7/8
! ("â
" "1:") ; 1/...
! ;; superscripts
! ("â°" "0") ; 0
! ("¹" "1") ; 1
! ("²" "2") ; 2
! ("³" "3") ; 3
! ("â´" "4") ; 4
! ("âµ" "5") ; 5
! ("â¶" "6") ; 6
! ("â·" "7") ; 7
! ("â¸" "8") ; 8
! ("â¹" "9") ; 9
! ("âº" "+") ; +
! ("â»" "-") ; -
! ("â½" "(") ; (
! ("â¾" ")") ; )
! ("â¿" "n") ; n
! ("â±" "i")) ; i
! "A list whose elements (old new) indicate replacements to make
! in Calc algebraic input.")
!
! (defvar math-read-superscripts
! "â°Â¹Â²Â³â´âµâ¶â·â¸â¹âºâ»â½â¾â¿â±" ; 0123456789+-()ni
! "A string consisting of the superscripts allowed by Calc.")
!
! (defun math-read-preprocess-string (str)
! "Replace some substrings of STR by Calc equivalents."
! (setq str
! (replace-regexp-in-string (concat "[" math-read-superscripts "]+")
! "^(\\&)" str))
! (let ((rep-list math-read-replacement-list))
! (while rep-list
! (setq str
! (replace-regexp-in-string (nth 0 (car rep-list))
! (nth 1 (car rep-list)) str))
! (setq rep-list (cdr rep-list))))
! str)
!
! ;; The next few variables are local to math-read-exprs (and math-read-expr
! ;; in calc-ext.el), but are set in functions they call.
(defvar math-exp-pos)
(defvar math-exp-str)
(defvar math-exp-old-pos)
(defvar math-exp-token)
(defvar math-exp-keep-spaces)
+ (defvar math-expr-data)
(defun math-read-exprs (math-exp-str)
(let ((math-exp-pos 0)
(math-exp-old-pos 0)
(math-exp-keep-spaces nil)
math-exp-token math-expr-data)
+ (setq math-exp-str (math-read-preprocess-string math-exp-str))
(if calc-language-input-filter
(setq math-exp-str (funcall calc-language-input-filter math-exp-str)))
(while (setq math-exp-token (string-match "\\.\\.\\([^.]\\|.[^.]\\)"
math-exp-str))
***************
*** 727,732 ****
--- 802,810 ----
math-expr-data (char-to-string ch)
math-exp-pos (1+ math-exp-pos)))))))
+ (defconst math-alg-inequalities
+ '(calcFunc-lt calcFunc-gt calcFunc-leq calcFunc-geq
+ calcFunc-eq calcFunc-neq))
(defun math-read-expr-level (exp-prec &optional exp-term)
(let* ((x (math-read-factor)) (first t) op op2)
***************
*** 771,777 ****
(if (not (equal (car op) "2x"))
(math-read-token))
(and (memq (nth 1 op) '(sdev mod))
! (calc-extensions))
(setq x (cond ((consp (nth 1 op))
(funcall (car (nth 1 op)) x op))
((eq (nth 3 op) -1)
--- 849,855 ----
(if (not (equal (car op) "2x"))
(math-read-token))
(and (memq (nth 1 op) '(sdev mod))
! (require 'calc-ext))
(setq x (cond ((consp (nth 1 op))
(funcall (car (nth 1 op)) x op))
((eq (nth 3 op) -1)
***************
*** 787,793 ****
((and (not first)
(memq (nth 1 op) math-alg-inequalities)
(memq (car-safe x) math-alg-inequalities))
! (calc-extensions)
(math-composite-inequalities x op))
(t (list (nth 1 op)
x
--- 865,871 ----
((and (not first)
(memq (nth 1 op) math-alg-inequalities)
(memq (car-safe x) math-alg-inequalities))
! (require 'calc-ext)
(math-composite-inequalities x op))
(t (list (nth 1 op)
x
***************
*** 815,821 ****
(or (not (listp
(setq matches (calc-match-user-syntax rule))))
(let ((args (progn
! (calc-extensions)
calc-arg-values))
(conds nil)
temp)
--- 893,899 ----
(or (not (listp
(setq matches (calc-match-user-syntax rule))))
(let ((args (progn
! (require 'calc-ext)
calc-arg-values))
(conds nil)
temp)
***************
*** 830,836 ****
conds)
match (nth 1 match)))
(while (and conds match)
! (calc-extensions)
(cond ((eq (car-safe (car conds))
'calcFunc-let)
(setq temp (car conds))
--- 908,914 ----
conds)
match (nth 1 match)))
(while (and conds match)
! (require 'calc-ext)
(cond ((eq (car-safe (car conds))
'calcFunc-let)
(setq temp (car conds))
***************
*** 941,950 ****
matches "Failed"))
matches))
- (defconst math-alg-inequalities
- '(calcFunc-lt calcFunc-gt calcFunc-leq calcFunc-geq
- calcFunc-eq calcFunc-neq))
-
(defun math-remove-dashes (x)
(if (string-match "\\`\\(.*\\)-\\(.*\\)\\'" x)
(math-remove-dashes
--- 1019,1024 ----
***************
*** 1026,1032 ****
(throw 'syntax "Expected `)'"))
(math-read-token)
(if (and (eq calc-language 'fortran) args
! (calc-extensions)
(let ((calc-matrix-mode 'scalar))
(math-known-matrixp
(list 'var sym
--- 1100,1106 ----
(throw 'syntax "Expected `)'"))
(math-read-token)
(if (and (eq calc-language 'fortran) args
! (require 'calc-ext)
(let ((calc-matrix-mode 'scalar))
(math-known-matrixp
(list 'var sym
***************
*** 1085,1091 ****
((eq math-exp-token 'hash)
(or calc-hashes-used
(throw 'syntax "#'s not allowed in this context"))
! (calc-extensions)
(if (<= math-expr-data (length calc-arg-values))
(let ((num math-expr-data))
(math-read-token)
--- 1159,1165 ----
((eq math-exp-token 'hash)
(or calc-hashes-used
(throw 'syntax "#'s not allowed in this context"))
! (require 'calc-ext)
(if (<= math-expr-data (length calc-arg-values))
(let ((num math-expr-data))
(math-read-token)
***************
*** 1116,1122 ****
(setq exp (if (and exp2 (Math-realp exp)
(Math-anglep exp2))
(math-normalize (list 'polar exp exp2))
! (calc-extensions)
(list '* exp
(list 'calcFunc-exp
(list '*
--- 1190,1196 ----
(setq exp (if (and exp2 (Math-realp exp)
(Math-anglep exp2))
(math-normalize (list 'polar exp exp2))
! (require 'calc-ext)
(list '* exp
(list 'calcFunc-exp
(list '*
***************
*** 1143,1160 ****
(math-read-token)
exp))
((eq math-exp-token 'string)
! (calc-extensions)
(math-read-string))
((equal math-expr-data "[")
! (calc-extensions)
(math-read-brackets t "]"))
((equal math-expr-data "{")
! (calc-extensions)
(math-read-brackets nil "}"))
((equal math-expr-data "<")
! (calc-extensions)
(math-read-angle-brackets))
(t (throw 'syntax "Expected a number")))))
;;; arch-tag: 5599e45d-e51e-44bb-9a20-9f4ed8c96c32
;;; calc-aent.el ends here
--- 1217,1236 ----
(math-read-token)
exp))
((eq math-exp-token 'string)
! (require 'calc-ext)
(math-read-string))
((equal math-expr-data "[")
! (require 'calc-ext)
(math-read-brackets t "]"))
((equal math-expr-data "{")
! (require 'calc-ext)
(math-read-brackets nil "}"))
((equal math-expr-data "<")
! (require 'calc-ext)
(math-read-angle-brackets))
(t (throw 'syntax "Expected a number")))))
+ (provide 'calc-aent)
+
;;; arch-tag: 5599e45d-e51e-44bb-9a20-9f4ed8c96c32
;;; calc-aent.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] Changes to emacs/lisp/calc/calc-aent.el [lexbind],
Miles Bader <=