[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/calc/calccomp.el
From: |
Jay Belanger |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/calc/calccomp.el |
Date: |
Mon, 31 Jan 2005 01:30:37 -0500 |
Index: emacs/lisp/calc/calccomp.el
diff -c emacs/lisp/calc/calccomp.el:1.8 emacs/lisp/calc/calccomp.el:1.9
*** emacs/lisp/calc/calccomp.el:1.8 Tue Nov 30 17:31:45 2004
--- emacs/lisp/calc/calccomp.el Mon Jan 31 06:30:37 2005
***************
*** 79,85 ****
(defun math-compose-expr (a prec)
! (let ((math-compose-level (1+ math-compose-level)))
(cond
((or (and (eq a math-comp-selected) a)
(and math-comp-tagged
--- 79,86 ----
(defun math-compose-expr (a prec)
! (let ((math-compose-level (1+ math-compose-level))
! spfn)
(cond
((or (and (eq a math-comp-selected) a)
(and math-comp-tagged
***************
*** 89,98 ****
(list 'tag a (math-compose-expr a prec))))
((and (not (consp a)) (not (integerp a)))
(concat "'" (prin1-to-string a)))
((math-scalarp a)
(if (or (eq (car-safe a) 'frac)
(and (nth 1 calc-frac-format) (Math-integerp a)))
! (if (memq calc-language '(tex eqn math maple c fortran pascal))
(let ((aa (math-adjust-fraction a))
(calc-frac-format nil))
(math-compose-expr (list '/
--- 90,102 ----
(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) math-expr-special-function-mapping))
+ (setq spfn (cdr spfn))
+ (funcall (car spfn) a spfn))
((math-scalarp a)
(if (or (eq (car-safe a) 'frac)
(and (nth 1 calc-frac-format) (Math-integerp a)))
! (if (memq calc-language '(tex latex eqn math maple c fortran pascal))
(let ((aa (math-adjust-fraction a))
(calc-frac-format nil))
(math-compose-expr (list '/
***************
*** 265,298 ****
(append '(horiz "\\matrix{ ")
(math-compose-tex-matrix (cdr a))
'(" }"))
! (if (and (eq calc-language 'eqn)
! (math-matrixp a))
! (append '(horiz "matrix { ")
! (math-compose-eqn-matrix
! (cdr (math-transpose a)))
! '("}"))
! (if (and (eq calc-language 'maple)
! (math-matrixp a))
! (list 'horiz
! "matrix("
! math-comp-left-bracket
! (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 (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 " ")
math-comp-vector-prec)
! math-comp-comma (if (eq calc-language 'tex) " \\ldots" "
...")
math-comp-comma " "
(list 'break math-compose-level)
(math-compose-expr (nth (1- (length a)) a)
--- 269,312 ----
(append '(horiz "\\matrix{ ")
(math-compose-tex-matrix (cdr a))
'(" }"))
! (if (and (eq calc-language 'latex)
! (math-matrixp a))
! (if (memq calc-language-option '(-2 0 2))
! (append '(vleft 0 "\\begin{pmatrix}")
! (math-compose-tex-matrix (cdr a))
! '("\\end{pmatrix}"))
! (append '(horiz "\\begin{pmatrix} ")
! (math-compose-tex-matrix (cdr a))
! '(" \\end{pmatrix}")))
! (if (and (eq calc-language 'eqn)
! (math-matrixp a))
! (append '(horiz "matrix { ")
! (math-compose-eqn-matrix
! (cdr (math-transpose a)))
! '("}"))
! (if (and (eq calc-language 'maple)
! (math-matrixp a))
! (list 'horiz
! "matrix("
! math-comp-left-bracket
! (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 (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 " ")
math-comp-vector-prec)
! math-comp-comma (if (memq calc-language '(tex latex))
! " \\ldots" " ...")
math-comp-comma " "
(list 'break math-compose-level)
(math-compose-expr (nth (1- (length a)) a)
***************
*** 326,337 ****
(let ((v (rassq (nth 2 a) math-expr-variable-mapping)))
(if v
(symbol-name (car v))
! (if (and (eq calc-language 'tex)
calc-language-option
(not (= calc-language-option 0))
(string-match "\\`[a-zA-Z][a-zA-Z0-9]+\\'"
(symbol-name (nth 1 a))))
! (format "\\hbox{%s}" (symbol-name (nth 1 a)))
(if (and math-compose-hash-args
(let ((p calc-arg-values))
(setq v 1)
--- 340,353 ----
(let ((v (rassq (nth 2 a) math-expr-variable-mapping)))
(if v
(symbol-name (car v))
! (if (and (memq calc-language '(tex latex))
calc-language-option
(not (= calc-language-option 0))
(string-match "\\`[a-zA-Z][a-zA-Z0-9]+\\'"
(symbol-name (nth 1 a))))
! (if (eq calc-language 'latex)
! (format "\\text{%s}" (symbol-name (nth 1 a)))
! (format "\\hbox{%s}" (symbol-name (nth 1 a))))
(if (and math-compose-hash-args
(let ((p calc-arg-values))
(setq v 1)
***************
*** 359,365 ****
(if (eq calc-language 'maple) ""
(if (memq (nth 1 a) '(0 1)) "(" "["))
(math-compose-expr (nth 2 a) 0)
! (if (eq calc-language 'tex) " \\ldots "
(if (eq calc-language 'eqn) " ... " " .. "))
(math-compose-expr (nth 3 a) 0)
(if (eq calc-language 'maple) ""
--- 375,381 ----
(if (eq calc-language 'maple) ""
(if (memq (nth 1 a) '(0 1)) "(" "["))
(math-compose-expr (nth 2 a) 0)
! (if (memq calc-language '(tex latex)) " \\ldots "
(if (eq calc-language 'eqn) " ... " " .. "))
(math-compose-expr (nth 3 a) 0)
(if (eq calc-language 'maple) ""
***************
*** 404,410 ****
(math-compose-expr (nth 2 a) 0)
"]]"))
((and (eq (car a) 'calcFunc-sqrt)
! (eq calc-language 'tex))
(list 'horiz
"\\sqrt{"
(math-compose-expr (nth 1 a) 0)
--- 420,426 ----
(math-compose-expr (nth 2 a) 0)
"]]"))
((and (eq (car a) 'calcFunc-sqrt)
! (memq calc-language '(tex latex)))
(list 'horiz
"\\sqrt{"
(math-compose-expr (nth 1 a) 0)
***************
*** 440,446 ****
(math-comp-height a1)
a1 '(rule ?-) a2)))
((and (memq (car a) '(calcFunc-sum calcFunc-prod))
! (eq calc-language 'tex)
(= (length a) 5))
(list 'horiz (if (eq (car a) 'calcFunc-sum) "\\sum" "\\prod")
"_{" (math-compose-expr (nth 2 a) 0)
--- 456,462 ----
(math-comp-height a1)
a1 '(rule ?-) a2)))
((and (memq (car a) '(calcFunc-sum calcFunc-prod))
! (memq calc-language '(tex latex))
(= (length a) 5))
(list 'horiz (if (eq (car a) 'calcFunc-sum) "\\sum" "\\prod")
"_{" (math-compose-expr (nth 2 a) 0)
***************
*** 495,501 ****
(integerp (nth 2 a)))
(let ((c (math-compose-expr (nth 1 a) -1)))
(if (> prec (nth 2 a))
! (if (eq calc-language 'tex)
(list 'horiz "\\left( " c " \\right)")
(if (eq calc-language 'eqn)
(list 'horiz "{left ( " c " right )}")
--- 511,517 ----
(integerp (nth 2 a)))
(let ((c (math-compose-expr (nth 1 a) -1)))
(if (> prec (nth 2 a))
! (if (memq calc-language '(tex latex))
(list 'horiz "\\left( " c " \\right)")
(if (eq calc-language 'eqn)
(list 'horiz "{left ( " c " right )}")
***************
*** 633,645 ****
(make-list (nth 1 a) c))))))
((and (eq (car a) 'calcFunc-evalto)
(setq calc-any-evaltos t)
! (memq calc-language '(tex eqn))
(= math-compose-level (if math-comp-tagged 2 1))
(= (length a) 3))
(list 'horiz
! (if (eq calc-language 'tex) "\\evalto " "evalto ")
(math-compose-expr (nth 1 a) 0)
! (if (eq calc-language 'tex) " \\to " " -> ")
(math-compose-expr (nth 2 a) 0)))
(t
(let ((op (and (not (eq calc-language 'unform))
--- 649,661 ----
(make-list (nth 1 a) c))))))
((and (eq (car a) 'calcFunc-evalto)
(setq calc-any-evaltos t)
! (memq calc-language '(tex latex eqn))
(= math-compose-level (if math-comp-tagged 2 1))
(= (length a) 3))
(list 'horiz
! (if (memq calc-language '(tex latex)) "\\evalto " "evalto ")
(math-compose-expr (nth 1 a) 0)
! (if (memq calc-language '(tex latex)) " \\to " " -> ")
(math-compose-expr (nth 2 a) 0)))
(t
(let ((op (and (not (eq calc-language 'unform))
***************
*** 651,657 ****
(/= (nth 3 op) -1))
(cond
((> prec (or (nth 4 op) (min (nth 2 op) (nth 3 op))))
! (if (and (eq calc-language 'tex)
(not (math-tex-expr-is-flat a)))
(if (eq (car-safe a) '/)
(list 'horiz "{" (math-compose-expr a -1) "}")
--- 667,673 ----
(/= (nth 3 op) -1))
(cond
((> prec (or (nth 4 op) (min (nth 2 op) (nth 3 op))))
! (if (and (memq calc-language '(tex latex))
(not (math-tex-expr-is-flat a)))
(if (eq (car-safe a) '/)
(list 'horiz "{" (math-compose-expr a -1) "}")
***************
*** 668,674 ****
(math-compose-expr a -1)
" right )}")))
(list 'horiz "(" (math-compose-expr a 0) ")"))))
! ((and (eq calc-language 'tex)
(memq (car a) '(/ calcFunc-choose calcFunc-evalto))
(>= prec 0))
(list 'horiz "{" (math-compose-expr a -1) "}"))
--- 684,690 ----
(math-compose-expr a -1)
" right )}")))
(list 'horiz "(" (math-compose-expr a 0) ")"))))
! ((and (memq calc-language '(tex latex))
(memq (car a) '(/ calcFunc-choose calcFunc-evalto))
(>= prec 0))
(list 'horiz "{" (math-compose-expr a -1) "}"))
***************
*** 694,700 ****
(and (equal (car op) "^")
(eq (math-comp-first-char lhs) ?-)
(setq lhs (list 'horiz "(" lhs ")")))
! (and (eq calc-language 'tex)
(or (equal (car op) "^") (equal (car op) "_"))
(not (and (stringp rhs) (= (length rhs) 1)))
(setq rhs (list 'horiz "{" rhs "}")))
--- 710,716 ----
(and (equal (car op) "^")
(eq (math-comp-first-char lhs) ?-)
(setq lhs (list 'horiz "(" lhs ")")))
! (and (memq calc-language '(tex latex))
(or (equal (car op) "^") (equal (car op) "_"))
(not (and (stringp rhs) (= (length rhs) 1)))
(setq rhs (list 'horiz "{" rhs "}")))
***************
*** 761,767 ****
((or (> prec (or (nth 4 op) (nth 2 op)))
(and (not (eq (assoc (car op) math-expr-opers) op))
(> prec 0))) ; don't write x% + y
! (if (and (eq calc-language 'tex)
(not (math-tex-expr-is-flat a)))
(list 'horiz "\\left( "
(math-compose-expr a -1)
--- 777,783 ----
((or (> prec (or (nth 4 op) (nth 2 op)))
(and (not (eq (assoc (car op) math-expr-opers) op))
(> prec 0))) ; don't write x% + y
! (if (and (memq calc-language '(tex latex))
(not (math-tex-expr-is-flat a)))
(list 'horiz "\\left( "
(math-compose-expr a -1)
***************
*** 786,792 ****
((and op (= (length a) 2) (= (nth 2 op) -1))
(cond
((eq (nth 3 op) 0)
! (let ((lr (and (eq calc-language 'tex)
(not (math-tex-expr-is-flat (nth 1 a))))))
(list 'horiz
(if lr "\\left" "")
--- 802,808 ----
((and op (= (length a) 2) (= (nth 2 op) -1))
(cond
((eq (nth 3 op) 0)
! (let ((lr (and (memq calc-language '(tex latex))
(not (math-tex-expr-is-flat (nth 1 a))))))
(list 'horiz
(if lr "\\left" "")
***************
*** 799,805 ****
(if lr "\\right" "")
(car (nth 1 (memq op math-expr-opers))))))
((> prec (or (nth 4 op) (nth 3 op)))
! (if (and (eq calc-language 'tex)
(not (math-tex-expr-is-flat a)))
(list 'horiz "\\left( "
(math-compose-expr a -1)
--- 815,821 ----
(if lr "\\right" "")
(car (nth 1 (memq op math-expr-opers))))))
((> prec (or (nth 4 op) (nth 3 op)))
! (if (and (memq calc-language '(tex latex))
(not (math-tex-expr-is-flat a)))
(list 'horiz "\\left( "
(math-compose-expr a -1)
***************
*** 836,841 ****
--- 852,858 ----
( pascal . math-compose-pascal )
( fortran . math-compose-fortran )
( tex . math-compose-tex )
+ ( latex . math-compose-latex )
( eqn . math-compose-eqn )
( math . math-compose-math )
( maple . math-compose-maple ))))
***************
*** 866,885 ****
(symbol-name func))))
(if (memq calc-language '(c fortran pascal maple))
(setq func (math-to-underscores func)))
! (if (and (eq calc-language 'tex)
calc-language-option
(not (= calc-language-option 0))
(string-match "\\`[a-zA-Z][a-zA-Z0-9]+\\'" func))
(if (< (prefix-numeric-value calc-language-option) 0)
(setq func (format "\\%s" func))
! (setq func (format "\\hbox{%s}" func))))
(if (and (eq calc-language 'eqn)
(string-match "[^']'+\\'" func))
(let ((n (- (length func) (match-beginning 0) 1)))
(setq func (substring func 0 (- n)))
(while (>= (setq n (1- n)) 0)
(setq func (concat func " prime")))))
! (cond ((and (eq calc-language 'tex)
(or (> (length a) 2)
(not (math-tex-expr-is-flat (nth 1 a)))))
(setq left "\\left( "
--- 883,904 ----
(symbol-name func))))
(if (memq calc-language '(c fortran pascal maple))
(setq func (math-to-underscores func)))
! (if (and (memq calc-language '(tex latex))
calc-language-option
(not (= calc-language-option 0))
(string-match "\\`[a-zA-Z][a-zA-Z0-9]+\\'" func))
(if (< (prefix-numeric-value calc-language-option) 0)
(setq func (format "\\%s" func))
! (setq func (if (eq calc-language 'latex)
! (format "\\text{%s}" func)
! (format "\\hbox{%s}" func)))))
(if (and (eq calc-language 'eqn)
(string-match "[^']'+\\'" func))
(let ((n (- (length func) (match-beginning 0) 1)))
(setq func (substring func 0 (- n)))
(while (>= (setq n (1- n)) 0)
(setq func (concat func " prime")))))
! (cond ((and (eq calc-language '(tex latex))
(or (> (length a) 2)
(not (math-tex-expr-is-flat (nth 1 a)))))
(setq left "\\left( "
***************
*** 889,899 ****
(not (math-tex-expr-is-flat (nth 1 a)))))
(setq left "{left ( "
right " right )}"))
! ((and (or (and (eq calc-language 'tex)
(eq (aref func 0) ?\\))
(and (eq calc-language 'eqn)
(memq (car a) math-eqn-special-funcs)))
! (not (string-match "\\hbox{" func))
(= (length a) 2)
(or (Math-realp (nth 1 a))
(memq (car (nth 1 a)) '(var *))))
--- 908,920 ----
(not (math-tex-expr-is-flat (nth 1 a)))))
(setq left "{left ( "
right " right )}"))
! ((and (or (and (memq calc-language '(tex latex))
(eq (aref func 0) ?\\))
(and (eq calc-language 'eqn)
(memq (car a) math-eqn-special-funcs)))
! (not (or
! (string-match "\\hbox{" func)
! (string-match "\\text{" func)))
(= (length a) 2)
(or (Math-realp (nth 1 a))
(memq (car (nth 1 a)) '(var *))))
***************
*** 968,974 ****
(if (<= count 0)
(if (< count 0)
(math-compose-rows (cdr a) -1 nil)
! (cons (concat (if (eq calc-language 'tex) " \\ldots" " ...")
math-comp-comma)
(math-compose-rows (cdr a) -1 nil)))
(cons (list 'horiz
--- 989,995 ----
(if (<= count 0)
(if (< count 0)
(math-compose-rows (cdr a) -1 nil)
! (cons (concat (if (memq calc-language '(tex latex)) " \\ldots" "
...")
math-comp-comma)
(math-compose-rows (cdr a) -1 nil)))
(cons (list 'horiz
***************
*** 983,991 ****
(defun math-compose-tex-matrix (a)
(if (cdr a)
! (cons (math-compose-vector (cdr (car a)) " & " 0)
! (cons " \\\\ "
! (math-compose-tex-matrix (cdr a))))
(list (math-compose-vector (cdr (car a)) " & " 0))))
(defun math-compose-eqn-matrix (a)
--- 1004,1011 ----
(defun math-compose-tex-matrix (a)
(if (cdr a)
! (cons (append (math-compose-vector (cdr (car a)) " & " 0) '(" \\\\ "))
! (math-compose-tex-matrix (cdr a)))
(list (math-compose-vector (cdr (car a)) " & " 0))))
(defun math-compose-eqn-matrix (a)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] Changes to emacs/lisp/calc/calccomp.el,
Jay Belanger <=