From 28d88201880a7c891eec1572f953e8bdc71860e7 Mon Sep 17 00:00:00 2001 From: Jay Belanger Date: Wed, 26 Dec 2007 17:38:24 +0000 Subject: [PATCH] (math-to-percentsigns): New function. (math-compose-var): Handle variables with percent signs. (math-compose-expr): Handle function names with percent signs. --- lisp/ChangeLog | 18 ++++++++++++++++++ lisp/calc/calccomp.el | 19 ++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e98c4bf2fce..392eaa6d609 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,21 @@ +2007-12-26 Jay Belanger + + * calc/calc.el (calc-lang-allow-percentsigns): New variable. + + * calc/calc-lang.el (calc-lang-allow-percentsigns): Declare as + a variable. + + * calc/calccomp.el (math-to-percentsigns): New function. + (math-compose-var): Handle variables with percent signs. + (math-compose-expr): Handle function names with percent signs. + + * calc/calc-aent.el (math-to-percentsigns): Declare as function. + (math-read-exprs): Handle percent signs in languages that + allow them. + (math-restore-underscores): Remove function. + (math-remove-percentsigns, math-restore-placeholders): + New functions. + 2007-12-26 Vinicius Jose Latorre * ps-print.el (ps-print-preprint-region): Use `region-active-p' instead diff --git a/lisp/calc/calccomp.el b/lisp/calc/calccomp.el index dd59b366881..0f913ea0cb4 100644 --- a/lisp/calc/calccomp.el +++ b/lisp/calc/calccomp.el @@ -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)) -- 2.39.2