diff options
Diffstat (limited to 'lisp/calc')
-rw-r--r-- | lisp/calc/calc-aent.el | 4 | ||||
-rw-r--r-- | lisp/calc/calc-alg.el | 12 | ||||
-rw-r--r-- | lisp/calc/calc-ext.el | 32 | ||||
-rw-r--r-- | lisp/calc/calc-forms.el | 2 | ||||
-rw-r--r-- | lisp/calc/calc-graph.el | 2 | ||||
-rw-r--r-- | lisp/calc/calc-keypd.el | 2 | ||||
-rw-r--r-- | lisp/calc/calc-lang.el | 8 | ||||
-rw-r--r-- | lisp/calc/calc-menu.el | 4 | ||||
-rw-r--r-- | lisp/calc/calc-nlfit.el | 2 | ||||
-rw-r--r-- | lisp/calc/calc-prog.el | 93 | ||||
-rw-r--r-- | lisp/calc/calc-sel.el | 4 | ||||
-rw-r--r-- | lisp/calc/calc-units.el | 2 | ||||
-rw-r--r-- | lisp/calc/calc-yank.el | 5 | ||||
-rw-r--r-- | lisp/calc/calc.el | 20 | ||||
-rw-r--r-- | lisp/calc/calcalg2.el | 6 | ||||
-rw-r--r-- | lisp/calc/calcalg3.el | 6 |
16 files changed, 114 insertions, 90 deletions
diff --git a/lisp/calc/calc-aent.el b/lisp/calc/calc-aent.el index 1e31c3cadc0..db4751a9fbb 100644 --- a/lisp/calc/calc-aent.el +++ b/lisp/calc/calc-aent.el @@ -1139,7 +1139,7 @@ If the current Calc language does not use placeholders, return nil." 0) (setq sym (intern (substring (symbol-name sym) 1)))) - (or (string-match "-" (symbol-name sym)) + (or (string-search "-" (symbol-name sym)) (setq sym (intern (concat "calcFunc-" (symbol-name sym)))))) @@ -1149,7 +1149,7 @@ If the current Calc language does not use placeholders, return nil." (let ((val (list 'var (intern (math-remove-dashes (symbol-name sym))) - (if (string-match "-" (symbol-name sym)) + (if (string-search "-" (symbol-name sym)) sym (intern (concat "var-" (symbol-name sym))))))) diff --git a/lisp/calc/calc-alg.el b/lisp/calc/calc-alg.el index 1327cf0a39b..162026d092b 100644 --- a/lisp/calc/calc-alg.el +++ b/lisp/calc/calc-alg.el @@ -444,12 +444,12 @@ Code can refer to the expression to simplify via lexical variable `expr' and should return the simplified expression to use (or nil)." (declare (indent 1) (debug (sexp body))) (cons 'progn - (mapcar #'(lambda (func) - `(put ',func 'math-simplify - (nconc - (get ',func 'math-simplify) - (list - #'(lambda (expr) ,@code))))) + (mapcar (lambda (func) + `(put ',func 'math-simplify + (nconc + (get ',func 'math-simplify) + (list + (lambda (expr) ,@code))))) (if (symbolp funcs) (list funcs) funcs)))) (math-defsimplify (+ -) diff --git a/lisp/calc/calc-ext.el b/lisp/calc/calc-ext.el index f4ddb840b50..45337e187be 100644 --- a/lisp/calc/calc-ext.el +++ b/lisp/calc/calc-ext.el @@ -2565,9 +2565,9 @@ If X is not an error form, return 1." ;;; True if A is numerically equal to the integer B. [P N S] [Public] ;;; B must not be a multiple of 10. (defun math-equal-int (a b) - (or (eq a b) + (or (eql a b) (and (eq (car-safe a) 'float) - (eq (nth 1 a) b) + (eql (nth 1 a) b) (= (nth 2 a) 0)))) @@ -2784,23 +2784,23 @@ If X is not an error form, return 1." (declare (indent 1) (debug (sexp body))) (setq math-integral-cache nil) (cons 'progn - (mapcar #'(lambda (func) - `(put ',func 'math-integral - (nconc - (get ',func 'math-integral) - (list - #'(lambda (u) ,@code))))) + (mapcar (lambda (func) + `(put ',func 'math-integral + (nconc + (get ',func 'math-integral) + (list + (lambda (u) ,@code))))) (if (symbolp funcs) (list funcs) funcs)))) (defmacro math-defintegral-2 (funcs &rest code) (declare (indent 1) (debug (sexp body))) (setq math-integral-cache nil) (cons 'progn - (mapcar #'(lambda (func) - `(put ',func 'math-integral-2 - (nconc - (get ',func 'math-integral-2) - (list #'(lambda (u v) ,@code))))) + (mapcar (lambda (func) + `(put ',func 'math-integral-2 + (nconc + (get ',func 'math-integral-2) + (list (lambda (u v) ,@code))))) (if (symbolp funcs) (list funcs) funcs)))) (defvar var-IntegAfterRules 'calc-IntegAfterRules) @@ -3088,7 +3088,7 @@ If X is not an error form, return 1." (math-read-big-err-msg nil) math-read-big-baseline math-read-big-h2 new-pos p) - (while (setq new-pos (string-match "\n" str pos)) + (while (setq new-pos (string-search "\n" str pos)) (setq math-read-big-lines (cons (substring str pos new-pos) math-read-big-lines) pos (1+ new-pos))) @@ -3249,7 +3249,7 @@ If X is not an error form, return 1." (t (let ((str (math-format-flat-expr x 0)) (pos 0) p) - (or (string-match "\"" str) + (or (string-search "\"" str) (while (<= (setq p (+ pos w)) (length str)) (while (and (> (setq p (1- p)) pos) (not (= (aref str p) ? )))) @@ -3278,7 +3278,7 @@ If X is not an error form, return 1." (math-format-radix-float a prec)) (format "%d#%s" calc-number-radix (math-format-radix-float a prec))))) - (if (and prec (> prec 191) (string-match "\\*" str)) + (if (and prec (> prec 191) (string-search "*" str)) (concat "(" str ")") str)))) ((eq (car a) 'frac) diff --git a/lisp/calc/calc-forms.el b/lisp/calc/calc-forms.el index ee53b94cd64..ac57011da04 100644 --- a/lisp/calc/calc-forms.el +++ b/lisp/calc/calc-forms.el @@ -2238,7 +2238,7 @@ and ends on the last Sunday of October at 2 a.m." (if (eq (car-safe str2) 'error) str2 (append '(calcFunc-lambda) (cdr str1) (list str2))))) - (if (string-match "#" str) + (if (string-search "#" str) (let ((calc-hashes-used 0)) (and (setq str (math-read-expr str)) (if (eq (car-safe str) 'error) diff --git a/lisp/calc/calc-graph.el b/lisp/calc/calc-graph.el index 423d1e64126..9ac24bf1889 100644 --- a/lisp/calc/calc-graph.el +++ b/lisp/calc/calc-graph.el @@ -1025,7 +1025,7 @@ This \"dumb\" driver will be present in Gnuplot 3.0." (calc-pop-stack 1)))) (if (string-match "\\[.+\\]" range) (setq range (substring range 1 -1))) - (if (and (not (string-match ":" range)) + (if (and (not (string-search ":" range)) (or (string-match "," range) (string-match " " range))) (aset range (match-beginning 0) ?\:)) diff --git a/lisp/calc/calc-keypd.el b/lisp/calc/calc-keypd.el index 1902a4f3f29..acbef27a1da 100644 --- a/lisp/calc/calc-keypd.el +++ b/lisp/calc/calc-keypd.el @@ -481,7 +481,7 @@ ":" (if (and (equal cmd "e") (or (not input) - (string-match + (string-search "#" input)) (> radix 14)) (format "*%d.^" radix) diff --git a/lisp/calc/calc-lang.el b/lisp/calc/calc-lang.el index 0117f449dd5..aef3173f5c0 100644 --- a/lisp/calc/calc-lang.el +++ b/lisp/calc/calc-lang.el @@ -660,7 +660,7 @@ (setq math-exp-pos (match-end 0) math-exp-token 'punc math-expr-data "[") - (let ((right (string-match "}" math-exp-str math-exp-pos))) + (let ((right (string-search "}" math-exp-str math-exp-pos))) (and right (setq math-exp-str (copy-sequence math-exp-str)) (aset math-exp-str right ?\])))))))))) @@ -899,7 +899,7 @@ (setq math-exp-pos (match-end 0) math-exp-token 'punc math-expr-data "[") - (let ((right (string-match "}" math-exp-str math-exp-pos))) + (let ((right (string-search "}" math-exp-str math-exp-pos))) (and right (setq math-exp-str (copy-sequence math-exp-str)) (aset math-exp-str right ?\])))))))))) @@ -2342,7 +2342,7 @@ order to Calc's." (math-read-big-emptyp math-rb-h1 (1+ v) h math-rb-v2 nil t) (if (= (math-read-big-char widest v) ?\() (progn - (setq line (if (string-match "-" p) + (setq line (if (string-search "-" p) (intern p) (intern (concat "calcFunc-" p))) h (1+ widest) @@ -2362,7 +2362,7 @@ order to Calc's." (setq p (cons line (nreverse p)))) (setq p (list 'var (intern (math-remove-dashes p)) - (if (string-match "-" p) + (if (string-search "-" p) (intern p) (intern (concat "var-" p))))))) diff --git a/lisp/calc/calc-menu.el b/lisp/calc/calc-menu.el index 16cca055330..516f62d7b63 100644 --- a/lisp/calc/calc-menu.el +++ b/lisp/calc/calc-menu.el @@ -781,7 +781,7 @@ :active (>= (calc-stack-size) 2) :help "The cross product in R^3"] ["(2:) dot (1:)" - calc-mult + calc-times :keys "*" :active (>= (calc-stack-size) 2) :help "The dot product"] @@ -1669,3 +1669,5 @@ ["Quit" calc-quit])) (provide 'calc-menu) + +;;; calc-menu.el ends here diff --git a/lisp/calc/calc-nlfit.el b/lisp/calc/calc-nlfit.el index 11867f15e5b..f676b098e58 100644 --- a/lisp/calc/calc-nlfit.el +++ b/lisp/calc/calc-nlfit.el @@ -819,3 +819,5 @@ (calc-record traillist "parm"))))) (provide 'calc-nlfit) + +;;; calc-nlfit.el ends here diff --git a/lisp/calc/calc-prog.el b/lisp/calc/calc-prog.el index 3097b09b013..f9dd9eb98a9 100644 --- a/lisp/calc/calc-prog.el +++ b/lisp/calc/calc-prog.el @@ -604,7 +604,7 @@ ((equal name "#") (search-backward "#") (error "Token `#' is reserved")) - ((and unquoted (string-match "#" name)) + ((and unquoted (string-search "#" name)) (error "Tokens containing `#' must be quoted")) ((not (string-match "[^ ]" name)) (search-backward "\"" nil t) @@ -802,8 +802,8 @@ (when match (kill-line 1) (setq line (concat line (substring curline 0 match)))) - (setq line (replace-regexp-in-string "SPC" " SPC " - (replace-regexp-in-string " " "" line))) + (setq line (string-replace "SPC" " SPC " + (string-replace " " "" line))) (insert line "\t\t\t") (if (> (current-column) 24) (delete-char -1)) @@ -830,7 +830,7 @@ (when match (kill-line 1) (setq line (concat line (substring curline 0 match)))) - (setq line (replace-regexp-in-string " " "" line)) + (setq line (string-replace " " "" line)) (insert cmdbeg " " line "\t\t\t") (if (> (current-column) 24) (delete-char -1)) @@ -857,7 +857,7 @@ (when match (kill-line 1) (setq line (concat line (substring curline 0 match)))) - (setq line (replace-regexp-in-string " " "" line)) + (setq line (string-replace " " "" line)) (insert line "\t\t\t") (if (> (current-column) 24) (delete-char -1)) @@ -1068,7 +1068,7 @@ Redefine the corresponding command." (insert (setq str (prin1-to-string (cons 'defun (cons cmd (cdr fcmd))))) "\n") - (or (and (string-match "\"" str) (not q-ok)) + (or (and (string-search "\"" str) (not q-ok)) (fill-region pt (point))) (indent-rigidly pt (point) 2) (delete-region pt (1+ pt)) @@ -1087,7 +1087,7 @@ Redefine the corresponding command." (cons 'defun (cons func (cdr ffunc))))) "\n") - (or (and (string-match "\"" str) (not q-ok)) + (or (and (string-search "\"" str) (not q-ok)) (fill-region pt (point))) (indent-rigidly pt (point) 2) (delete-region pt (1+ pt)) @@ -1881,9 +1881,9 @@ Redefine the corresponding command." (if (fboundp (setq chk (intern (concat "math-" qual-name)))) (append rest (if is-rest - `((mapcar #'(lambda (x) - (or (,chk x) - (math-reject-arg x ',qual))) + `((mapcar (lambda (x) + (or (,chk x) + (math-reject-arg x ',qual))) ,var)) `((or (,chk ,var) (math-reject-arg ,var ',qual))))) @@ -1894,9 +1894,9 @@ Redefine the corresponding command." qual-name 1)))))) (append rest (if is-rest - `((mapcar #'(lambda (x) - (and (,chk x) - (math-reject-arg x ',qual))) + `((mapcar (lambda (x) + (and (,chk x) + (math-reject-arg x ',qual))) ,var)) `((and (,chk ,var) @@ -1985,22 +1985,37 @@ Redefine the corresponding command." (cons 'quote (math-define-lambda (nth 1 exp) math-exp-env)) exp)) - ((memq func '(let let* for foreach)) - (let ((head (nth 1 exp)) - (body (cdr (cdr exp)))) - (if (memq func '(let let*)) - () - (setq func (cdr (assq func '((for . math-for) - (foreach . math-foreach))))) - (if (not (listp (car head))) - (setq head (list head)))) - (macroexpand - (cons func - (cons (math-define-let head) - (math-define-body body - (nconc - (math-define-let-env head) - math-exp-env))))))) + ((eq func 'let) + (let ((bindings (nth 1 exp)) + (body (cddr exp))) + `(let ,(math-define-let bindings) + ,@(math-define-body + body (append (math-define-let-env bindings) + math-exp-env))))) + ((eq func 'let*) + ;; Rewrite in terms of `let'. + (let ((bindings (nth 1 exp)) + (body (cddr exp))) + (math-define-exp + (if (> (length bindings) 1) + `(let ,(list (car bindings)) + (let* ,(cdr bindings) ,@body)) + `(let ,bindings ,@body))))) + ((memq func '(for foreach)) + (let ((bindings (nth 1 exp)) + (body (cddr exp))) + (if (> (length bindings) 1) + ;; Rewrite as nested loops. + (math-define-exp + `(,func ,(list (car bindings)) + (,func ,(cdr bindings) ,@body))) + (let ((mac (cdr (assq func '((for . math-for) + (foreach . math-foreach)))))) + (macroexpand + `(,mac ,(math-define-let bindings) + ,@(math-define-body + body (append (math-define-let-env bindings) + math-exp-env)))))))) ((and (memq func '(setq setf)) (math-complicated-lhs (cdr exp))) (if (> (length exp) 3) @@ -2017,7 +2032,7 @@ Redefine the corresponding command." (math-define-cond (cdr exp)))) ((and (consp func) ; ('spam a b) == force use of plain spam (eq (car func) 'quote)) - (cons func (math-define-list (cdr exp)))) + (cons (cadr func) (math-define-list (cdr exp)))) ((symbolp func) (let ((args (math-define-list (cdr exp))) (prim (assq func math-prim-funcs))) @@ -2117,7 +2132,7 @@ Redefine the corresponding command." (cdr prim)) ((memq exp math-exp-env) exp) - ((string-match "-" name) + ((string-search "-" name) exp) (t (intern (concat "var-" name)))))) @@ -2276,20 +2291,16 @@ Redefine the corresponding command." (defun math-handle-foreach (head body) (let ((var (nth 0 (car head))) + (loop-var (gensym "foreach")) (data (nth 1 (car head))) (body (if (cdr head) (list (math-handle-foreach (cdr head) body)) body))) - (cons 'let - (cons (list (list var data)) - (list - (cons 'while - (cons var - (append body - (list (list 'setq - var - (list 'cdr var))))))))))) - + `(let ((,loop-var ,data)) + (while ,loop-var + (let ((,var (car ,loop-var))) + ,@(append body + `((setq ,loop-var (cdr ,loop-var))))))))) (defun math-body-refers-to (body thing) (or (equal body thing) diff --git a/lisp/calc/calc-sel.el b/lisp/calc/calc-sel.el index 2b317ac3696..18fd483bafe 100644 --- a/lisp/calc/calc-sel.el +++ b/lisp/calc/calc-sel.el @@ -486,8 +486,8 @@ (defun calc-replace-sub-formula (expr rsf-old rsf-new) (let ((calc-rsf-old rsf-old) - (calc-rsf-new (calc-encase-atoms rsf-new)))) - (calc-replace-sub-formula-rec expr)) + (calc-rsf-new (calc-encase-atoms rsf-new))) + (calc-replace-sub-formula-rec expr))) (defun calc-replace-sub-formula-rec (expr) (cond ((eq expr calc-rsf-old) calc-rsf-new) diff --git a/lisp/calc/calc-units.el b/lisp/calc/calc-units.el index c3adc3db02a..8b6f0637035 100644 --- a/lisp/calc/calc-units.el +++ b/lisp/calc/calc-units.el @@ -406,7 +406,7 @@ Entries are (SYMBOL EXPR DOC-STRING TEMP-TYPE BASE-UNITS).") If EXPR is nil, return nil." (if expr (let ((cexpr (math-compose-expr expr 0))) - (replace-regexp-in-string + (string-replace " / " "/" (if (stringp cexpr) cexpr diff --git a/lisp/calc/calc-yank.el b/lisp/calc/calc-yank.el index e5f05236f3a..762adbd407e 100644 --- a/lisp/calc/calc-yank.el +++ b/lisp/calc/calc-yank.el @@ -639,7 +639,7 @@ Interactively, reads the register using `register-read-with-preview'." (calc-slow-wrapper (when (eq n 0) (setq n (calc-stack-size))) - (let* ((flag nil) + (let* (;; (flag nil) (allow-ret (> n 1)) (list (math-showing-full-precision (mapcar (if (> n 1) @@ -651,7 +651,8 @@ Interactively, reads the register using `register-read-with-preview'." (if (> n 0) (calc-top-list n) (calc-top-list 1 (- n))))))) - (calc--edit-mode (lambda () (calc-finish-stack-edit (or flag n))) allow-ret) + (calc--edit-mode (lambda () (calc-finish-stack-edit n)) ;; (or flag n) + allow-ret) (while list (insert (car list) "\n") (setq list (cdr list))))) diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el index ec09abb34c4..a10b3178302 100644 --- a/lisp/calc/calc.el +++ b/lisp/calc/calc.el @@ -483,6 +483,11 @@ current precision are displayed in scientific notation in calc-mode.") "Floating-point numbers with this negative exponent or lower are displayed scientific notation in calc-mode.") +(defvar calc-digit-after-point nil + "If t, display at least one digit after the decimal point, as in `12.0'. +If nil, the decimal point may come last in a number, as in `12.'. +This setting only applies to floats in normal display mode.") + (defvar calc-other-modes nil "List of used-defined strings to append to Calculator mode line.") @@ -2121,7 +2126,7 @@ the United States." (goto-char (point-max)) (cond ((null prefix) (insert " ")) ((and (> (length prefix) 4) - (string-match " " prefix 4)) + (string-search " " prefix 4)) (insert (substring prefix 0 4) " ")) (t (insert (format "%4s " prefix)))) (insert fval "\n") @@ -2464,7 +2469,7 @@ the United States." (calc-minibuffer-contains "[-+]?\\(.*\\+/- *\\|.*mod *\\)?\\([0-9]+\\.?0*[@oh] *\\)?\\([0-9]+\\.?0*['m] *\\)?[0-9]*\\(\\.?[0-9]*\\(e[-+]?[0-3]?[0-9]?[0-9]?[0-9]?[0-9]?[0-9]?[0-9]?\\)?\\|[0-9]:\\([0-9]+:\\)?[0-9]*\\)?[\"s]?\\'")) (if (and (memq last-command-event '(?@ ?o ?h ?\' ?m)) - (string-match " " calc-hms-format)) + (string-search " " calc-hms-format)) (insert " ")) (if (and (memq last-command '(calcDigit-start calcDigit-key)) (eq last-command-event ?.)) @@ -3054,7 +3059,7 @@ the United States." (defun calc-count-lines (s) (let ((pos 0) (num 1)) - (while (setq pos (string-match "\n" s pos)) + (while (setq pos (string-search "\n" s pos)) (setq pos (1+ pos) num (1+ num))) num)) @@ -3184,7 +3189,8 @@ the United States." exp (- exp adj))))) (setq str (int-to-string mant)) (let* ((len (length str)) - (dpos (+ exp len))) + (dpos (+ exp len)) + (trailing-0 (and calc-digit-after-point "0"))) (if (and (eq fmt 'float) (<= dpos (+ calc-internal-prec calc-display-sci-high)) (>= dpos (+ calc-display-sci-low 2))) @@ -3194,9 +3200,11 @@ the United States." (setq str (concat "0" point str))) ((and (<= exp 0) (> dpos 0)) (setq str (concat (substring str 0 dpos) point - (substring str dpos)))) + (substring str dpos) + (and (>= dpos len) trailing-0)))) ((> exp 0) - (setq str (concat str (make-string exp ?0) point))) + (setq str (concat str (make-string exp ?0) + point trailing-0))) (t ; (< dpos 0) (setq str (concat "0" point (make-string (- dpos) ?0) str)))) diff --git a/lisp/calc/calcalg2.el b/lisp/calc/calcalg2.el index 94b99aa29d8..8d93ae987a1 100644 --- a/lisp/calc/calcalg2.el +++ b/lisp/calc/calcalg2.el @@ -158,7 +158,7 @@ (calc-top-n 2) (calc-top-n 1))) (let ((var (if (and (string-match ",\\|[^ ] +[^ ]" var) - (not (string-match "\\[" var))) + (not (string-search "[" var))) (math-read-expr (concat "[" var "]")) (math-read-expr var)))) (if (eq (car-safe var) 'error) @@ -175,7 +175,7 @@ (calc-top-n 2) (calc-top-n 1))) (let ((var (if (and (string-match ",\\|[^ ] +[^ ]" var) - (not (string-match "\\[" var))) + (not (string-search "[" var))) (math-read-expr (concat "[" var "]")) (math-read-expr var)))) (if (eq (car-safe var) 'error) @@ -1028,7 +1028,7 @@ (fset 'calcFunc-integ math-old-integ)))) ;; See if the function is a symbolic derivative. - (and (string-match "'" (symbol-name (car expr))) + (and (string-search "'" (symbol-name (car expr))) (let ((name (symbol-name (car expr))) (p expr) (n 0) (which nil) (bad nil)) (while (setq n (1+ n) p (cdr p)) diff --git a/lisp/calc/calcalg3.el b/lisp/calc/calcalg3.el index ee3ae0a4c1f..3cb1886f3bd 100644 --- a/lisp/calc/calcalg3.el +++ b/lisp/calc/calcalg3.el @@ -56,7 +56,7 @@ (calc-top-n 1) (calc-top-n 2))) (let ((var (if (and (string-match ",\\|[^ ] +[^ ]" var) - (not (string-match "\\[" var))) + (not (string-search "[" var))) (math-read-expr (concat "[" var "]")) (math-read-expr var)))) (if (eq (car-safe var) 'error) @@ -81,7 +81,7 @@ (calc-top-n 1) (calc-top-n 2))) (let ((var (if (and (string-match ",\\|[^ ] +[^ ]" var) - (not (string-match "\\[" var))) + (not (string-search "[" var))) (math-read-expr (concat "[" var "]")) (math-read-expr var)))) (if (eq (car-safe var) 'error) @@ -490,7 +490,7 @@ defc) ","))))) (coefs nil)) - (setq vars (if (string-match "\\[" vars) + (setq vars (if (string-search "[" vars) (math-read-expr vars) (math-read-expr (concat "[" vars "]")))) (if (eq (car-safe vars) 'error) |