diff options
| author | Jay Belanger | 2007-12-26 17:32:13 +0000 |
|---|---|---|
| committer | Jay Belanger | 2007-12-26 17:32:13 +0000 |
| commit | d039d4d8ff0a77afa2685ed6d9b8d1186e1d4b28 (patch) | |
| tree | 7db04da7128088c4f7ca0ff20d86bdca491a43dc | |
| parent | 53a124003ed4fba04eb9bbee897e0548747b0c31 (diff) | |
| download | emacs-d039d4d8ff0a77afa2685ed6d9b8d1186e1d4b28.tar.gz emacs-d039d4d8ff0a77afa2685ed6d9b8d1186e1d4b28.zip | |
(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.
| -rw-r--r-- | lisp/calc/calc-aent.el | 54 |
1 files changed, 40 insertions, 14 deletions
diff --git a/lisp/calc/calc-aent.el b/lisp/calc/calc-aent.el index ee9c6e61e4c..712acfa6867 100644 --- a/lisp/calc/calc-aent.el +++ b/lisp/calc/calc-aent.el | |||
| @@ -49,7 +49,7 @@ | |||
| 49 | (declare-function math-read-string "calc-ext" ()) | 49 | (declare-function math-read-string "calc-ext" ()) |
| 50 | (declare-function math-read-brackets "calc-vec" (space-sep math-rb-close)) | 50 | (declare-function math-read-brackets "calc-vec" (space-sep math-rb-close)) |
| 51 | (declare-function math-read-angle-brackets "calc-forms" ()) | 51 | (declare-function math-read-angle-brackets "calc-forms" ()) |
| 52 | 52 | (declare-function math-to-percentsigns "calccomp" (x)) | |
| 53 | 53 | ||
| 54 | (defvar calc-quick-calc-history nil | 54 | (defvar calc-quick-calc-history nil |
| 55 | "The history list for quick-calc.") | 55 | "The history list for quick-calc.") |
| @@ -595,10 +595,14 @@ in Calc algebraic input.") | |||
| 595 | (math-exp-keep-spaces nil) | 595 | (math-exp-keep-spaces nil) |
| 596 | math-exp-token math-expr-data) | 596 | math-exp-token math-expr-data) |
| 597 | (setq math-exp-str (math-read-preprocess-string math-exp-str)) | 597 | (setq math-exp-str (math-read-preprocess-string math-exp-str)) |
| 598 | (if (memq calc-language calc-lang-allow-percentsigns) | ||
| 599 | (setq math-exp-str (math-remove-percentsigns math-exp-str))) | ||
| 598 | (if calc-language-input-filter | 600 | (if calc-language-input-filter |
| 599 | (setq math-exp-str (funcall calc-language-input-filter math-exp-str))) | 601 | (setq math-exp-str (funcall calc-language-input-filter math-exp-str))) |
| 600 | (while (setq math-exp-token (string-match "\\.\\.\\([^.]\\|.[^.]\\)" math-exp-str)) | 602 | (while (setq math-exp-token |
| 601 | (setq math-exp-str (concat (substring math-exp-str 0 math-exp-token) "\\dots" | 603 | (string-match "\\.\\.\\([^.]\\|.[^.]\\)" math-exp-str)) |
| 604 | (setq math-exp-str | ||
| 605 | (concat (substring math-exp-str 0 math-exp-token) "\\dots" | ||
| 602 | (substring math-exp-str (+ math-exp-token 2))))) | 606 | (substring math-exp-str (+ math-exp-token 2))))) |
| 603 | (math-build-parse-table) | 607 | (math-build-parse-table) |
| 604 | (math-read-token) | 608 | (math-read-token) |
| @@ -694,17 +698,23 @@ in Calc algebraic input.") | |||
| 694 | (math-read-token))) | 698 | (math-read-token))) |
| 695 | ((and (memq ch calc-user-token-chars) | 699 | ((and (memq ch calc-user-token-chars) |
| 696 | (let ((case-fold-search nil)) | 700 | (let ((case-fold-search nil)) |
| 697 | (eq (string-match calc-user-tokens math-exp-str math-exp-pos) | 701 | (eq (string-match |
| 702 | calc-user-tokens math-exp-str math-exp-pos) | ||
| 698 | math-exp-pos))) | 703 | math-exp-pos))) |
| 699 | (setq math-exp-token 'punc | 704 | (setq math-exp-token 'punc |
| 700 | math-expr-data (math-match-substring math-exp-str 0) | 705 | math-expr-data (math-match-substring math-exp-str 0) |
| 701 | math-exp-pos (match-end 0))) | 706 | math-exp-pos (match-end 0))) |
| 702 | ((or (and (>= ch ?a) (<= ch ?z)) | 707 | ((or (and (>= ch ?a) (<= ch ?z)) |
| 703 | (and (>= ch ?A) (<= ch ?Z))) | 708 | (and (>= ch ?A) (<= ch ?Z))) |
| 704 | (string-match (if (memq calc-language calc-lang-allow-underscores) | 709 | (string-match |
| 705 | "[a-zA-Z0-9_#]*" | 710 | (cond |
| 706 | "[a-zA-Z0-9'#]*") | 711 | ((and (memq calc-language calc-lang-allow-underscores) |
| 707 | math-exp-str math-exp-pos) | 712 | (memq calc-language calc-lang-allow-percentsigns)) |
| 713 | "[a-zA-Z0-9_'#]*") | ||
| 714 | ((memq calc-language calc-lang-allow-underscores) | ||
| 715 | "[a-zA-Z0-9_#]*") | ||
| 716 | (t "[a-zA-Z0-9'#]*")) | ||
| 717 | math-exp-str math-exp-pos) | ||
| 708 | (setq math-exp-token 'symbol | 718 | (setq math-exp-token 'symbol |
| 709 | math-exp-pos (match-end 0) | 719 | math-exp-pos (match-end 0) |
| 710 | math-expr-data (math-restore-dashes | 720 | math-expr-data (math-restore-dashes |
| @@ -1009,17 +1019,33 @@ in Calc algebraic input.") | |||
| 1009 | (concat (math-match-substring x 1) "#" (math-match-substring x 2))) | 1019 | (concat (math-match-substring x 1) "#" (math-match-substring x 2))) |
| 1010 | x)) | 1020 | x)) |
| 1011 | 1021 | ||
| 1022 | (defun math-remove-percentsigns (x) | ||
| 1023 | (if (string-match "^%" x) | ||
| 1024 | (setq x (concat "I#'" (substring x 1)))) | ||
| 1025 | (if (string-match "\\`\\(.*\\)%\\(.*\\)\\'" x) | ||
| 1026 | (math-remove-percentsigns | ||
| 1027 | (concat (math-match-substring x 1) "'" (math-match-substring x 2))) | ||
| 1028 | x)) | ||
| 1029 | |||
| 1012 | (defun math-restore-dashes (x) | 1030 | (defun math-restore-dashes (x) |
| 1013 | (if (string-match "\\`\\(.*\\)[#_]\\(.*\\)\\'" x) | 1031 | (if (string-match "\\`\\(.*\\)[#_]\\(.*\\)\\'" x) |
| 1014 | (math-restore-dashes | 1032 | (math-restore-dashes |
| 1015 | (concat (math-match-substring x 1) "-" (math-match-substring x 2))) | 1033 | (concat (math-match-substring x 1) "-" (math-match-substring x 2))) |
| 1016 | x)) | 1034 | x)) |
| 1017 | 1035 | ||
| 1018 | (defun math-restore-underscores (x) | 1036 | (defun math-restore-placeholders (x) |
| 1019 | "Replace pound signs by underscores in the symbol x. | 1037 | "Replace placeholders by the proper characters in the symbol x. |
| 1020 | If the current Calc language does not allow underscores, return nil." | 1038 | This includes `#' for `_' and `'' for `%'. |
| 1021 | (if (memq calc-language calc-lang-allow-underscores) | 1039 | If the current Calc language does not use placeholders, return nil." |
| 1022 | (intern-soft (math-string-restore-underscores (symbol-name x))))) | 1040 | (if (or (memq calc-language calc-lang-allow-underscores) |
| 1041 | (memq calc-language calc-lang-allow-percentsigns)) | ||
| 1042 | (let ((sx (symbol-name x))) | ||
| 1043 | (when (memq calc-language calc-lang-allow-percentsigns) | ||
| 1044 | (require 'calccomp) | ||
| 1045 | (setq sx (math-to-percentsigns sx))) | ||
| 1046 | (if (memq calc-language calc-lang-allow-underscores) | ||
| 1047 | (setq sx (math-string-restore-underscores sx))) | ||
| 1048 | (intern-soft sx)))) | ||
| 1023 | 1049 | ||
| 1024 | (defun math-string-restore-underscores (x) | 1050 | (defun math-string-restore-underscores (x) |
| 1025 | "Replace pound signs by underscores in the string x." | 1051 | "Replace pound signs by underscores in the string x." |
| @@ -1131,7 +1157,7 @@ If the current Calc language does not allow underscores, return nil." | |||
| 1131 | (symbol-name sym))))))) | 1157 | (symbol-name sym))))))) |
| 1132 | (let ((v (or | 1158 | (let ((v (or |
| 1133 | (assq (nth 1 val) math-expr-variable-mapping) | 1159 | (assq (nth 1 val) math-expr-variable-mapping) |
| 1134 | (assq (math-restore-underscores (nth 1 val)) | 1160 | (assq (math-restore-placeholders (nth 1 val)) |
| 1135 | math-expr-variable-mapping)))) | 1161 | math-expr-variable-mapping)))) |
| 1136 | (and v (setq val (if (consp (cdr v)) | 1162 | (and v (setq val (if (consp (cdr v)) |
| 1137 | (funcall (car (cdr v)) v val) | 1163 | (funcall (car (cdr v)) v val) |