[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r109536: calccomp.el (math-compose-ex
From: |
Jay Belanger |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r109536: calccomp.el (math-compose-expr): Add extra argument indicating that |
Date: |
Thu, 09 Aug 2012 09:46:03 -0500 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 109536
committer: Jay Belanger <address@hidden>
branch nick: trunk
timestamp: Thu 2012-08-09 09:46:03 -0500
message:
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.
modified:
lisp/ChangeLog
lisp/calc/calccomp.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2012-08-09 13:37:31 +0000
+++ b/lisp/ChangeLog 2012-08-09 14:46:03 +0000
@@ -1,3 +1,10 @@
+2012-08-09 Jay Belanger <address@hidden>
+
+ * calc/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.
+
2012-08-09 Chong Yidong <address@hidden>
* man.el (Man-switches, Man-sed-command, Man-awk-command)
=== modified file 'lisp/calc/calccomp.el'
--- a/lisp/calc/calccomp.el 2012-07-27 15:05:13 +0000
+++ b/lisp/calc/calccomp.el 2012-08-09 14:46:03 +0000
@@ -86,8 +86,11 @@
(setq sn (math-to-underscores sn)))
sn)))
-(defun math-compose-expr (a prec)
- (let ((math-compose-level (1+ math-compose-level))
+;;; Give multiplication precendence when composing to avoid
+;;; writing a*(b c) instead of a b c
+(defun math-compose-expr (a prec &optional div)
+ (let ((calc-multiplication-has-precedence t)
+ (math-compose-level (1+ math-compose-level))
(math-expr-opers (math-expr-ops))
spfn)
(cond
@@ -591,7 +594,9 @@
(or (= (length a) 3) (eq (car a) 'calcFunc-if))
(/= (nth 3 op) -1))
(cond
- ((> prec (or (nth 4 op) (min (nth 2 op) (nth 3 op))))
+ ((or
+ (> prec (or (nth 4 op) (min (nth 2 op) (nth 3 op))))
+ (and div (eq (car a) '*)))
(if (and (memq calc-language '(tex latex))
(not (math-tex-expr-is-flat a)))
(if (eq (car-safe a) '/)
@@ -631,7 +636,7 @@
nil)
math-compose-level))
(lhs (math-compose-expr (nth 1 a) (nth 2 op)))
- (rhs (math-compose-expr (nth 2 a) (nth 3 op))))
+ (rhs (math-compose-expr (nth 2 a) (nth 3 op) (eq (nth 1
op) '/))))
(and (equal (car op) "^")
(eq (math-comp-first-char lhs) ?-)
(setq lhs (list 'horiz "(" lhs ")")))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r109536: calccomp.el (math-compose-expr): Add extra argument indicating that,
Jay Belanger <=