summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorJay Belanger <jay.p.belanger@gmail.com>2007-12-12 04:55:20 +0000
committerJay Belanger <jay.p.belanger@gmail.com>2007-12-12 04:55:20 +0000
commit57f8977d5cc4d63494061f2ec2e1ab225ab46519 (patch)
treeec5ff9b47a1c79bd0f5795a1d73f887de4628503 /lisp
parent2a29c40930f8585f3bf6b19e85eb6703dcc38ae5 (diff)
downloademacs-57f8977d5cc4d63494061f2ec2e1ab225ab46519.tar.gz
(math-restore-underscores, math-string-restore-underscores):
New functions. (math-read-factor): Properly check variable names with underscores for entries in `math-expr-variable-mapping'.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/calc/calc-aent.el18
2 files changed, 22 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 12cbb15eacc..59b0854751b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -4,6 +4,11 @@
2007-12-11 Jay Belanger <jay.p.belanger@gmail.com>
+ * calc/calc-aent.el (math-restore-underscores)
+ (math-string-restore-underscores): New functions.
+ (math-read-factor): Properly check variable names with underscores
+ for entries in `math-expr-variable-mapping'.
+
* calc/calc-lang.el (math-lang-name): New property name.
* calc/calc.el (calc-set-mode-line): Use `math-lang-name'
diff --git a/lisp/calc/calc-aent.el b/lisp/calc/calc-aent.el
index 697d510ac02..ee9c6e61e4c 100644
--- a/lisp/calc/calc-aent.el
+++ b/lisp/calc/calc-aent.el
@@ -1015,6 +1015,19 @@ in Calc algebraic input.")
(concat (math-match-substring x 1) "-" (math-match-substring x 2)))
x))
+(defun math-restore-underscores (x)
+ "Replace pound signs by underscores in the symbol x.
+If the current Calc language does not allow underscores, return nil."
+ (if (memq calc-language calc-lang-allow-underscores)
+ (intern-soft (math-string-restore-underscores (symbol-name x)))))
+
+(defun math-string-restore-underscores (x)
+ "Replace pound signs by underscores in the string x."
+ (if (string-match "\\`\\(.*\\)#\\(.*\\)\\'" x)
+ (math-string-restore-underscores
+ (concat (math-match-substring x 1) "_" (math-match-substring x 2)))
+ x))
+
(defun math-read-if (cond op)
(let ((then (math-read-expr-level 0)))
(or (equal math-expr-data ":")
@@ -1116,7 +1129,10 @@ in Calc algebraic input.")
sym
(intern (concat "var-"
(symbol-name sym)))))))
- (let ((v (assq (nth 1 val) math-expr-variable-mapping)))
+ (let ((v (or
+ (assq (nth 1 val) math-expr-variable-mapping)
+ (assq (math-restore-underscores (nth 1 val))
+ math-expr-variable-mapping))))
(and v (setq val (if (consp (cdr v))
(funcall (car (cdr v)) v val)
(list 'var