diff options
Diffstat (limited to 'lisp/calc')
-rw-r--r-- | lisp/calc/.arch-inventory | 4 | ||||
-rw-r--r-- | lisp/calc/README | 10 | ||||
-rw-r--r-- | lisp/calc/calc-aent.el | 115 | ||||
-rw-r--r-- | lisp/calc/calc-alg.el | 26 | ||||
-rw-r--r-- | lisp/calc/calc-bin.el | 4 | ||||
-rw-r--r-- | lisp/calc/calc-ext.el | 79 | ||||
-rw-r--r-- | lisp/calc/calc-frac.el | 34 | ||||
-rw-r--r-- | lisp/calc/calc-graph.el | 2 | ||||
-rw-r--r-- | lisp/calc/calc-help.el | 8 | ||||
-rw-r--r-- | lisp/calc/calc-incom.el | 6 | ||||
-rw-r--r-- | lisp/calc/calc-keypd.el | 9 | ||||
-rw-r--r-- | lisp/calc/calc-lang.el | 142 | ||||
-rw-r--r-- | lisp/calc/calc-misc.el | 33 | ||||
-rw-r--r-- | lisp/calc/calc-poly.el | 2 | ||||
-rw-r--r-- | lisp/calc/calc-prog.el | 3 | ||||
-rw-r--r-- | lisp/calc/calc-sel.el | 10 | ||||
-rw-r--r-- | lisp/calc/calc-store.el | 14 | ||||
-rw-r--r-- | lisp/calc/calc-trail.el | 28 | ||||
-rw-r--r-- | lisp/calc/calc-units.el | 26 | ||||
-rw-r--r-- | lisp/calc/calc-vec.el | 71 | ||||
-rw-r--r-- | lisp/calc/calc-yank.el | 12 | ||||
-rw-r--r-- | lisp/calc/calc.el | 64 | ||||
-rw-r--r-- | lisp/calc/calcalg2.el | 14 | ||||
-rw-r--r-- | lisp/calc/calccomp.el | 77 |
24 files changed, 481 insertions, 312 deletions
diff --git a/lisp/calc/.arch-inventory b/lisp/calc/.arch-inventory deleted file mode 100644 index e4e8f8239ce..00000000000 --- a/lisp/calc/.arch-inventory +++ /dev/null @@ -1,4 +0,0 @@ -# Auto-generated lisp files, which ignore -precious ^(.*-loaddefs)\.el$ - -# arch-tag: 5258f69e-459b-449b-bdd7-bdbd5f948cb9 diff --git a/lisp/calc/README b/lisp/calc/README index 9e095252fc1..cf3a697c5d7 100644 --- a/lisp/calc/README +++ b/lisp/calc/README @@ -72,6 +72,16 @@ opinions. Summary of changes to "Calc" ------- -- ------- -- ---- +Emacs 24.1 + +* Added option to highlight selections using faces. + +* Gave `calc-histogram' the option of using a vector to determine the bins. + +* Added "O" option prefix. + +* Used "O" prefix to "d r" (`calc-radix') to turn on twos-complement mode. + Emacs 23.2 * Added twos-complement display. diff --git a/lisp/calc/calc-aent.el b/lisp/calc/calc-aent.el index 58e30a237f9..472133be84f 100644 --- a/lisp/calc/calc-aent.el +++ b/lisp/calc/calc-aent.el @@ -1,7 +1,7 @@ ;;; calc-aent.el --- algebraic entry functions for Calc -;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, 2005, +;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: Dave Gillespie <daveg@synaptics.com> ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com> @@ -315,10 +315,24 @@ The value t means abort and give an error message.") calc-dollar-used 0))) (calc-handle-whys)))) -(defvar calc-alg-ent-map nil +(defvar calc-alg-ent-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map minibuffer-local-map) + (define-key map "'" 'calcAlg-previous) + (define-key map "`" 'calcAlg-edit) + (define-key map "\C-m" 'calcAlg-enter) + (define-key map "\C-j" 'calcAlg-enter) + map) "The keymap used for algebraic entry.") -(defvar calc-alg-ent-esc-map nil +(defvar calc-alg-ent-esc-map + (let ((map (make-keymap)) + (i 33)) + (set-keymap-parent map esc-map) + (while (< i 127) + (define-key map (vector i) 'calcAlg-escape) + (setq i (1+ i))) + map) "The keymap used for escapes in algebraic entry.") (defvar calc-alg-exp) @@ -326,19 +340,8 @@ The value t means abort and give an error message.") ;;;###autoload (defun calc-do-alg-entry (&optional initial prompt no-normalize history) (let* ((calc-buffer (current-buffer)) - (blink-paren-function 'calcAlg-blink-matching-open) + (blink-matching-check-function 'calcAlg-blink-matching-check) (calc-alg-exp 'error)) - (unless calc-alg-ent-map - (setq calc-alg-ent-map (copy-keymap minibuffer-local-map)) - (define-key calc-alg-ent-map "'" 'calcAlg-previous) - (define-key calc-alg-ent-map "`" 'calcAlg-edit) - (define-key calc-alg-ent-map "\C-m" 'calcAlg-enter) - (define-key calc-alg-ent-map "\C-j" 'calcAlg-enter) - (let ((i 33)) - (setq calc-alg-ent-esc-map (copy-keymap esc-map)) - (while (< i 127) - (aset (nth 1 calc-alg-ent-esc-map) i 'calcAlg-escape) - (setq i (1+ i))))) (define-key calc-alg-ent-map "\e" nil) (if (eq calc-algebraic-mode 'total) (define-key calc-alg-ent-map "\e" calc-alg-ent-esc-map) @@ -430,18 +433,9 @@ The value t means abort and give an error message.") exp)) (exit-minibuffer)))) -(defun calcAlg-blink-matching-open () - (let ((rightpt (point)) - (leftpt nil) - (rightchar (preceding-char)) - leftchar - rightsyntax - leftsyntax) - (save-excursion - (condition-case () - (setq leftpt (scan-sexps rightpt -1) - leftchar (char-after leftpt)) - (error nil))) +(defun calcAlg-blink-matching-check (leftpt rightpt) + (let ((rightchar (char-before rightpt)) + (leftchar (if leftpt (char-after leftpt)))) (if (and leftpt (or (and (= rightchar ?\)) (= leftchar ?\[)) @@ -450,20 +444,9 @@ The value t means abort and give an error message.") (save-excursion (goto-char leftpt) (looking-at ".+\\(\\.\\.\\|\\\\dots\\|\\\\ldots\\)"))) - (let ((leftsaved (aref (syntax-table) leftchar)) - (rightsaved (aref (syntax-table) rightchar))) - (unwind-protect - (progn - (cond ((= leftchar ?\[) - (aset (syntax-table) leftchar (cons 4 ?\))) - (aset (syntax-table) rightchar (cons 5 ?\[))) - (t - (aset (syntax-table) leftchar (cons 4 ?\])) - (aset (syntax-table) rightchar (cons 5 ?\()))) - (blink-matching-open)) - (aset (syntax-table) leftchar leftsaved) - (aset (syntax-table) rightchar rightsaved))) - (blink-matching-open)))) + ;; [2..5) perfectly valid! + nil + (blink-matching-check-mismatch leftpt rightpt)))) ;;;###autoload (defun calc-alg-digit-entry () @@ -510,6 +493,7 @@ The value t means abort and give an error message.") ("≥" ">=") ("≦" "<=") ("≧" ">=") + ("µ" "μ") ;; fractions ("¼" "(1:4)") ; 1/4 ("½" "(1:2)") ; 1/2 @@ -608,9 +592,9 @@ in Calc algebraic input.") (setq math-exp-str (math-remove-percentsigns 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 + (while (setq math-exp-token (string-match "\\.\\.\\([^.]\\|.[^.]\\)" math-exp-str)) - (setq math-exp-str + (setq math-exp-str (concat (substring math-exp-str 0 math-exp-token) "\\dots" (substring math-exp-str (+ math-exp-token 2))))) (math-build-parse-table) @@ -675,11 +659,11 @@ in Calc algebraic input.") (cond ((and (stringp (car p)) (or (> (length (car p)) 1) (equal (car p) "$") (equal (car p) "\"")) - (string-match "[^a-zA-Z0-9]" (car p))) + (string-match "[^a-zA-Zα-ωΑ-Ω0-9]" (car p))) (let ((s (regexp-quote (car p)))) - (if (string-match "\\`[a-zA-Z0-9]" s) + (if (string-match "\\`[a-zA-Zα-ωΑ-Ω0-9]" s) (setq s (concat "\\<" s))) - (if (string-match "[a-zA-Z0-9]\\'" s) + (if (string-match "[a-zA-Zα-ωΑ-Ω0-9]\\'" s) (setq s (concat s "\\>"))) (or (assoc s math-toks) (progn @@ -711,22 +695,24 @@ in Calc algebraic input.") (math-read-token))) ((and (memq ch calc-user-token-chars) (let ((case-fold-search nil)) - (eq (string-match + (eq (string-match calc-user-tokens math-exp-str math-exp-pos) math-exp-pos))) (setq math-exp-token 'punc math-expr-data (math-match-substring math-exp-str 0) math-exp-pos (match-end 0))) ((or (and (>= ch ?a) (<= ch ?z)) - (and (>= ch ?A) (<= ch ?Z))) - (string-match + (and (>= ch ?A) (<= ch ?Z)) + (and (>= ch ?α) (<= ch ?ω)) + (and (>= ch ?Α) (<= ch ?Ω))) + (string-match (cond ((and (memq calc-language calc-lang-allow-underscores) (memq calc-language calc-lang-allow-percentsigns)) - "[a-zA-Z0-9_'#]*") + "[a-zA-Zα-ωΑ-Ω0-9_'#]*") ((memq calc-language calc-lang-allow-underscores) - "[a-zA-Z0-9_#]*") - (t "[a-zA-Z0-9'#]*")) + "[a-zA-Zα-ωΑ-Ω0-9_#]*") + (t "[a-zA-Zα-ωΑ-Ω0-9'#]*")) math-exp-str math-exp-pos) (setq math-exp-token 'symbol math-exp-pos (match-end 0) @@ -742,19 +728,19 @@ in Calc algebraic input.") (eq (string-match "_\\.?[0-9]" math-exp-str math-exp-pos) math-exp-pos) (or (eq math-exp-pos 0) - (and (not (memq calc-language + (and (not (memq calc-language calc-lang-allow-underscores)) - (eq (string-match "[^])}\"a-zA-Z0-9'$]_" + (eq (string-match "[^])}\"a-zA-Zα-ωΑ-Ω0-9'$]_" math-exp-str (1- math-exp-pos)) (1- math-exp-pos)))))) (or (and (memq calc-language calc-lang-c-type-hex) (string-match "0[xX][0-9a-fA-F]+" math-exp-str math-exp-pos)) - (string-match "_?\\([0-9]+.?0*@ *\\)?\\([0-9]+.?0*' *\\)?\\(0*\\([2-9]\\|1[0-4]\\)\\(#[#]?\\|\\^\\^\\)[0-9a-dA-D.]+[eE][-+_]?[0-9]+\\|0*\\([2-9]\\|[0-2][0-9]\\|3[0-6]\\)\\(#[#]?\\|\\^\\^\\)[0-9a-zA-Z:.]+\\|[0-9]+:[0-9:]+\\|[0-9.]+\\([eE][-+_]?[0-9]+\\)?\"?\\)?" + (string-match "_?\\([0-9]+.?0*@ *\\)?\\([0-9]+.?0*' *\\)?\\(0*\\([2-9]\\|1[0-4]\\)\\(#[#]?\\|\\^\\^\\)[0-9a-dA-D.]+[eE][-+_]?[0-9]+\\|0*\\([2-9]\\|[0-2][0-9]\\|3[0-6]\\)\\(#[#]?\\|\\^\\^\\)[0-9a-zA-Zα-ωΑ-Ω:.]+\\|[0-9]+:[0-9:]+\\|[0-9.]+\\([eE][-+_]?[0-9]+\\)?\"?\\)?" math-exp-str math-exp-pos)) (setq math-exp-token 'number math-expr-data (math-match-substring math-exp-str 0) math-exp-pos (match-end 0))) - ((and (setq adfn + ((and (setq adfn (assq ch (get calc-language 'math-lang-read-symbol))) (eval (nth 1 adfn))) (eval (nth 2 adfn))) @@ -807,8 +793,8 @@ in Calc algebraic input.") (defun math-read-expr-level (exp-prec &optional exp-term) (let* ((math-expr-opers (math-expr-ops)) - (x (math-read-factor)) - (first t) + (x (math-read-factor)) + (first t) op op2) (while (and (or (and calc-user-parse-table (setq op (calc-check-user-syntax x exp-prec)) @@ -829,8 +815,8 @@ in Calc algebraic input.") (memq math-exp-token '(symbol number dollar hash)) (equal math-expr-data "(") (and (equal math-expr-data "[") - (not (equal - (get calc-language + (not (equal + (get calc-language 'math-function-open) "[")) (not (and math-exp-keep-spaces (eq (car-safe x) 'vec))))) @@ -1138,8 +1124,8 @@ If the current Calc language does not use placeholders, return nil." (eq math-exp-token 'end))) (throw 'syntax "Expected `)'")) (math-read-token) - (if (and (memq calc-language - calc-lang-parens-are-subscripts) + (if (and (memq calc-language + calc-lang-parens-are-subscripts) args (require 'calc-ext) (let ((calc-matrix-mode 'scalar)) @@ -1181,7 +1167,7 @@ If the current Calc language does not use placeholders, return nil." (substring (symbol-name (cdr v)) 4)) (cdr v)))))) - (while (and (memq calc-language + (while (and (memq calc-language calc-lang-brackets-are-subscripts) (equal math-expr-data "[")) (math-read-token) @@ -1281,6 +1267,7 @@ If the current Calc language does not use placeholders, return nil." (provide 'calc-aent) ;; Local variables: +;; coding: utf-8 ;; generated-autoload-file: "calc-loaddefs.el" ;; End: diff --git a/lisp/calc/calc-alg.el b/lisp/calc/calc-alg.el index 6a85be14aeb..47cdae52a13 100644 --- a/lisp/calc/calc-alg.el +++ b/lisp/calc/calc-alg.el @@ -1659,11 +1659,11 @@ ;; math-is-poly-rec. (defvar math-is-poly-degree) (defvar math-is-poly-loose) -(defvar var) +(defvar math-var) -(defun math-is-polynomial (expr var &optional math-is-poly-degree math-is-poly-loose) +(defun math-is-polynomial (expr math-var &optional math-is-poly-degree math-is-poly-loose) (let* ((math-poly-base-variable (if math-is-poly-loose - (if (eq math-is-poly-loose 'gen) var '(var XXX XXX)) + (if (eq math-is-poly-loose 'gen) math-var '(var XXX XXX)) math-poly-base-variable)) (poly (math-is-poly-rec expr math-poly-neg-powers))) (and (or (null math-is-poly-degree) @@ -1672,11 +1672,11 @@ (defun math-is-poly-rec (expr negpow) (math-poly-simplify - (or (cond ((or (equal expr var) + (or (cond ((or (equal expr math-var) (eq (car-safe expr) '^)) (let ((pow 1) (expr expr)) - (or (equal expr var) + (or (equal expr math-var) (setq pow (nth 2 expr) expr (nth 1 expr))) (or (eq math-poly-mult-powers 1) @@ -1690,7 +1690,7 @@ (equal math-poly-mult-powers (nth 1 m)) (setq math-poly-mult-powers (nth 1 m))) - (or (equal expr var) + (or (equal expr math-var) (eq math-poly-mult-powers 1)) (car m))))) (if (consp pow) @@ -1698,7 +1698,7 @@ (setq pow (math-to-simple-fraction pow)) (and (eq (car-safe pow) 'frac) math-poly-frac-powers - (equal expr var) + (equal expr math-var) (setq math-poly-frac-powers (calcFunc-lcm math-poly-frac-powers (nth 2 pow)))))) @@ -1706,10 +1706,10 @@ (setq pow (math-mul pow math-poly-frac-powers))) (if (integerp pow) (if (and (= pow 1) - (equal expr var)) + (equal expr math-var)) (list 0 1) (if (natnump pow) - (let ((p1 (if (equal expr var) + (let ((p1 (if (equal expr math-var) (list 0 1) (math-is-poly-rec expr nil))) (n pow) @@ -1749,7 +1749,7 @@ math-is-poly-degree)) (math-poly-mul p1 p2)))))) ((eq (car expr) '/) - (and (or (not (math-poly-depends (nth 2 expr) var)) + (and (or (not (math-poly-depends (nth 2 expr) math-var)) (and negpow (math-is-poly-rec (nth 2 expr) nil) (setq math-poly-neg-powers @@ -1759,13 +1759,13 @@ (mapcar (function (lambda (x) (math-div x (nth 2 expr)))) p1)))) ((and (eq (car expr) 'calcFunc-exp) - (equal var '(var e var-e))) - (math-is-poly-rec (list '^ var (nth 1 expr)) negpow)) + (equal math-var '(var e var-e))) + (math-is-poly-rec (list '^ math-var (nth 1 expr)) negpow)) ((and (eq (car expr) 'calcFunc-sqrt) math-poly-frac-powers) (math-is-poly-rec (list '^ (nth 1 expr) '(frac 1 2)) negpow)) (t nil)) - (and (or (not (math-poly-depends expr var)) + (and (or (not (math-poly-depends expr math-var)) math-is-poly-loose) (not (eq (car expr) 'vec)) (list expr))))) diff --git a/lisp/calc/calc-bin.el b/lisp/calc/calc-bin.el index 7af60e92140..4ab698ea640 100644 --- a/lisp/calc/calc-bin.el +++ b/lisp/calc/calc-bin.el @@ -175,7 +175,7 @@ the size of a Calc bignum digit.") (progn (calc-change-mode (list 'calc-number-radix 'calc-twos-complement-mode) - (list n (and (or (= n 2) (= n 8) (= n 16)) arg)) t) + (list n (or arg (calc-is-option))) t) ;; also change global value so minibuffer sees it (setq-default calc-number-radix calc-number-radix)) (setq n calc-number-radix)) @@ -845,6 +845,8 @@ the size of a Calc bignum digit.") (len (length num))) (if (< len digs) (setq num (concat (make-string (- digs len) ?0) num)))) + (when calc-group-digits + (setq num (math-group-float num))) (concat (number-to-string calc-number-radix) "##" diff --git a/lisp/calc/calc-ext.el b/lisp/calc/calc-ext.el index 61ec3573282..18e63655ecf 100644 --- a/lisp/calc/calc-ext.el +++ b/lisp/calc/calc-ext.el @@ -1,7 +1,7 @@ ;;; calc-ext.el --- various extension functions for Calc -;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, 2005, +;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: David Gillespie <daveg@synaptics.com> ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com> @@ -104,6 +104,7 @@ (define-key calc-mode-map "J" 'calc-conj) (define-key calc-mode-map "L" 'calc-ln) (define-key calc-mode-map "N" 'calc-eval-num) + (define-key calc-mode-map "O" 'calc-option) (define-key calc-mode-map "P" 'calc-pi) (define-key calc-mode-map "Q" 'calc-sqrt) (define-key calc-mode-map "R" 'calc-round) @@ -959,7 +960,7 @@ math-read-brackets math-reduce-cols math-reduce-vec math-transpose) ("calc-yank" calc-alg-edit calc-clean-newlines calc-do-grab-rectangle calc-do-grab-region calc-finish-stack-edit -calc-copy-to-register calc-insert-register +calc-copy-to-register calc-insert-register calc-append-to-register calc-prepend-to-register calc-force-refresh calc-locate-cursor-element calc-show-edit-buffer) @@ -988,7 +989,7 @@ calc-floor calc-idiv calc-increment calc-mant-part calc-max calc-min calc-round calc-scale-float calc-sign calc-trunc calc-xpon-part) ("calc-bin" calc-and calc-binary-radix calc-clip calc-twos-complement-mode -calc-decimal-radix calc-diff calc-hex-radix calc-leading-zeros +calc-decimal-radix calc-diff calc-hex-radix calc-leading-zeros calc-lshift-arith calc-lshift-binary calc-not calc-octal-radix calc-or calc-radix calc-rotate-binary calc-rshift-arith calc-rshift-binary calc-word-size calc-xor) @@ -1045,7 +1046,7 @@ calc-graph-zero-x calc-graph-zero-y) calc-d-prefix-help calc-describe-function calc-describe-key calc-describe-key-briefly calc-describe-variable calc-f-prefix-help calc-full-help calc-g-prefix-help calc-help-prefix -calc-hyperbolic-prefix-help calc-inv-hyp-prefix-help +calc-hyperbolic-prefix-help calc-inv-hyp-prefix-help calc-option-prefix-help calc-inverse-prefix-help calc-j-prefix-help calc-k-prefix-help calc-m-prefix-help calc-r-prefix-help calc-s-prefix-help calc-t-prefix-help calc-u-prefix-help calc-v-prefix-help) @@ -1408,9 +1409,18 @@ calc-kill calc-kill-region calc-yank)))) (with-current-buffer calc-main-buffer calc-hyperbolic-flag) calc-hyperbolic-flag)) - (msg (if hyp-flag - "Inverse Hyperbolic..." - "Inverse..."))) + (opt-flag (if (or + (eq major-mode 'calc-keypad-mode) + (eq major-mode 'calc-trail-mode)) + (with-current-buffer calc-main-buffer + calc-option-flag) + calc-option-flag)) + (msg + (cond + ((and opt-flag hyp-flag) "Option Inverse Hyperbolic...") + (hyp-flag "Inverse Hyperbolic...") + (opt-flag "Option Inverse...") + (t "Inverse...")))) (calc-fancy-prefix 'calc-inverse-flag msg n))) (defconst calc-fancy-prefix-map @@ -1489,9 +1499,18 @@ calc-kill calc-kill-region calc-yank)))) (with-current-buffer calc-main-buffer calc-inverse-flag) calc-inverse-flag)) - (msg (if inv-flag - "Inverse Hyperbolic..." - "Hyperbolic..."))) + (opt-flag (if (or + (eq major-mode 'calc-keypad-mode) + (eq major-mode 'calc-trail-mode)) + (with-current-buffer calc-main-buffer + calc-option-flag) + calc-option-flag)) + (msg + (cond + ((and opt-flag inv-flag) "Option Inverse Hyperbolic...") + (opt-flag "Option Hyperbolic...") + (inv-flag "Inverse Hyperbolic...") + (t "Hyperbolic...")))) (calc-fancy-prefix 'calc-hyperbolic-flag msg n))) (defun calc-hyperbolic-func () @@ -1504,6 +1523,31 @@ calc-kill calc-kill-region calc-yank)))) (defun calc-is-hyperbolic () calc-hyperbolic-flag) +(defun calc-option (&optional n) + (interactive "P") + (let* ((inv-flag (if (or + (eq major-mode 'calc-keypad-mode) + (eq major-mode 'calc-trail-mode)) + (with-current-buffer calc-main-buffer + calc-inverse-flag) + calc-inverse-flag)) + (hyp-flag (if (or + (eq major-mode 'calc-keypad-mode) + (eq major-mode 'calc-trail-mode)) + (with-current-buffer calc-main-buffer + calc-hyperbolic-flag) + calc-hyperbolic-flag)) + (msg + (cond + ((and hyp-flag inv-flag) "Option Inverse Hyperbolic...") + (hyp-flag "Option Hyperbolic...") + (inv-flag "Option Inverse...") + (t "Option...")))) + (calc-fancy-prefix 'calc-option-flag msg n))) + +(defun calc-is-option () + calc-option-flag) + (defun calc-keep-args (&optional n) (interactive "P") (calc-fancy-prefix 'calc-keep-args-flag "Keep args..." n)) @@ -1658,8 +1702,8 @@ calc-kill calc-kill-region calc-yank)))) (defun calc-execute-extended-command (n) (interactive "P") (let* ((prompt (concat (calc-num-prefix-name n) "M-x ")) - (cmd (intern - (completing-read prompt obarray 'commandp t "calc-" + (cmd (intern + (completing-read prompt obarray 'commandp t "calc-" 'calc-extended-command-history)))) (setq prefix-arg n) (command-execute cmd))) @@ -3239,7 +3283,7 @@ If X is not an error form, return 1." (concat "-" (math-format-flat-expr (nth 1 a) 1000))) (t (concat (math-remove-dashes - (if (string-match "\\`calcFunc-\\([a-zA-Z0-9']+\\)\\'" + (if (string-match "\\`calcFunc-\\([a-zA-Zα-ωΑ-Ω0-9']+\\)\\'" (symbol-name (car a))) (math-match-substring (symbol-name (car a)) 1) (symbol-name (car a)))) @@ -3425,7 +3469,8 @@ If X is not an error form, return 1." (defun math-group-float (str) ; [X X] (let* ((pt (or (string-match "[^0-9a-zA-Z]" str) (length str))) - (g (if (integerp calc-group-digits) (math-abs calc-group-digits) 3)) + (g (if (integerp calc-group-digits) (math-abs calc-group-digits) + (if (memq calc-number-radix '(2 16)) 4 3))) (i pt)) (if (and (integerp calc-group-digits) (< calc-group-digits 0)) (while (< (setq i (+ (1+ i) g)) (length str)) @@ -3455,5 +3500,9 @@ A key may contain additional specs for Inverse, Hyperbolic, and Inv+Hyp.") (provide 'calc-ext) +;; Local variables: +;; coding: utf-8 +;; End: + ;; arch-tag: 1814ba7f-a390-49dc-9e25-a5adc205e97e ;;; calc-ext.el ends here diff --git a/lisp/calc/calc-frac.el b/lisp/calc/calc-frac.el index a01f5b8b9fa..265f0b325b9 100644 --- a/lisp/calc/calc-frac.el +++ b/lisp/calc/calc-frac.el @@ -205,16 +205,32 @@ n temp)) (math-div n d))) - - (defun calcFunc-fdiv (a b) ; [R I I] [Public] - (if (Math-num-integerp a) - (if (Math-num-integerp b) - (if (Math-zerop b) - (math-reject-arg a "*Division by zero") - (math-make-frac (math-trunc a) (math-trunc b))) - (math-reject-arg b 'integerp)) - (math-reject-arg a 'integerp))) + (cond + ((Math-num-integerp a) + (cond + ((Math-num-integerp b) + (if (Math-zerop b) + (math-reject-arg a "*Division by zero") + (math-make-frac (math-trunc a) (math-trunc b)))) + ((eq (car-safe b) 'frac) + (if (Math-zerop (nth 1 b)) + (math-reject-arg a "*Division by zero") + (math-make-frac (math-mul (math-trunc a) (nth 2 b)) (nth 1 b)))) + (t (math-reject-arg b 'integerp)))) + ((eq (car-safe a) 'frac) + (cond + ((Math-num-integerp b) + (if (Math-zerop b) + (math-reject-arg a "*Division by zero") + (math-make-frac (cadr a) (math-mul (nth 2 a) (math-trunc b))))) + ((eq (car-safe b) 'frac) + (if (Math-zerop (nth 1 b)) + (math-reject-arg a "*Division by zero") + (math-make-frac (math-mul (nth 1 a) (nth 2 b)) (math-mul (nth 2 a) (nth 1 b))))) + (t (math-reject-arg b 'integerp)))) + (t + (math-reject-arg a 'integerp)))) (provide 'calc-frac) diff --git a/lisp/calc/calc-graph.el b/lisp/calc/calc-graph.el index 9af89ab6c3a..9fefaa73d79 100644 --- a/lisp/calc/calc-graph.el +++ b/lisp/calc/calc-graph.el @@ -433,7 +433,7 @@ (while (memq (preceding-char) '(?\s ?\t)) (forward-char -1)) (if (eq (preceding-char) ?\,) - (delete-backward-char 1)))) + (delete-char -1)))) (with-current-buffer calcbuf (setq cache-env (list calc-angle-mode calc-complex-mode diff --git a/lisp/calc/calc-help.el b/lisp/calc/calc-help.el index 0b2240f78c4..47c95130641 100644 --- a/lisp/calc/calc-help.el +++ b/lisp/calc/calc-help.el @@ -128,7 +128,7 @@ C-w Describe how there is no warranty for Calc." (dig2 (char-after (match-beginning 3)))) (delete-region (match-end 1) (match-end 0)) (goto-char (match-beginning 1)) - (delete-backward-char 1) + (delete-char -1) (delete-char 5) (insert (format "%c .. %c" (min dig1 dig2) (max dig1 dig2))))) (goto-char (point-min))))) @@ -446,6 +446,7 @@ C-w Describe how there is no warranty for Calc." '(calc-inverse-prefix-help calc-hyperbolic-prefix-help calc-inv-hyp-prefix-help + calc-option-prefix-help calc-a-prefix-help calc-b-prefix-help calc-c-prefix-help @@ -512,6 +513,11 @@ C-w Describe how there is no warranty for Calc." "I H + a S (general invert func); v h (rtail)") "inverse-hyperbolic" nil)) +(defun calc-option-prefix-help () + (interactive) + (calc-do-prefix-help + '("") + "option" nil)) (defun calc-f-prefix-help () (interactive) diff --git a/lisp/calc/calc-incom.el b/lisp/calc/calc-incom.el index 6244c0d97e1..43811721146 100644 --- a/lisp/calc/calc-incom.el +++ b/lisp/calc/calc-incom.el @@ -176,9 +176,9 @@ (defun calc-digit-dots () (if (eq calc-prev-char ?.) (progn - (delete-backward-char 1) + (delete-char -1) (if (calc-minibuffer-contains ".*\\.\\'") - (delete-backward-char 1)) + (delete-char -1)) (setq calc-prev-char 'dots last-command-event 32) (if calc-prev-prev-char @@ -188,7 +188,7 @@ (erase-buffer)) (exit-minibuffer))) ;; just ignore extra decimal point, anticipating ".." - (delete-backward-char 1))) + (delete-char -1))) (defun calc-dots () (interactive) diff --git a/lisp/calc/calc-keypd.el b/lisp/calc/calc-keypd.el index e4dc5f5a88b..f0a37ad3b74 100644 --- a/lisp/calc/calc-keypd.el +++ b/lisp/calc/calc-keypd.el @@ -1,7 +1,7 @@ ;;; calc-keypd.el --- mouse-capable keypad input for Calc -;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, 2005, +;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: David Gillespie <daveg@synaptics.com> ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com> @@ -390,9 +390,7 @@ (interactive) (unless (eq major-mode 'calc-keypad-mode) (error "Must be in *Calc Keypad* buffer for this command")) - (let* ((row (save-excursion - (beginning-of-line) - (count-lines (point-min) (point)))) + (let* ((row (count-lines (point-min) (point-at-bol))) (y (/ row 2)) (x (/ (current-column) (if (>= y 4) 6 5))) radix frac inv @@ -619,5 +617,4 @@ (provide 'calc-keypd) -;; arch-tag: 4ba0d360-2bb6-40b8-adfa-eb373765b3f9 ;;; calc-keypd.el ends here diff --git a/lisp/calc/calc-lang.el b/lisp/calc/calc-lang.el index cd30232feee..f461c47aafd 100644 --- a/lisp/calc/calc-lang.el +++ b/lisp/calc/calc-lang.el @@ -1,7 +1,7 @@ ;;; calc-lang.el --- calc language functions -;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, 2005, +;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: David Gillespie <daveg@synaptics.com> ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com> @@ -214,7 +214,7 @@ (put 'pascal 'math-lang-read-symbol '((?\$ (eq (string-match - "\\(\\$[0-9a-fA-F]+\\)\\($\\|[^0-9a-zA-Z]\\)" + "\\(\\$[0-9a-fA-F]+\\)\\($\\|[^0-9a-zA-Zα-ωΑ-Ω]\\)" math-exp-str math-exp-pos) math-exp-pos) (setq math-exp-token 'number @@ -312,7 +312,7 @@ (put 'fortran 'math-lang-read-symbol '((?\. - (eq (string-match "\\.[a-zA-Z][a-zA-Z][a-zA-Z]?\\." + (eq (string-match "\\.[a-zA-Zα-ωΑ-Ω][a-zA-Zα-ωΑ-Ω][a-zA-Zα-ωΑ-Ω]?\\." math-exp-str math-exp-pos) math-exp-pos) (setq math-exp-token 'punc math-expr-data (upcase (math-match-substring math-exp-str 0)) @@ -335,7 +335,7 @@ (add-to-list 'calc-lang-allow-underscores 'fortran) (add-to-list 'calc-lang-parens-are-subscripts 'fortran) -;; The next few variables are local to math-read-exprs in calc-aent.el +;; The next few variables are local to math-read-exprs in calc-aent.el ;; and math-read-expr in calc-ext.el, but are set in functions they call. (defvar math-exp-token) @@ -379,12 +379,12 @@ ((= n 1) (message "TeX language mode with \\hbox{func}(\\hbox{var})")) ((> n 1) - (message + (message "TeX language mode with \\hbox{func}(\\hbox{var}) and multiline matrices")) ((= n -1) (message "TeX language mode with \\func(\\hbox{var})")) ((< n -1) - (message + (message "TeX language mode with \\func(\\hbox{var}) and multiline matrices"))))) (defun calc-latex-language (n) @@ -399,12 +399,12 @@ ((= n 1) (message "LaTeX language mode with \\text{func}(\\text{var})")) ((> n 1) - (message + (message "LaTeX language mode with \\text{func}(\\text{var}) and multiline matrices")) ((= n -1) (message "LaTeX language mode with \\func(\\text{var})")) ((< n -1) - (message + (message "LaTeX language mode with \\func(\\text{var}) and multiline matrices"))))) (put 'tex 'math-lang-name "TeX") @@ -498,7 +498,7 @@ (intv . math-compose-tex-intv))) (put 'tex 'math-variable-table - '( + '( ;; The Greek letters ( \\alpha . var-alpha ) ( \\beta . var-beta ) @@ -603,9 +603,9 @@ '((?\\ (< math-exp-pos (1- (length math-exp-str))) (progn - (or (string-match "\\\\hbox *{\\([a-zA-Z0-9]+\\)}" + (or (string-match "\\\\hbox *{\\([a-zA-Zα-ωΑ-Ω0-9]+\\)}" math-exp-str math-exp-pos) - (string-match "\\(\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\)" + (string-match "\\(\\\\\\([a-zA-Zα-ωΑ-Ω]+\\|[^a-zA-Zα-ωΑ-Ω]\\)\\)" math-exp-str math-exp-pos)) (setq math-exp-token 'symbol math-exp-pos (match-end 0) @@ -630,7 +630,7 @@ (defun math-compose-tex-matrix (a &optional ltx) (if (cdr a) - (cons (append (math-compose-vector (cdr (car a)) " & " 0) + (cons (append (math-compose-vector (cdr (car a)) " & " 0) (if ltx '(" \\\\ ") '(" \\cr "))) (math-compose-tex-matrix (cdr a) ltx)) (list (math-compose-vector (cdr (car a)) " & " 0)))) @@ -691,7 +691,7 @@ (defun math-compose-tex-var (a prec) (if (and calc-language-option (not (= calc-language-option 0)) - (string-match "\\`[a-zA-Z][a-zA-Z0-9]+\\'" + (string-match "\\`[a-zA-Zα-ωΑ-Ω][a-zA-Zα-ωΑ-Ω0-9]+\\'" (symbol-name (nth 1 a)))) (if (eq calc-language 'latex) (format "\\text{%s}" (symbol-name (nth 1 a))) @@ -702,7 +702,7 @@ (let (left right) (if (and calc-language-option (not (= calc-language-option 0)) - (string-match "\\`[a-zA-Z][a-zA-Z0-9]+\\'" func)) + (string-match "\\`[a-zA-Zα-ωΑ-Ω][a-zA-Zα-ωΑ-Ω0-9]+\\'" func)) (if (< (prefix-numeric-value calc-language-option) 0) (setq func (format "\\%s" func)) (setq func (if (eq calc-language 'latex) @@ -722,7 +722,7 @@ (setq left "{" right "}")) (t (setq left calc-function-open right calc-function-close))) - (list 'horiz func + (list 'horiz func left (math-compose-vector (cdr a) ", " 0) right))) @@ -824,11 +824,11 @@ '((?\\ (< math-exp-pos (1- (length math-exp-str))) (progn - (or (string-match "\\\\hbox *{\\([a-zA-Z0-9]+\\)}" + (or (string-match "\\\\hbox *{\\([a-zA-Zα-ωΑ-Ω0-9]+\\)}" math-exp-str math-exp-pos) - (string-match "\\\\text *{\\([a-zA-Z0-9]+\\)}" + (string-match "\\\\text *{\\([a-zA-Zα-ωΑ-Ω0-9]+\\)}" math-exp-str math-exp-pos) - (string-match "\\(\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\)" + (string-match "\\(\\\\\\([a-zA-Zα-ωΑ-Ω]+\\|[^a-zA-Zα-ωΑ-Ω]\\)\\)" math-exp-str math-exp-pos)) (setq math-exp-token 'symbol math-exp-pos (match-end 0) @@ -866,7 +866,7 @@ (and right (setq math-exp-str (copy-sequence math-exp-str)) (aset math-exp-str right ?\])))))))))) - + (defun math-latex-parse-frac (f val) (let (numer denom) (setq numer (car (math-read-expr-list))) @@ -988,7 +988,7 @@ (cdr (math-transpose a))) '("}"))))) -(put 'eqn 'math-var-formatter +(put 'eqn 'math-var-formatter (function (lambda (a prec) (let (v) @@ -1011,7 +1011,7 @@ (intern (substring (symbol-name (nth 2 a)) 0 -1)))) prec) (symbol-name (nth 1 a)))))))) - + (defconst math-eqn-special-funcs '( calcFunc-log calcFunc-ln calcFunc-exp @@ -1022,7 +1022,7 @@ calcFunc-arcsin calcFunc-arccos calcFunc-arctan calcFunc-arcsinh calcFunc-arccosh calcFunc-arctanh)) -(put 'eqn 'math-func-formatter +(put 'eqn 'math-func-formatter (function (lambda (func a) (let (left right) @@ -1035,8 +1035,8 @@ (not (math-tex-expr-is-flat (nth 1 a)))) (setq left "{left ( " right " right )}")) - - ((and + + ((and (memq (car a) math-eqn-special-funcs) (= (length a) 2) (or (Math-realp (nth 1 a)) @@ -1069,7 +1069,7 @@ ("above" punc ","))) (put 'eqn 'math-lang-adjust-words - (function + (function (lambda () (let ((code (assoc math-expr-data math-eqn-ignore-words))) (cond ((null code)) @@ -1189,21 +1189,21 @@ ( Gamma . var-gamma))) (put 'yacas 'math-parse-table - '((("Deriv(" 0 ")" 0) + '((("Deriv(" 0 ")" 0) calcFunc-deriv (var ArgB var-ArgB) (var ArgA var-ArgA)) - (("D(" 0 ")" 0) + (("D(" 0 ")" 0) calcFunc-deriv (var ArgB var-ArgB) (var ArgA var-ArgA)) - (("Integrate(" 0 ")" 0) + (("Integrate(" 0 ")" 0) calcFunc-integ (var ArgB var-ArgB)(var ArgA var-ArgA)) - (("Integrate(" 0 "," 0 "," 0 ")" 0) - calcFunc-integ (var ArgD var-ArgD) (var ArgA var-ArgA) + (("Integrate(" 0 "," 0 "," 0 ")" 0) + calcFunc-integ (var ArgD var-ArgD) (var ArgA var-ArgA) (var ArgB var-ArgB) (var ArgC var-ArgC)) - (("Subst(" 0 "," 0 ")" 0) - calcFunc-subst (var ArgC var-ArgC) (var ArgA var-ArgA) + (("Subst(" 0 "," 0 ")" 0) + calcFunc-subst (var ArgC var-ArgC) (var ArgA var-ArgA) (var ArgB var-ArgB)) - (("Taylor(" 0 "," 0 "," 0 ")" 0) - calcFunc-taylor (var ArgD var-ArgD) - (calcFunc-eq (var ArgA var-ArgA) (var ArgB var-ArgB)) + (("Taylor(" 0 "," 0 "," 0 ")" 0) + calcFunc-taylor (var ArgD var-ArgD) + (calcFunc-eq (var ArgA var-ArgA) (var ArgB var-ArgB)) (var ArgC var-ArgC)))) (put 'yacas 'math-oper-table @@ -1356,7 +1356,7 @@ (math-compose-expr (nth 2 a) -1) (if (not (nth 3 a)) ")" - (concat + (concat "," (math-compose-expr (nth 3 a) -1) "," @@ -1393,7 +1393,7 @@ '(("+" + 100 100) ("-" - 100 134) ("*" * 120 120) - ("." * 130 129) + ("." * 130 129) ("/" / 120 120) ("u-" neg -1 180) ("u+" ident -1 180) @@ -1494,9 +1494,9 @@ (nth 3 args)))) (put 'maxima 'math-parse-table - '((("if" 0 "then" 0 "else" 0) - calcFunc-if - (var ArgA var-ArgA) + '((("if" 0 "then" 0 "else" 0) + calcFunc-if + (var ArgA var-ArgA) (var ArgB var-ArgB) (var ArgC var-ArgC)))) @@ -1572,7 +1572,7 @@ (lambda (a) (list 'horiz "matrix(" - (math-compose-vector (cdr a) + (math-compose-vector (cdr a) (concat math-comp-comma " ") math-comp-vector-prec) ")")))) @@ -1734,7 +1734,7 @@ order to Calc's." (nth 0 args)))) (put 'giac 'math-parse-table - '((("set" 0) + '((("set" 0) calcFunc-rdup (var ArgA var-ArgA)))) @@ -1748,7 +1748,7 @@ order to Calc's." "Compose the arguments to a Calc function in reverse order. This is used for various language modes which have functions in reverse order to Calc's." - (list 'horiz (nth 1 fn) + (list 'horiz (nth 1 fn) "(" (math-compose-expr (nth 2 a) 0) "," @@ -1770,7 +1770,7 @@ order to Calc's." (list 'horiz (math-compose-expr (nth 1 a) 1000) "[" - (math-compose-expr + (math-compose-expr (calc-normalize (list '- (nth 2 a) 1)) 0) "]"))))) @@ -2001,7 +2001,7 @@ order to Calc's." (list 'horiz "matrix(" math-comp-left-bracket - (math-compose-vector (cdr a) + (math-compose-vector (cdr a) (concat math-comp-comma " ") math-comp-vector-prec) math-comp-right-bracket @@ -2044,9 +2044,9 @@ order to Calc's." (defvar math-read-big-baseline) (defvar math-read-big-h2) -;; The variables math-rb-h1, math-rb-h2, math-rb-v1 and math-rb-v2 -;; are local to math-read-big-rec, but are used by math-read-big-char, -;; math-read-big-emptyp and math-read-big-balance which are called by +;; The variables math-rb-h1, math-rb-h2, math-rb-v1 and math-rb-v2 +;; are local to math-read-big-rec, but are used by math-read-big-char, +;; math-read-big-emptyp and math-read-big-balance which are called by ;; math-read-big-rec. ;; math-rb-h2 is also local to math-read-big-bigp in calc-ext.el, ;; which calls math-read-big-balance. @@ -2055,40 +2055,40 @@ order to Calc's." (defvar math-rb-v1) (defvar math-rb-v2) -(defun math-read-big-rec (math-rb-h1 math-rb-v1 math-rb-h2 math-rb-v2 +(defun math-read-big-rec (math-rb-h1 math-rb-v1 math-rb-h2 math-rb-v2 &optional baseline prec short) (or prec (setq prec 0)) ;; Clip whitespace above or below. - (while (and (< math-rb-v1 math-rb-v2) + (while (and (< math-rb-v1 math-rb-v2) (math-read-big-emptyp math-rb-h1 math-rb-v1 math-rb-h2 (1+ math-rb-v1))) (setq math-rb-v1 (1+ math-rb-v1))) - (while (and (< math-rb-v1 math-rb-v2) + (while (and (< math-rb-v1 math-rb-v2) (math-read-big-emptyp math-rb-h1 (1- math-rb-v2) math-rb-h2 math-rb-v2)) (setq math-rb-v2 (1- math-rb-v2))) ;; If formula is a single line high, normal parser can handle it. (if (<= math-rb-v2 (1+ math-rb-v1)) (if (or (<= math-rb-v2 math-rb-v1) - (> math-rb-h1 (length (setq math-rb-v2 + (> math-rb-h1 (length (setq math-rb-v2 (nth math-rb-v1 math-read-big-lines))))) (math-read-big-error math-rb-h1 math-rb-v1) (setq math-read-big-baseline math-rb-v1 math-read-big-h2 math-rb-h2 math-rb-v2 (nth math-rb-v1 math-read-big-lines) - math-rb-h2 (math-read-expr - (substring math-rb-v2 math-rb-h1 + math-rb-h2 (math-read-expr + (substring math-rb-v2 math-rb-h1 (min math-rb-h2 (length math-rb-v2))))) (if (eq (car-safe math-rb-h2) 'error) - (math-read-big-error (+ math-rb-h1 (nth 1 math-rb-h2)) + (math-read-big-error (+ math-rb-h1 (nth 1 math-rb-h2)) math-rb-v1 (nth 2 math-rb-h2)) math-rb-h2)) ;; Clip whitespace at left or right. - (while (and (< math-rb-h1 math-rb-h2) + (while (and (< math-rb-h1 math-rb-h2) (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) math-rb-v2)) (setq math-rb-h1 (1+ math-rb-h1))) - (while (and (< math-rb-h1 math-rb-h2) + (while (and (< math-rb-h1 math-rb-h2) (math-read-big-emptyp (1- math-rb-h2) math-rb-v1 math-rb-h2 math-rb-v2)) (setq math-rb-h2 (1- math-rb-h2))) @@ -2107,7 +2107,7 @@ order to Calc's." (/= (aref line math-rb-h1) ?\ ) (if (and (= (aref line math-rb-h1) ?\-) ;; Make sure it's not a minus sign. - (or (and (< (1+ math-rb-h1) len) + (or (and (< (1+ math-rb-h1) len) (= (aref line (1+ math-rb-h1)) ?\-)) (/= (math-read-big-char math-rb-h1 (1- v)) ?\ ) (/= (math-read-big-char math-rb-h1 (1+ v)) ?\ ))) @@ -2166,7 +2166,7 @@ order to Calc's." ;; Binomial coefficient. ((and (= other-char ?\() (= (math-read-big-char (1+ math-rb-h1) v) ?\ ) - (= (string-match "( *)" (nth v math-read-big-lines) + (= (string-match "( *)" (nth v math-read-big-lines) math-rb-h1) math-rb-h1)) (setq h (match-end 0)) (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil t) @@ -2180,7 +2180,7 @@ order to Calc's." ;; Minus sign. ((= other-char ?\-) - (setq p (list 'neg (math-read-big-rec (1+ math-rb-h1) math-rb-v1 + (setq p (list 'neg (math-read-big-rec (1+ math-rb-h1) math-rb-v1 math-rb-h2 math-rb-v2 v 250 t)) v math-read-big-baseline h math-read-big-h2)) @@ -2199,10 +2199,10 @@ order to Calc's." (if (= sep ?\]) (math-read-big-error (1- h) v "Expected `)'")) (if (= sep ?\)) - (setq p (math-read-big-rec + (setq p (math-read-big-rec (1+ math-rb-h1) math-rb-v1 (1- h) math-rb-v2 v)) (setq hmid (math-read-big-balance h v "(") - p (list p + p (list p (math-read-big-rec h math-rb-v1 (1- hmid) math-rb-v2 v)) h hmid) (cond ((= sep ?\.) @@ -2301,9 +2301,11 @@ order to Calc's." ;; Variable name or function call. ((or (and (>= other-char ?a) (<= other-char ?z)) - (and (>= other-char ?A) (<= other-char ?Z))) + (and (>= other-char ?A) (<= other-char ?Z)) + (and (>= other-char ?α) (<= other-char ?ω)) + (and (>= other-char ?Α) (<= other-char ?Ω))) (setq line (nth v math-read-big-lines)) - (string-match "\\([a-zA-Z'_]+\\) *" line math-rb-h1) + (string-match "\\([a-zA-Zα-ωΑ-Ω'_]+\\) *" line math-rb-h1) (setq h (match-end 1) widest (match-end 0) p (math-match-substring line 1)) @@ -2345,7 +2347,7 @@ order to Calc's." (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t) (math-read-big-emptyp math-rb-h1 (1+ v) h math-rb-v2 nil t))) - ;; Now left term is bounded by math-rb-h1, math-rb-v1, h, math-rb-v2; + ;; Now left term is bounded by math-rb-h1, math-rb-v1, h, math-rb-v2; ;; baseline = v. (if baseline (or (= v baseline) @@ -2387,12 +2389,12 @@ order to Calc's." (cond ((eq (nth 3 widest) -1) (setq p (list (nth 1 widest) p))) ((equal (car widest) "?") - (let ((y (math-read-big-rec h math-rb-v1 math-rb-h2 + (let ((y (math-read-big-rec h math-rb-v1 math-rb-h2 math-rb-v2 baseline nil t))) (or (= (math-read-big-char math-read-big-h2 baseline) ?\:) (math-read-big-error math-read-big-h2 baseline "Expected `:'")) (setq p (list (nth 1 widest) p y - (math-read-big-rec + (math-read-big-rec (1+ math-read-big-h2) math-rb-v1 math-rb-h2 math-rb-v2 baseline (nth 3 widest) t)) h math-read-big-h2))) @@ -2481,5 +2483,9 @@ order to Calc's." (provide 'calc-lang) +;; Local variables: +;; coding: utf-8 +;; End: + ;; arch-tag: 483bfe15-f290-4fef-bb7d-ce65be687f2e ;;; calc-lang.el ends here diff --git a/lisp/calc/calc-misc.el b/lisp/calc/calc-misc.el index b6b2917f0fe..890e624ecb4 100644 --- a/lisp/calc/calc-misc.el +++ b/lisp/calc/calc-misc.el @@ -35,6 +35,7 @@ (declare-function calc-inv-hyp-prefix-help "calc-help" ()) (declare-function calc-inverse-prefix-help "calc-help" ()) (declare-function calc-hyperbolic-prefix-help "calc-help" ()) +(declare-function calc-option-prefix-help "calc-help" ()) (declare-function calc-explain-why "calc-stuff" (why &optional more)) (declare-function calc-clear-command-flag "calc-ext" (f)) (declare-function calc-roll-down-with-selections "calc-sel" (n m)) @@ -219,7 +220,7 @@ Calc user interface as before (either C-x * C or C-x * K; initially C-x * C). (let ((msgs '("Press `h' for complete help; press `?' repeatedly for a summary" "Letter keys: Negate; Precision; Yank; Why; Xtended cmd; Quit" - "Letter keys: SHIFT + Undo, reDo; Keep-args; Inverse, Hyperbolic" + "Letter keys: SHIFT + Undo, reDo; Keep-args; Inverse, Hyperbolic, Option" "Letter keys: SHIFT + sQrt; Sin, Cos, Tan; Exp, Ln, logB" "Letter keys: SHIFT + Floor, Round; Abs, conJ, arG; Pi" "Letter keys: SHIFT + Num-eval; More-recn; eXec-kbd-macro" @@ -245,20 +246,22 @@ Calc user interface as before (either C-x * C or C-x * K; initially C-x * C). (calc-inv-hyp-prefix-help) (calc-inverse-prefix-help)) (calc-hyperbolic-prefix-help)) - (setq calc-help-phase - (if (eq this-command last-command) - (% (1+ calc-help-phase) (1+ (length msgs))) - 0)) - (let ((msg (nth calc-help-phase msgs))) - (message "%s" (if msg - (concat msg ":" - (make-string (- (apply 'max - (mapcar 'length - msgs)) - (length msg)) 32) - " [?=MORE]") - ""))))))) - + (if calc-option-flag + (calc-option-prefix-help) + (setq calc-help-phase + (if (eq this-command last-command) + (% (1+ calc-help-phase) (1+ (length msgs))) + 0)) + (let ((msg (nth calc-help-phase msgs))) + (message "%s" (if msg + (concat msg ":" + (make-string (- (apply 'max + (mapcar 'length + msgs)) + (length msg)) 32) + " [?=MORE]") + "")))))))) + diff --git a/lisp/calc/calc-poly.el b/lisp/calc/calc-poly.el index a994ace6fb6..f268a032d14 100644 --- a/lisp/calc/calc-poly.el +++ b/lisp/calc/calc-poly.el @@ -663,7 +663,7 @@ (cons 'vec (cons (nth 1 facs) (cons (list 'vec fac pow) (cdr (cdr facs))))) (cons 'vec (cons (list 'vec fac pow) (cdr facs)))))))) - (math-mul (math-pow fac pow) facs))) + (math-mul (math-pow fac pow) (math-factor-protect facs)))) (defun math-factor-poly-coefs (p &optional square-free) ; uses "x" (let (t1 t2 temp) diff --git a/lisp/calc/calc-prog.el b/lisp/calc/calc-prog.el index 5e4adace91e..91017627699 100644 --- a/lisp/calc/calc-prog.el +++ b/lisp/calc/calc-prog.el @@ -627,7 +627,8 @@ (error "Separator not allowed with { ... }?")) (if (string-match "\\`\"" sep) (setq sep (read-from-string sep))) - (setq sep (calc-fix-token-name sep)) + (if (> (length sep) 0) + (setq sep (calc-fix-token-name sep))) (setq part (nconc part (list (list sym p (and (> (length sep) 0) diff --git a/lisp/calc/calc-sel.el b/lisp/calc/calc-sel.el index 084b9ea2b6a..c485fdd168a 100644 --- a/lisp/calc/calc-sel.el +++ b/lisp/calc/calc-sel.el @@ -309,6 +309,8 @@ (setq n (1+ n)))) (calc-clear-command-flag 'position-point))) +(defvar calc-highlight-selections-with-faces) + (defun calc-show-selections (arg) (interactive "P") (calc-wrapper @@ -330,8 +332,12 @@ (setcar (nthcdr 2 calc-selection-cache-entry) nil) (calc-change-current-selection sel))))) (message (if calc-show-selections - "Displaying only selected part of formulas" - "Displaying all but selected part of formulas")))) + (if calc-highlight-selections-with-faces + "De-emphasizing all but selected part of formulas" + "Displaying only selected part of formulas") + (if calc-highlight-selections-with-faces + "Emphasizing selected part of formulas" + "Displaying all but selected part of formulas"))))) ;; The variables calc-final-point-line and calc-final-point-column ;; are declared in calc.el, and are used throughout. diff --git a/lisp/calc/calc-store.el b/lisp/calc/calc-store.el index 5ec21eee887..b82ed08c557 100644 --- a/lisp/calc/calc-store.el +++ b/lisp/calc/calc-store.el @@ -1,7 +1,7 @@ ;;; calc-store.el --- value storage functions for Calc -;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, 2005, +;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: David Gillespie <daveg@synaptics.com> ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com> @@ -197,12 +197,12 @@ (minibuffer-completion-predicate (lambda (x) (boundp (intern (concat "var-" x))))) (minibuffer-completion-confirm t)) - (read-from-minibuffer - prompt nil calc-var-name-map nil + (read-from-minibuffer + prompt nil calc-var-name-map nil 'calc-read-var-name-history))))) (setq calc-aborted-prefix "") (and (not (equal var "var-")) - (if (string-match "\\`\\([-a-zA-Z0-9]+\\) *:?=" var) + (if (string-match "\\`\\([-a-zA-Zα-ωΑ-Ω0-9]+\\) *:?=" var) (if (null calc-given-value-flag) (error "Assignment is not allowed in this command") (let ((svar (intern (substring var 0 (match-end 1))))) @@ -677,5 +677,9 @@ (provide 'calc-store) +;; Local variables: +;; coding: utf-8 +;; End: + ;; arch-tag: 2fbfec82-a521-42ca-bcd8-4f254ae6313e ;;; calc-store.el ends here diff --git a/lisp/calc/calc-trail.el b/lisp/calc/calc-trail.el index 9bbb4178fd3..20dc1d1b99e 100644 --- a/lisp/calc/calc-trail.el +++ b/lisp/calc/calc-trail.el @@ -108,20 +108,28 @@ (defun calc-trail-isearch-forward () (interactive) (calc-with-trail-buffer - (save-window-excursion - (select-window (get-buffer-window (current-buffer))) - (let ((search-exit-char ?\r)) - (isearch-forward))) - (calc-trail-here))) + (let ((win (get-buffer-window (current-buffer))) + pos) + (save-window-excursion + (select-window win) + (isearch-forward) + (setq pos (point))) + (goto-char pos) + (set-window-point win pos) + (calc-trail-here)))) (defun calc-trail-isearch-backward () (interactive) (calc-with-trail-buffer - (save-window-excursion - (select-window (get-buffer-window (current-buffer))) - (let ((search-exit-char ?\r)) - (isearch-backward))) - (calc-trail-here))) + (let ((win (get-buffer-window (current-buffer))) + pos) + (save-window-excursion + (select-window win) + (isearch-backward) + (setq pos (point))) + (goto-char pos) + (set-window-point win pos) + (calc-trail-here)))) (defun calc-trail-yank (arg) (interactive "P") diff --git a/lisp/calc/calc-units.el b/lisp/calc/calc-units.el index 6dd3e4911b7..a88e87dffbc 100644 --- a/lisp/calc/calc-units.el +++ b/lisp/calc/calc-units.el @@ -1,7 +1,7 @@ ;;; calc-units.el --- unit conversion functions for Calc -;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, 2005, +;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: David Gillespie <daveg@synaptics.com> ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com> @@ -36,13 +36,13 @@ ;;; Units table last updated 9-Jan-91 by Ulrich Mueller (ulm@vsnhd1.cern.ch) ;;; with some additions by Przemek Klosowski (przemek@rrdstrad.nist.gov) -;;; Updated April 2002 by Jochen Küpper +;;; Updated April 2002 by Jochen Küpper ;;; Updated August 2007, using ;;; CODATA (http://physics.nist.gov/cuu/Constants/index.html) ;;; NIST (http://physics.nist.gov/Pubs/SP811/appenB9.html) ;;; ESUWM (Encyclopaedia of Scientific Units, Weights and -;;; Measures, by François Cardarelli) +;;; Measures, by François Cardarelli) ;;; All conversions are exact unless otherwise noted. (defvar math-standard-units @@ -210,6 +210,7 @@ "1.602176487 10^-19 C (*)") ;;(approx) CODATA ( V "W/A" "Volt" ) ( ohm "V/A" "Ohm" ) + ( Ω "ohm" "Ohm" ) ( mho "A/V" "Mho" ) ( S "A/V" "Siemens" ) ( F "C/V" "Farad" ) @@ -259,7 +260,9 @@ "6.62606896 10^-34 J s (*)") ( hbar "h / (2 pi)" "Planck's constant" ) ;; Exact ( mu0 "4 pi 10^(-7) H/m" "Permeability of vacuum") ;; Exact + ( μ0 "mu0" "Permeability of vacuum") ;; Exact ( eps0 "1 / (mu0 c^2)" "Permittivity of vacuum" ) + ( ε0 "eps0" "Permittivity of vacuum" ) ( G "6.67428*10^(-11) m^3/(kg s^2)" "Gravitational constant" nil "6.67428 10^-11 m^3/(kg s^2) (*)") ( Nav "6.02214179*10^(23) / mol" "Avogadro's constant" nil @@ -272,12 +275,16 @@ "1.674927211 10^-27 kg (*)") ( mmu "1.88353130*10^(-28) kg" "Muon rest mass" nil "1.88353130 10^-28 kg (*)") + ( mμ "mmu" "Muon rest mass" nil + "1.88353130 10^-28 kg (*)") ( Ryd "10973731.568527 /m" "Rydberg's constant" nil "10973731.568527 /m (*)") ( k "1.3806504*10^(-23) J/K" "Boltzmann's constant" nil "1.3806504 10^-23 J/K (*)") ( alpha "7.2973525376*10^(-3)" "Fine structure constant" nil "7.2973525376 10^-3 (*)") + ( α "alpha" "Fine structure constant" nil + "7.2973525376 10^-3 (*)") ( muB "927.400915*10^(-26) J/T" "Bohr magneton" nil "927.400915 10^-26 J/T (*)") ( muN "5.05078324*10^(-27) J/T" "Nuclear magneton" nil @@ -316,6 +323,7 @@ that the combined units table will be rebuilt.") ( ?c (^ 10 -2) "Centi" ) ( ?m (^ 10 -3) "Milli" ) ( ?u (^ 10 -6) "Micro" ) + ( ?μ (^ 10 -6) "Micro" ) ( ?n (^ 10 -9) "Nano" ) ( ?p (^ 10 -12) "Pico" ) ( ?f (^ 10 -15) "Femto" ) @@ -581,8 +589,8 @@ If EXPR is nil, return nil." (let ((name (or (nth 2 u) (symbol-name (car u))))) (if (eq (aref name 0) ?\*) (setq name (substring name 1))) - (if (string-match "[^a-zA-Z0-9']" name) - (if (string-match "^[a-zA-Z0-9' ()]*$" name) + (if (string-match "[^a-zA-Zα-ωΑ-Ω0-9']" name) + (if (string-match "^[a-zA-Zα-ωΑ-Ω0-9' ()]*$" name) (while (setq pos (string-match "[ ()]" name)) (setq name (concat (substring name 0 pos) (if (eq (aref name pos) 32) "-" "") @@ -592,7 +600,7 @@ If EXPR is nil, return nil." (setq name (concat (nth 2 (assq (aref (symbol-name (nth 1 expr)) 0) math-unit-prefixes)) - (if (and (string-match "[^a-zA-Z0-9']" name) + (if (and (string-match "[^a-zA-Zα-ωΑ-Ω0-9']" name) (not (memq (car u) '(mHg gf)))) (concat "-" name) (downcase name))))) @@ -1540,8 +1548,8 @@ If EXPR is nil, return nil." (provide 'calc-units) -;; Local Variables: -;; coding: iso-latin-1 +;; Local variables: +;; coding: utf-8 ;; End: ;; arch-tag: e993314f-3adc-4191-be61-4ef8874881c4 diff --git a/lisp/calc/calc-vec.el b/lisp/calc/calc-vec.el index c4de362ab36..5b807a55491 100644 --- a/lisp/calc/calc-vec.el +++ b/lisp/calc/calc-vec.el @@ -451,16 +451,18 @@ (calc-enter-result 1 "grad" (list 'calcFunc-grade (calc-top-n 1)))))) (defun calc-histogram (n) - (interactive "NNumber of bins: ") + (interactive "P") + (unless (natnump n) + (setq n (math-read-expr (read-string "Centers of bins: ")))) (calc-slow-wrapper (if calc-hyperbolic-flag (calc-enter-result 2 "hist" (list 'calcFunc-histogram (calc-top-n 2) (calc-top-n 1) - (prefix-numeric-value n))) + n)) (calc-enter-result 1 "hist" (list 'calcFunc-histogram (calc-top-n 1) - (prefix-numeric-value n)))))) + n))))) (defun calc-transpose (arg) (interactive "P") @@ -1135,22 +1137,53 @@ (if (Math-vectorp wts) (or (= (length vec) (length wts)) (math-dimension-error))) - (or (natnump n) - (math-reject-arg n 'fixnatnump)) - (let ((res (make-vector n 0)) - (vp vec) - (wvec (Math-vectorp wts)) - (wp wts) - bin) - (while (setq vp (cdr vp)) - (setq bin (car vp)) - (or (natnump bin) - (setq bin (math-floor bin))) - (and (natnump bin) - (< bin n) - (aset res bin (math-add (aref res bin) - (if wvec (car (setq wp (cdr wp))) wts))))) - (cons 'vec (append res nil)))) + (cond ((natnump n) + (let ((res (make-vector n 0)) + (vp vec) + (wvec (Math-vectorp wts)) + (wp wts) + bin) + (while (setq vp (cdr vp)) + (setq bin (car vp)) + (or (natnump bin) + (setq bin (math-floor bin))) + (and (natnump bin) + (< bin n) + (aset res bin + (math-add (aref res bin) + (if wvec (car (setq wp (cdr wp))) wts))))) + (cons 'vec (append res nil)))) + ((Math-vectorp n) ;; n is a vector of midpoints + (let* ((bds (math-vector-avg n)) + (res (make-vector (1- (length n)) 0)) + (vp (cdr vec)) + (wvec (Math-vectorp wts)) + (wp wts) + num) + (while vp + (setq num (car vp)) + (let ((tbds (cdr bds)) + (i 0)) + (while (and tbds (Math-lessp (car tbds) num)) + (setq i (1+ i)) + (setq tbds (cdr tbds))) + (aset res i + (math-add (aref res i) + (if wvec (car (setq wp (cdr wp))) wts)))) + (setq vp (cdr vp))) + (cons 'vec (append res nil)))) + (t + (math-reject-arg n "*Expecting an integer or vector")))) + +;;; Replace a vector [a b c ...] with a vector of averages +;;; [(a+b)/2 (b+c)/2 ...] +(defun math-vector-avg (vec) + (let ((vp (sort (copy-sequence (cdr vec)) 'math-beforep)) + (res nil)) + (while (and vp (cdr vp)) + (setq res (cons (math-div (math-add (car vp) (cadr vp)) 2) res) + vp (cdr vp))) + (cons 'vec (reverse res)))) ;;; Set operations. diff --git a/lisp/calc/calc-yank.el b/lisp/calc/calc-yank.el index 63b3cb03322..0588f31de15 100644 --- a/lisp/calc/calc-yank.el +++ b/lisp/calc/calc-yank.el @@ -1,7 +1,7 @@ ;;; calc-yank.el --- kill-ring functionality for Calc -;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, 2005, +;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: David Gillespie <daveg@synaptics.com> ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com> @@ -282,11 +282,8 @@ With prefix arg, also delete the region." (setq single t) (setq arg (prefix-numeric-value arg)) (if (= arg 0) - (save-excursion - (beginning-of-line) - (setq top (point)) - (end-of-line) - (setq bot (point))) + (setq top (point-at-bol) + bot (point-at-eol)) (save-excursion (setq top (point)) (forward-line arg) @@ -713,5 +710,4 @@ To cancel the edit, simply kill the *Calc Edit* buffer." ;; generated-autoload-file: "calc-loaddefs.el" ;; End: -;; arch-tag: ca61019e-caca-4daa-b32c-b6afe372d5b5 ;;; calc-yank.el ends here diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el index 2a6ec97ef5c..e0560465a99 100644 --- a/lisp/calc/calc.el +++ b/lisp/calc/calc.el @@ -419,12 +419,33 @@ in normal mode." :group 'calc :type 'boolean) -(defcustom calc-undo-length +(defcustom calc-undo-length 100 "The number of undo steps that will be preserved when Calc is quit." :group 'calc :type 'integer) +(defcustom calc-highlight-selections-with-faces + nil + "If non-nil, use a separate face to indicate selected sub-formulas. +If `calc-show-selections' is non-nil, then selected sub-formulas are shown +by displaying the rest of the formula in `calc-nonselected-face'. +If `calc-show-selections' is nil, then selected sub-formulas are shown +by displaying the sub-formula in `calc-selected-face'." + :group 'calc + :type 'boolean) + +(defface calc-nonselected-face + '((t :inherit shadow + :slant italic)) + "Face used to show the non-selected portion of a formula." + :group 'calc) + +(defface calc-selected-face + '((t :weight bold)) + "Face used to show the selected portion of a formula." + :group 'calc) + (defvar calc-bug-address "jay.p.belanger@gmail.com" "Address of the maintainer of Calc, for use by `report-calc-bug'.") @@ -797,6 +818,7 @@ Used by `calc-user-invocation'.") calc-matrix-mode calc-inverse-flag calc-hyperbolic-flag + calc-option-flag calc-keep-args-flag calc-angle-mode calc-number-radix @@ -926,6 +948,8 @@ Used by `calc-user-invocation'.") "If non-nil, next operation is Inverse.") (defvar calc-hyperbolic-flag nil "If non-nil, next operation is Hyperbolic.") +(defvar calc-option-flag nil + "If non-nil, next operation has Optional behavior.") (defvar calc-keep-args-flag nil "If non-nil, next operation should not remove its arguments from stack.") (defvar calc-function-open "(" @@ -996,9 +1020,12 @@ Used by `calc-user-invocation'.") (defvar math-working-step-2 nil) (defvar var-i '(special-const (math-imaginary 1))) (defvar var-pi '(special-const (math-pi))) +(defvar var-Ï€ '(special-const (math-pi))) (defvar var-e '(special-const (math-e))) (defvar var-phi '(special-const (math-phi))) +(defvar var-φ '(special-const (math-phi))) (defvar var-gamma '(special-const (math-gamma-const))) +(defvar var-γ '(special-const (math-gamma-const))) (defvar var-Modes '(special-const (math-get-modes-vec))) (mapc (lambda (v) (or (boundp v) (set v nil))) @@ -1038,7 +1065,7 @@ Used by `calc-user-invocation'.") (mapc (lambda (x) (define-key map (char-to-string x) 'undefined)) "lOW") (mapc (lambda (x) (define-key map (char-to-string x) 'calc-missing-key)) - (concat "ABCDEFGHIJKLMNPQRSTUVXZabcdfghjkmoprstuvwxyz" + (concat "ABCDEFGHIJKLMNOPQRSTUVXZabcdfghjkmoprstuvwxyz" ":\\|!()[]<>{},;=~`\C-k\C-w\C-_")) (define-key map "\M-w" 'calc-missing-key) (define-key map "\M-k" 'calc-missing-key) @@ -1227,7 +1254,7 @@ the trail buffer." ;; Eventually, prompt user with a list of buffers using embedded mode. (when (and info-list - (yes-or-no-p + (yes-or-no-p (concat "This Calc stack is being used for embedded mode. Kill anyway?"))) (while info-list (with-current-buffer (car (car info-list)) @@ -1379,8 +1406,7 @@ commands given here will actually operate on the *Calculator* stack." (set (make-local-variable 'calc-main-buffer) buf)) (when (= (buffer-size) 0) (let ((buffer-read-only nil)) - (insert (propertize (concat "Emacs Calculator Trail\n") - 'font-lock-face 'italic)))) + (insert (propertize "Emacs Calculator Trail\n" 'face 'italic)))) (run-mode-hooks 'calc-trail-mode-hook)) (defun calc-create-buffer () @@ -1619,6 +1645,7 @@ See calc-keypad for details." (calc-select-buffer) (setq calc-inverse-flag nil calc-hyperbolic-flag nil + calc-option-flag nil calc-keep-args-flag nil))) (when (memq 'do-edit calc-command-flags) (switch-to-buffer (get-buffer-create "*Calc Edit*"))) @@ -1757,6 +1784,7 @@ See calc-keypad for details." (> (calc-stack-size) 0) (calc-top 1 'sel)) "Sel " "") (if calc-display-dirty "Dirty " "") + (if calc-option-flag "Opt " "") (if calc-inverse-flag "Inv " "") (if calc-hyperbolic-flag "Hyp " "") (if calc-keep-args-flag "Keep " "") @@ -1968,7 +1996,7 @@ See calc-keypad for details." (erase-buffer) (when calc-show-banner (insert (propertize "--- Emacs Calculator Mode ---\n" - 'font-lock-face 'italic))) + 'face 'italic))) (while thing (goto-char (point-min)) (when calc-show-banner @@ -2378,7 +2406,7 @@ See calc-keypad for details." (progn (require 'calc-ext) (calc-digit-dots)) - (delete-backward-char 1) + (delete-char -1) (beep) (calc-temp-minibuffer-message " [Bad format]")))))) (setq calc-prev-prev-char calc-prev-char @@ -3401,7 +3429,7 @@ largest Emacs integer.") (Math-lessp a math-half-2-word-size)) (and (Math-integer-negp a) (require 'calc-ext) - (let ((comparison + (let ((comparison (math-compare (Math-integer-neg a) math-half-2-word-size))) (or (= comparison 0) (= comparison -1)))))) @@ -3545,7 +3573,7 @@ largest Emacs integer.") (math-normalize (save-match-data (cond - + ;; Integers (most common case) ((string-match "\\` *\\([0-9]+\\) *\\'" s) (let ((digs (math-match-substring s 1))) @@ -3557,22 +3585,22 @@ largest Emacs integer.") (if (<= (length digs) (* 2 math-bignum-digit-length)) (string-to-number digs) (cons 'bigpos (math-read-bignum digs)))))) - + ;; Clean up the string if necessary ((string-match "\\`\\(.*\\)[ \t\n]+\\([^\001]*\\)\\'" s) (math-read-number (concat (math-match-substring s 1) (math-match-substring s 2)))) - + ;; Plus and minus signs ((string-match "^[-_+]\\(.*\\)$" s) (let ((val (math-read-number (math-match-substring s 1)))) (and val (if (eq (aref s 0) ?+) val (math-neg val))))) - + ;; Forms that require extensions module ((string-match "[^-+0-9eE.]" s) (require 'calc-ext) (math-read-number-fancy s)) - + ;; Decimal point ((string-match "^\\([0-9]*\\)\\.\\([0-9]*\\)$" s) (let ((int (math-match-substring s 1)) @@ -3585,7 +3613,7 @@ largest Emacs integer.") (list 'float (math-add (math-scale-int int flen) frac) (- flen))))))) - + ;; "e" notation ((string-match "^\\(.*\\)[eE]\\([-+]?[0-9]+\\)$" s) (let ((mant (math-match-substring s 1)) @@ -3596,7 +3624,7 @@ largest Emacs integer.") (and mant exp (Math-realp mant) (> exp -4000000) (< exp 4000000) (let ((mant (math-float mant))) (list 'float (nth 1 mant) (+ (nth 2 mant) exp))))))) - + ;; Syntax error! (t nil))))) @@ -3789,7 +3817,7 @@ See Info node `(calc)Defining Functions'." (setq unread-command-event nil) (setq unread-command-events nil))) -(defcalcmodevar math-2-word-size +(defcalcmodevar math-2-word-size (math-read-number-simple "4294967296") "Two to the power of `calc-word-size'.") @@ -3806,5 +3834,9 @@ See Info node `(calc)Defining Functions'." (provide 'calc) +;; Local variables: +;; coding: utf-8 +;; End: + ;; arch-tag: 0c3b170c-4ce6-4eaf-8d9b-5834d1fe938f ;;; calc.el ends here diff --git a/lisp/calc/calcalg2.el b/lisp/calc/calcalg2.el index 2b45ce1b2f0..4bee751ad41 100644 --- a/lisp/calc/calcalg2.el +++ b/lisp/calc/calcalg2.el @@ -1886,9 +1886,9 @@ ;; math-scan-for-limits. (defvar calc-low) (defvar calc-high) -(defvar var) +(defvar math-var) -(defun calcFunc-table (expr var &optional calc-low calc-high step) +(defun calcFunc-table (expr math-var &optional calc-low calc-high step) (or calc-low (setq calc-low '(neg (var inf var-inf)) calc-high '(var inf var-inf))) (or calc-high (setq calc-high calc-low calc-low 1)) @@ -1917,7 +1917,7 @@ (math-working-step-2 (1+ count)) (math-working-step 0)) (setq expr (math-evaluate-expr - (math-expr-subst expr var '(var DUMMY var-DUMMY)))) + (math-expr-subst expr math-var '(var DUMMY var-DUMMY)))) (while (>= count 0) (setq math-working-step (1+ math-working-step) var-DUMMY calc-low @@ -1940,7 +1940,7 @@ (calc-record-why 'integerp calc-high)) (calc-record-why 'integerp calc-low))) (append (list (or math-tabulate-function 'calcFunc-table) - expr var) + expr math-var) (and (not (and (equal calc-low '(neg (var inf var-inf))) (equal calc-high '(var inf var-inf)))) (list calc-low calc-high)) @@ -1950,11 +1950,11 @@ (cond ((Math-primp x)) ((and (eq (car x) 'calcFunc-subscr) (Math-vectorp (nth 1 x)) - (math-expr-contains (nth 2 x) var)) + (math-expr-contains (nth 2 x) math-var)) (let* ((calc-next-why nil) - (low-val (math-solve-for (nth 2 x) 1 var nil)) + (low-val (math-solve-for (nth 2 x) 1 math-var nil)) (high-val (math-solve-for (nth 2 x) (1- (length (nth 1 x))) - var nil)) + math-var nil)) temp) (and low-val (math-realp low-val) high-val (math-realp high-val)) diff --git a/lisp/calc/calccomp.el b/lisp/calc/calccomp.el index c7d3469abe0..6923cd7693a 100644 --- a/lisp/calc/calccomp.el +++ b/lisp/calc/calccomp.el @@ -1,7 +1,7 @@ ;;; calccomp.el --- composition functions for Calc -;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004, 2005, +;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: David Gillespie <daveg@synaptics.com> ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com> @@ -50,19 +50,19 @@ ;;; ;;; (tag X C) Composition C corresponds to sub-expression X -;; math-comp-just and math-comp-comma-spc are local to -;; math-compose-expr, but are used by math-compose-matrix, which is +;; math-comp-just and math-comp-comma-spc are local to +;; math-compose-expr, but are used by math-compose-matrix, which is ;; called by math-compose-expr (defvar math-comp-just) (defvar math-comp-comma-spc) -;; math-comp-vector-prec is local to math-compose-expr, but is used by -;; math-compose-matrix and math-compose-rows, which are called by +;; math-comp-vector-prec is local to math-compose-expr, but is used by +;; math-compose-matrix and math-compose-rows, which are called by ;; math-compose-expr. (defvar math-comp-vector-prec) -;; math-comp-left-bracket, math-comp-right-bracket and math-comp-comma are -;; local to math-compose-expr, but are used by math-compose-rows, which is +;; math-comp-left-bracket, math-comp-right-bracket and math-comp-comma are +;; local to math-compose-expr, but are used by math-compose-rows, which is ;; called by math-compose-expr. (defvar math-comp-left-bracket) (defvar math-comp-right-bracket) @@ -100,7 +100,7 @@ (list 'tag a (math-compose-expr a prec)))) ((and (not (consp a)) (not (integerp a))) (concat "'" (prin1-to-string a))) - ((setq spfn (assq (car-safe a) + ((setq spfn (assq (car-safe a) (get calc-language 'math-special-function-table))) (setq spfn (cdr spfn)) (if (consp spfn) @@ -111,12 +111,12 @@ (and (nth 1 calc-frac-format) (Math-integerp a))) (if (and calc-language - (not (memq calc-language + (not (memq calc-language '(flat big unform)))) (let ((aa (math-adjust-fraction a)) (calc-frac-format nil)) (math-compose-expr (list '/ - (if (memq calc-language + (if (memq calc-language calc-lang-slash-idiv) (math-float (nth 1 aa)) (nth 1 aa)) @@ -281,22 +281,22 @@ (cdr a) (if full rows 3) t))))) (if (or calc-full-vectors (< (length a) 7)) - (if (and + (if (and (setq spfn (get calc-language 'math-matrix-formatter)) (math-matrixp a)) (funcall spfn a) (list 'horiz math-comp-left-bracket - (math-compose-vector (cdr a) + (math-compose-vector (cdr a) (concat math-comp-comma " ") math-comp-vector-prec) math-comp-right-bracket)) (list 'horiz math-comp-left-bracket (math-compose-vector (list (nth 1 a) (nth 2 a) (nth 3 a)) - (concat math-comp-comma " ") + (concat math-comp-comma " ") math-comp-vector-prec) - math-comp-comma + math-comp-comma (if (setq spfn (get calc-language 'math-dots)) (concat " " spfn) " ...") @@ -663,6 +663,8 @@ (and prevc nextc (or (and (>= nextc ?a) (<= nextc ?z)) (and (>= nextc ?A) (<= nextc ?Z)) + (and (>= nextc ?α) (<= nextc ?ω)) + (and (>= nextc ?Α) (<= nextc ?Ω)) (and (>= nextc ?0) (<= nextc ?9)) (memq nextc '(?. ?_ ?# ?\( ?\[ ?\{)) @@ -732,7 +734,7 @@ (not (math-tex-expr-is-flat (nth 1 a)))))) (list 'horiz (if lr "\\left" "") - (if (string-match "\\`u\\([^a-zA-Z]\\)\\'" (car op)) + (if (string-match "\\`u\\([^a-zA-Zα-ωΑ-Ω]\\)\\'" (car op)) (substring (car op) 1) (car op)) (if (or lr (> (length (car op)) 2)) " " "") @@ -758,7 +760,7 @@ (t (let ((rhs (math-compose-expr (nth 1 a) (nth 3 op)))) (list 'horiz - (let ((ops (if (string-match "\\`u\\([^a-zA-Z]\\)\\'" + (let ((ops (if (string-match "\\`u\\([^a-zA-Zα-ωΑ-Ω]\\)\\'" (car op)) (substring (car op) 1) (car op)))) @@ -806,7 +808,7 @@ (setq func (car func2))) (setq func (math-remove-dashes (if (string-match - "\\`calcFunc-\\([a-zA-Z0-9']+\\)\\'" + "\\`calcFunc-\\([a-zA-Zα-ωΑ-Ω0-9']+\\)\\'" (symbol-name func)) (math-match-substring (symbol-name func) 1) (symbol-name func)))) @@ -867,7 +869,7 @@ math-comp-vector-prec) (if (= col cols) "" - (concat + (concat math-comp-comma-spc " "))))) a))) res))) @@ -878,7 +880,7 @@ (if (<= count 0) (if (< count 0) (math-compose-rows (cdr a) -1 nil) - (cons (concat + (cons (concat (let ((mdots (get calc-language 'math-dots))) (if mdots (concat " " mdots) @@ -1117,7 +1119,7 @@ (if (memq prec '(196 201)) ")" ""))))) ;; The variables math-svo-c, math-svo-wid and math-svo-off are local -;; to math-stack-value-offset in calc.el, but are used by +;; to math-stack-value-offset in calc.el, but are used by ;; math-stack-value-offset-fancy, which is called by math-stack-value-offset.. (defvar math-svo-c) (defvar math-svo-wid) @@ -1193,11 +1195,11 @@ ;;; of the formula. ;; The variables math-comp-full-width, math-comp-highlight, math-comp-word, -;; math-comp-level, math-comp-margin and math-comp-buf are local to -;; math-comp-to-string-flat, but are used by math-comp-to-string-flat-term, +;; math-comp-level, math-comp-margin and math-comp-buf are local to +;; math-comp-to-string-flat, but are used by math-comp-to-string-flat-term, ;; which is called by math-comp-to-string-flat. -;; math-comp-highlight and math-comp-buf are also local to -;; math-comp-simplify-term and math-comp-simplify respectively, but are used +;; math-comp-highlight and math-comp-buf are also local to +;; math-comp-simplify-term and math-comp-simplify respectively, but are used ;; by math-comp-add-string. (defvar math-comp-full-width) (defvar math-comp-highlight) @@ -1242,7 +1244,7 @@ (cond ((not (consp c)) (if math-comp-highlight (setq c (math-comp-highlight-string c))) - (setq math-comp-word (if (= (length math-comp-word) 0) c + (setq math-comp-word (if (= (length math-comp-word) 0) c (concat math-comp-word c)) math-comp-pos (+ math-comp-pos (length c)))) @@ -1337,16 +1339,19 @@ (defun math-comp-highlight-string (s) (setq s (copy-sequence s)) - (let ((i (length s))) - (while (>= (setq i (1- i)) 0) - (or (memq (aref s i) '(32 ?\n)) - (aset s i (if calc-show-selections ?\. ?\#))))) - s) - + (if calc-highlight-selections-with-faces + (if (not calc-show-selections) + (propertize s 'face 'calc-selected-face) + (propertize s 'face 'calc-nonselected-face)) + (let ((i (length s))) + (while (>= (setq i (1- i)) 0) + (or (memq (aref s i) '(32 ?\n)) + (aset s i (if calc-show-selections ?\. ?\#))))) + s)) ;; The variable math-comp-sel-tag is local to calc-find-selected-part -;; in calc-sel.el, but is used by math-comp-sel-flat-term and -;; math-comp-add-string-sel, which are called (indirectly) by +;; in calc-sel.el, but is used by math-comp-sel-flat-term and +;; math-comp-add-string-sel, which are called (indirectly) by ;; calc-find-selected-part. (defvar math-comp-sel-tag) @@ -1666,5 +1671,9 @@ (provide 'calccomp) +;; Local variables: +;; coding: utf-8 +;; End: + ;; arch-tag: 7c45d10a-a286-4dab-af49-7ae8989fbf78 ;;; calccomp.el ends here |