aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Belanger2012-08-09 09:46:03 -0500
committerJay Belanger2012-08-09 09:46:03 -0500
commit31673780356f219c7a26251b2f79fb00c8e29f0b (patch)
tree31e041714b6c5fc56ee6ba259f3d3a637e561053
parentdee4ef9388bd6cf5530e71736e0298b42382f32e (diff)
downloademacs-31673780356f219c7a26251b2f79fb00c8e29f0b.tar.gz
emacs-31673780356f219c7a26251b2f79fb00c8e29f0b.zip
calccomp.el (math-compose-expr): Add extra argument indicating that
parentheses should be put around products in denominators. Give multiplication precedence over division during composition.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/calc/calccomp.el13
2 files changed, 16 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 23cd53f1246..fef050e6d02 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12012-08-09 Jay Belanger <jay.p.belanger@gmail.com>
2
3 * calc/calccomp.el (math-compose-expr): Add extra argument
4 indicating that parentheses should be put around products in
5 denominators. Give multiplication precedence over division during
6 composition.
7
12012-08-09 Chong Yidong <cyd@gnu.org> 82012-08-09 Chong Yidong <cyd@gnu.org>
2 9
3 * man.el (Man-switches, Man-sed-command, Man-awk-command) 10 * man.el (Man-switches, Man-sed-command, Man-awk-command)
diff --git a/lisp/calc/calccomp.el b/lisp/calc/calccomp.el
index d8ad7e2cede..51ea8e7b7a3 100644
--- a/lisp/calc/calccomp.el
+++ b/lisp/calc/calccomp.el
@@ -86,8 +86,11 @@
86 (setq sn (math-to-underscores sn))) 86 (setq sn (math-to-underscores sn)))
87 sn))) 87 sn)))
88 88
89(defun math-compose-expr (a prec) 89;;; Give multiplication precendence when composing to avoid
90 (let ((math-compose-level (1+ math-compose-level)) 90;;; writing a*(b c) instead of a b c
91(defun math-compose-expr (a prec &optional div)
92 (let ((calc-multiplication-has-precedence t)
93 (math-compose-level (1+ math-compose-level))
91 (math-expr-opers (math-expr-ops)) 94 (math-expr-opers (math-expr-ops))
92 spfn) 95 spfn)
93 (cond 96 (cond
@@ -591,7 +594,9 @@
591 (or (= (length a) 3) (eq (car a) 'calcFunc-if)) 594 (or (= (length a) 3) (eq (car a) 'calcFunc-if))
592 (/= (nth 3 op) -1)) 595 (/= (nth 3 op) -1))
593 (cond 596 (cond
594 ((> prec (or (nth 4 op) (min (nth 2 op) (nth 3 op)))) 597 ((or
598 (> prec (or (nth 4 op) (min (nth 2 op) (nth 3 op))))
599 (and div (eq (car a) '*)))
595 (if (and (memq calc-language '(tex latex)) 600 (if (and (memq calc-language '(tex latex))
596 (not (math-tex-expr-is-flat a))) 601 (not (math-tex-expr-is-flat a)))
597 (if (eq (car-safe a) '/) 602 (if (eq (car-safe a) '/)
@@ -631,7 +636,7 @@
631 nil) 636 nil)
632 math-compose-level)) 637 math-compose-level))
633 (lhs (math-compose-expr (nth 1 a) (nth 2 op))) 638 (lhs (math-compose-expr (nth 1 a) (nth 2 op)))
634 (rhs (math-compose-expr (nth 2 a) (nth 3 op)))) 639 (rhs (math-compose-expr (nth 2 a) (nth 3 op) (eq (nth 1 op) '/))))
635 (and (equal (car op) "^") 640 (and (equal (car op) "^")
636 (eq (math-comp-first-char lhs) ?-) 641 (eq (math-comp-first-char lhs) ?-)
637 (setq lhs (list 'horiz "(" lhs ")"))) 642 (setq lhs (list 'horiz "(" lhs ")")))