emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master add1314 2/3: Calc: revert to old precedence of '/' in (La)TeX inp


From: Mattias Engdegård
Subject: master add1314 2/3: Calc: revert to old precedence of '/' in (La)TeX input mode
Date: Tue, 13 Oct 2020 05:34:05 -0400 (EDT)

branch: master
commit add1314195b193f04164cebe558d7a185b61de96
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    Calc: revert to old precedence of '/' in (La)TeX input mode
    
    Make the '/' precedence higher than that of '+' and '-' again,
    partially reverting fda9b316f84 (bug#43902).
    
    * lisp/calc/calc-lang.el (tex): Change precedence of '/'.
    * test/lisp/calc/calc-tests.el (calc-latex-input): New test.
---
 lisp/calc/calc-lang.el       |  2 +-
 test/lisp/calc/calc-tests.el | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/lisp/calc/calc-lang.el b/lisp/calc/calc-lang.el
index 1c270cf..bde5abe 100644
--- a/lisp/calc/calc-lang.el
+++ b/lisp/calc/calc-lang.el
@@ -468,10 +468,10 @@
      ( "\\times"  *               191 190 )
      ( "*"        *               191 190 )
      ( "2x"      *                191 190 )
+     ( "/"       /                185 186 )
      ( "+"       +                180 181 )
      ( "-"       -                180 181 )
      ( "\\over"          /                170 171 )
-     ( "/"       /                170 171 )
      ( "\\choose" calcFunc-choose  170 171 )
      ( "\\mod"   %                170 171 )
      ( "<"       calcFunc-lt      160 161 )
diff --git a/test/lisp/calc/calc-tests.el b/test/lisp/calc/calc-tests.el
index d08a1f6..fd16102 100644
--- a/test/lisp/calc/calc-tests.el
+++ b/test/lisp/calc/calc-tests.el
@@ -636,6 +636,25 @@ An existing calc stack is reused, otherwise a new one is 
created."
         (should (equal (calcFunc-rot x n w)
                        (calc-tests--rot x n w)))))))
 
+(ert-deftest calc-latex-input ()
+  ;; Check precedence of "/" in LaTeX input mode.
+  (should (equal (math-read-exprs "a+b/c*d")
+                 '((+ (var a var-a) (/ (var b var-b)
+                                       (* (var c var-c) (var d var-d)))))))
+  (unwind-protect
+      (progn
+        (calc-set-language 'latex)
+        (should (equal (math-read-exprs "a+b/c*d")
+                 '((+ (var a var-a) (/ (var b var-b)
+                                       (* (var c var-c) (var d var-d)))))))
+        (should (equal (math-read-exprs "a+b\\over c*d")
+                       '((/ (+ (var a var-a) (var b var-b))
+                            (* (var c var-c) (var d var-d))))))
+        (should (equal (math-read-exprs "a/b/c")
+                       '((/ (/ (var a var-a) (var b var-b))
+                            (var c var-c))))))
+    (calc-set-language nil)))
+
 (provide 'calc-tests)
 ;;; calc-tests.el ends here
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]