changeset 87417:ee7bf7cfd6b4

(math-to-percentsigns): New function. (math-compose-var): Handle variables with percent signs. (math-compose-expr): Handle function names with percent signs.
author Jay Belanger <jay.p.belanger@gmail.com>
date Wed, 26 Dec 2007 17:33:29 +0000
parents 87a6da15351c
children ba5aa1d3da46
files lisp/calc/calccomp.el
diffstat 1 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/calc/calccomp.el	Wed Dec 26 17:32:13 2007 +0000
+++ b/lisp/calc/calccomp.el	Wed Dec 26 17:33:29 2007 +0000
@@ -71,7 +71,7 @@
 (defvar math-comp-comma)
 
 (defun math-compose-var (a)
-  (let (v)
+  (let (v sn)
     (if (and math-compose-hash-args
              (let ((p calc-arg-values))
                (setq v 1)
@@ -82,9 +82,12 @@
         (if (eq math-compose-hash-args 1)
             "#"
           (format "#%d" v))
+      (setq sn (symbol-name (nth 1 a)))
+      (if (memq calc-language calc-lang-allow-percentsigns)
+          (setq sn (math-to-percentsigns sn)))
       (if (memq calc-language calc-lang-allow-underscores)
-          (math-to-underscores (symbol-name (nth 1 a)))
-        (symbol-name (nth 1 a))))))
+          (setq sn (math-to-underscores sn)))
+      sn)))
 
 (defun math-compose-expr (a prec)
   (let ((math-compose-level (1+ math-compose-level))
@@ -805,6 +808,8 @@
 				  (symbol-name func))
 				 (math-match-substring (symbol-name func) 1)
 			       (symbol-name func))))
+		 (if (memq calc-language calc-lang-allow-percentsigns)
+		     (setq func (math-to-percentsigns func)))
 		 (if (memq calc-language calc-lang-allow-underscores)
 		     (setq func (math-to-underscores func)))
                  (if (setq spfn (get calc-language 'math-func-formatter))
@@ -939,6 +944,14 @@
        (concat (math-match-substring x 1) "_" (math-match-substring x 2)))
     x))
 
+(defun math-to-percentsigns (x)
+  (if (string-match "^I#'" x)
+      (setq x (concat "%" (substring x 3))))
+  (if (string-match "\\`\\(.*\\)'\\(.*\\)\\'" x)
+      (math-to-percentsigns
+       (concat (math-match-substring x 1) "%" (math-match-substring x 2)))
+    x))
+
 (defun math-tex-expr-is-flat (a)
   (or (Math-integerp a)
       (memq (car a) '(float var))