changeset 108590:c84578d13e42

calc-aent.el (math-read-token, math-find-user-tokens): calc-lang.el (math-read-big-rec, math-lang-read-symbol) (math-compose-tex-func): calccomp.el (math-compose-expr): calc-ext.el (math-format-flat-expr-fancy): calc-store.el (calc-read-var-name): calc-units.el (calc-explain-units-rec): Allow Greek letters. calc.el (var-¦Ð, var-¦Õ, var-¦Ã): New variables. calc-aent.el (math-read-replacement-list): Add "micro" symbol. calc-units.el (math-unit-prefixes): Add mu for micro. (math-standard-units): Add units.
author Jay Belanger <jay.p.belanger@gmail.com>
date Fri, 14 May 2010 23:50:25 -0500
parents b818f9578731
children 7e6170a6733d
files lisp/ChangeLog lisp/calc/calc-aent.el lisp/calc/calc-ext.el lisp/calc/calc-lang.el lisp/calc/calc-store.el lisp/calc/calc-units.el lisp/calc/calc.el lisp/calc/calccomp.el
diffstat 8 files changed, 64 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sat May 15 00:10:22 2010 -0400
+++ b/lisp/ChangeLog	Fri May 14 23:50:25 2010 -0500
@@ -1,3 +1,18 @@
+2010-05-15  Jay Belanger  <jay.p.belanger@gmail.com>
+
+	* calc/calc-aent.el (math-read-token, math-find-user-tokens):
+	* calc/calc-lang.el (math-read-big-rec, math-lang-read-symbol):
+	(math-compose-tex-func):
+	* calc/calccomp.el (math-compose-expr):
+	* calc/calc-ext.el (math-format-flat-expr-fancy):
+	* calc/calc-store.el (calc-read-var-name):
+	* calc/calc-units.el (calc-explain-units-rec): Allow Greek letters.
+
+	* calc/calc.el (var-π, var-φ, var-γ): New variables.
+	* calc/calc-aent.el (math-read-replacement-list):  Add "micro" symbol.
+	* calc/calc-units.el (math-unit-prefixes): Add mu for micro.
+	(math-standard-units):  Add units.
+
 2010-05-15  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* progmodes/asm-mode.el (asm-mode):
@@ -14,7 +29,7 @@
 
 2010-05-14  Jay Belanger  <jay.p.belanger@gmail.com>
 
-	* calc-bin.el (math-format-twos-complement): Group digits when
+	* calc/calc-bin.el (math-format-twos-complement): Group digits when
 	appropriate.
 
 2010-05-14  Stefan Monnier  <monnier@iro.umontreal.ca>
--- a/lisp/calc/calc-aent.el	Sat May 15 00:10:22 2010 -0400
+++ b/lisp/calc/calc-aent.el	Fri May 14 23:50:25 2010 -0500
@@ -510,6 +510,7 @@
     ("≥" ">=")
     ("≦" "<=")
     ("≧" ">=")
+    ("µ" "μ")
     ;; fractions
     ("¼" "(1:4)") ; 1/4
     ("½" "(1:2)") ; 1/2
@@ -675,11 +676,11 @@
     (cond ((and (stringp (car p))
 		(or (> (length (car p)) 1) (equal (car p) "$")
 		    (equal (car p) "\""))
-		(string-match "[^a-zA-Z0-9]" (car p)))
+		(string-match "[^a-zA-Zα-ωΑ-Ω0-9]" (car p)))
 	   (let ((s (regexp-quote (car p))))
-	     (if (string-match "\\`[a-zA-Z0-9]" s)
+	     (if (string-match "\\`[a-zA-Zα-ωΑ-Ω0-9]" s)
 		 (setq s (concat "\\<" s)))
-	     (if (string-match "[a-zA-Z0-9]\\'" s)
+	     (if (string-match "[a-zA-Zα-ωΑ-Ω0-9]\\'" s)
 		 (setq s (concat s "\\>")))
 	     (or (assoc s math-toks)
 		 (progn
@@ -718,15 +719,17 @@
 		   math-expr-data (math-match-substring math-exp-str 0)
 		   math-exp-pos (match-end 0)))
 	    ((or (and (>= ch ?a) (<= ch ?z))
-		 (and (>= ch ?A) (<= ch ?Z)))
+		 (and (>= ch ?A) (<= ch ?Z))
+		 (and (>= ch ?α) (<= ch ?ω))
+		 (and (>= ch ?Α) (<= ch ?Ω)))
 	     (string-match 
               (cond
                ((and (memq calc-language calc-lang-allow-underscores)
                      (memq calc-language calc-lang-allow-percentsigns))
-                "[a-zA-Z0-9_'#]*")
+                "[a-zA-Zα-ωΑ-Ω0-9_'#]*")
                ((memq calc-language calc-lang-allow-underscores)
-			       "[a-zA-Z0-9_#]*")
-               (t "[a-zA-Z0-9'#]*"))
+			       "[a-zA-Zα-ωΑ-Ω0-9_#]*")
+               (t "[a-zA-Zα-ωΑ-Ω0-9'#]*"))
               math-exp-str math-exp-pos)
 	     (setq math-exp-token 'symbol
 		   math-exp-pos (match-end 0)
@@ -744,12 +747,12 @@
 		      (or (eq math-exp-pos 0)
 			  (and (not (memq calc-language 
                                           calc-lang-allow-underscores))
-			       (eq (string-match "[^])}\"a-zA-Z0-9'$]_"
+			       (eq (string-match "[^])}\"a-zA-Zα-ωΑ-Ω0-9'$]_"
 						 math-exp-str (1- math-exp-pos))
 				   (1- math-exp-pos))))))
 	     (or (and (memq calc-language calc-lang-c-type-hex)
 		      (string-match "0[xX][0-9a-fA-F]+" math-exp-str math-exp-pos))
-		 (string-match "_?\\([0-9]+.?0*@ *\\)?\\([0-9]+.?0*' *\\)?\\(0*\\([2-9]\\|1[0-4]\\)\\(#[#]?\\|\\^\\^\\)[0-9a-dA-D.]+[eE][-+_]?[0-9]+\\|0*\\([2-9]\\|[0-2][0-9]\\|3[0-6]\\)\\(#[#]?\\|\\^\\^\\)[0-9a-zA-Z:.]+\\|[0-9]+:[0-9:]+\\|[0-9.]+\\([eE][-+_]?[0-9]+\\)?\"?\\)?"
+		 (string-match "_?\\([0-9]+.?0*@ *\\)?\\([0-9]+.?0*' *\\)?\\(0*\\([2-9]\\|1[0-4]\\)\\(#[#]?\\|\\^\\^\\)[0-9a-dA-D.]+[eE][-+_]?[0-9]+\\|0*\\([2-9]\\|[0-2][0-9]\\|3[0-6]\\)\\(#[#]?\\|\\^\\^\\)[0-9a-zA-Zα-ωΑ-Ω:.]+\\|[0-9]+:[0-9:]+\\|[0-9.]+\\([eE][-+_]?[0-9]+\\)?\"?\\)?"
                                math-exp-str math-exp-pos))
 	     (setq math-exp-token 'number
 		   math-expr-data (math-match-substring math-exp-str 0)
--- a/lisp/calc/calc-ext.el	Sat May 15 00:10:22 2010 -0400
+++ b/lisp/calc/calc-ext.el	Fri May 14 23:50:25 2010 -0500
@@ -3283,7 +3283,7 @@
 	     (concat "-" (math-format-flat-expr (nth 1 a) 1000)))
 	    (t
 	     (concat (math-remove-dashes
-		      (if (string-match "\\`calcFunc-\\([a-zA-Z0-9']+\\)\\'"
+		      (if (string-match "\\`calcFunc-\\([a-zA-Zα-ωΑ-Ω0-9']+\\)\\'"
 					(symbol-name (car a)))
 			  (math-match-substring (symbol-name (car a)) 1)
 			(symbol-name (car a))))
--- a/lisp/calc/calc-lang.el	Sat May 15 00:10:22 2010 -0400
+++ b/lisp/calc/calc-lang.el	Fri May 14 23:50:25 2010 -0500
@@ -214,7 +214,7 @@
 (put 'pascal 'math-lang-read-symbol
      '((?\$
         (eq (string-match
-             "\\(\\$[0-9a-fA-F]+\\)\\($\\|[^0-9a-zA-Z]\\)"
+             "\\(\\$[0-9a-fA-F]+\\)\\($\\|[^0-9a-zA-Zα-ωΑ-Ω]\\)"
              math-exp-str math-exp-pos)
             math-exp-pos)
         (setq math-exp-token 'number
@@ -312,7 +312,7 @@
 
 (put 'fortran 'math-lang-read-symbol
      '((?\.
-        (eq (string-match "\\.[a-zA-Z][a-zA-Z][a-zA-Z]?\\."
+        (eq (string-match "\\.[a-zA-Zα-ωΑ-Ω][a-zA-Zα-ωΑ-Ω][a-zA-Zα-ωΑ-Ω]?\\."
                           math-exp-str math-exp-pos) math-exp-pos)
         (setq math-exp-token 'punc
               math-expr-data (upcase (math-match-substring math-exp-str 0))
@@ -603,9 +603,9 @@
      '((?\\
         (< math-exp-pos (1- (length math-exp-str)))
         (progn
-          (or (string-match "\\\\hbox *{\\([a-zA-Z0-9]+\\)}"
+          (or (string-match "\\\\hbox *{\\([a-zA-Zα-ωΑ-Ω0-9]+\\)}"
                             math-exp-str math-exp-pos)
-              (string-match "\\(\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\)"
+              (string-match "\\(\\\\\\([a-zA-Zα-ωΑ-Ω]+\\|[^a-zA-Zα-ωΑ-Ω]\\)\\)"
                             math-exp-str math-exp-pos))
           (setq math-exp-token 'symbol
                 math-exp-pos (match-end 0)
@@ -691,7 +691,7 @@
 (defun math-compose-tex-var (a prec)
   (if (and calc-language-option
            (not (= calc-language-option 0))
-           (string-match "\\`[a-zA-Z][a-zA-Z0-9]+\\'"
+           (string-match "\\`[a-zA-Zα-ωΑ-Ω][a-zA-Zα-ωΑ-Ω0-9]+\\'"
                          (symbol-name (nth 1 a))))
       (if (eq calc-language 'latex)
           (format "\\text{%s}" (symbol-name (nth 1 a)))
@@ -702,7 +702,7 @@
   (let (left right)
     (if (and calc-language-option
              (not (= calc-language-option 0))
-             (string-match "\\`[a-zA-Z][a-zA-Z0-9]+\\'" func))
+             (string-match "\\`[a-zA-Zα-ωΑ-Ω][a-zA-Zα-ωΑ-Ω0-9]+\\'" func))
         (if (< (prefix-numeric-value calc-language-option) 0)
             (setq func (format "\\%s" func))
           (setq func (if (eq calc-language 'latex)
@@ -824,11 +824,11 @@
      '((?\\
         (< math-exp-pos (1- (length math-exp-str)))
         (progn
-          (or (string-match "\\\\hbox *{\\([a-zA-Z0-9]+\\)}"
+          (or (string-match "\\\\hbox *{\\([a-zA-Zα-ωΑ-Ω0-9]+\\)}"
                             math-exp-str math-exp-pos)
-              (string-match "\\\\text *{\\([a-zA-Z0-9]+\\)}"
+              (string-match "\\\\text *{\\([a-zA-Zα-ωΑ-Ω0-9]+\\)}"
                             math-exp-str math-exp-pos)
-              (string-match "\\(\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\)"
+              (string-match "\\(\\\\\\([a-zA-Zα-ωΑ-Ω]+\\|[^a-zA-Zα-ωΑ-Ω]\\)\\)"
                             math-exp-str math-exp-pos))
           (setq math-exp-token 'symbol
                 math-exp-pos (match-end 0)
@@ -2301,9 +2301,11 @@
 
 	    ;; Variable name or function call.
 	    ((or (and (>= other-char ?a) (<= other-char ?z))
-		 (and (>= other-char ?A) (<= other-char ?Z)))
+		 (and (>= other-char ?A) (<= other-char ?Z))
+		 (and (>= other-char ?α) (<= other-char ?ω))
+		 (and (>= other-char ?Α) (<= other-char ?Ω)))
 	     (setq line (nth v math-read-big-lines))
-	     (string-match "\\([a-zA-Z'_]+\\) *" line math-rb-h1)
+	     (string-match "\\([a-zA-Zα-ωΑ-Ω'_]+\\) *" line math-rb-h1)
 	     (setq h (match-end 1)
 		   widest (match-end 0)
 		   p (math-match-substring line 1))
--- a/lisp/calc/calc-store.el	Sat May 15 00:10:22 2010 -0400
+++ b/lisp/calc/calc-store.el	Fri May 14 23:50:25 2010 -0500
@@ -202,7 +202,7 @@
                  'calc-read-var-name-history)))))
     (setq calc-aborted-prefix "")
     (and (not (equal var "var-"))
-	 (if (string-match "\\`\\([-a-zA-Z0-9]+\\) *:?=" var)
+	 (if (string-match "\\`\\([-a-zA-Zα-ωΑ-Ω0-9]+\\) *:?=" var)
 	     (if (null calc-given-value-flag)
 		 (error "Assignment is not allowed in this command")
 	       (let ((svar (intern (substring var 0 (match-end 1)))))
--- a/lisp/calc/calc-units.el	Sat May 15 00:10:22 2010 -0400
+++ b/lisp/calc/calc-units.el	Fri May 14 23:50:25 2010 -0500
@@ -36,13 +36,13 @@
 
 ;;; Units table last updated 9-Jan-91 by Ulrich Mueller (ulm@vsnhd1.cern.ch)
 ;;; with some additions by Przemek Klosowski (przemek@rrdstrad.nist.gov)
-;;; Updated April 2002 by Jochen Küpper
+;;; Updated April 2002 by Jochen Küpper
 
 ;;; Updated August 2007, using
 ;;;     CODATA (http://physics.nist.gov/cuu/Constants/index.html)
 ;;;     NIST   (http://physics.nist.gov/Pubs/SP811/appenB9.html)
 ;;;     ESUWM  (Encyclopaedia of Scientific Units, Weights and
-;;;             Measures, by François Cardarelli)
+;;;             Measures, by François Cardarelli)
 ;;; All conversions are exact unless otherwise noted.
 
 (defvar math-standard-units
@@ -210,6 +210,7 @@
               "1.602176487 10^-19 C (*)") ;;(approx) CODATA
     ( V       "W/A"                   "Volt" )
     ( ohm     "V/A"                   "Ohm" )
+    ( Ω       "ohm"                   "Ohm" )
     ( mho     "A/V"                   "Mho" )
     ( S       "A/V"                   "Siemens" )
     ( F       "C/V"                   "Farad" )
@@ -259,7 +260,9 @@
               "6.62606896 10^-34 J s (*)")
     ( hbar    "h / (2 pi)"                  "Planck's constant" ) ;; Exact
     ( mu0     "4 pi 10^(-7) H/m"            "Permeability of vacuum") ;; Exact
+    ( μ0      "mu0"                         "Permeability of vacuum") ;; Exact
     ( eps0    "1 / (mu0 c^2)"               "Permittivity of vacuum" )
+    ( ε0      "eps0"                        "Permittivity of vacuum" )
     ( G       "6.67428*10^(-11) m^3/(kg s^2)"    "Gravitational constant" nil
               "6.67428 10^-11 m^3/(kg s^2) (*)")
     ( Nav     "6.02214179*10^(23) / mol"    "Avogadro's constant" nil
@@ -272,12 +275,16 @@
               "1.674927211 10^-27 kg (*)")
     ( mmu     "1.88353130*10^(-28) kg"      "Muon rest mass" nil
               "1.88353130 10^-28 kg (*)")
+    ( mμ      "mmu"                         "Muon rest mass" nil
+              "1.88353130 10^-28 kg (*)")
     ( Ryd     "10973731.568527 /m"          "Rydberg's constant" nil
               "10973731.568527 /m (*)")
     ( k       "1.3806504*10^(-23) J/K"      "Boltzmann's constant" nil
               "1.3806504 10^-23 J/K (*)")
     ( alpha   "7.2973525376*10^(-3)"        "Fine structure constant" nil
               "7.2973525376 10^-3 (*)")
+    ( α       "alpha"                        "Fine structure constant" nil
+              "7.2973525376 10^-3 (*)")
     ( muB     "927.400915*10^(-26) J/T"     "Bohr magneton" nil
               "927.400915 10^-26 J/T (*)")
     ( muN     "5.05078324*10^(-27) J/T"     "Nuclear magneton" nil
@@ -316,6 +323,7 @@
      ( ?c  (^ 10 -2)  "Centi"  )
      ( ?m  (^ 10 -3)  "Milli"  )
      ( ?u  (^ 10 -6)  "Micro"  )
+     ( ?μ  (^ 10 -6)  "Micro"  )     
      ( ?n  (^ 10 -9)  "Nano"   )
      ( ?p  (^ 10 -12) "Pico"   )
      ( ?f  (^ 10 -15) "Femto"  )
@@ -581,8 +589,8 @@
 	(let ((name (or (nth 2 u) (symbol-name (car u)))))
 	  (if (eq (aref name 0) ?\*)
 	      (setq name (substring name 1)))
-	  (if (string-match "[^a-zA-Z0-9']" name)
-	      (if (string-match "^[a-zA-Z0-9' ()]*$" name)
+	  (if (string-match "[^a-zA-Zα-ωΑ-Ω0-9']" name)
+	      (if (string-match "^[a-zA-Zα-ωΑ-Ω0-9' ()]*$" name)
 		  (while (setq pos (string-match "[ ()]" name))
 		    (setq name (concat (substring name 0 pos)
 				       (if (eq (aref name pos) 32) "-" "")
@@ -592,7 +600,7 @@
 	      (setq name (concat (nth 2 (assq (aref (symbol-name
 						     (nth 1 expr)) 0)
 					      math-unit-prefixes))
-				 (if (and (string-match "[^a-zA-Z0-9']" name)
+				 (if (and (string-match "[^a-zA-Zα-ωΑ-Ω0-9']" name)
 					  (not (memq (car u) '(mHg gf))))
 				     (concat "-" name)
 				   (downcase name)))))
@@ -1540,9 +1548,5 @@
 
 (provide 'calc-units)
 
-;; Local Variables:
-;; coding: iso-latin-1
-;; End:
-
 ;; arch-tag: e993314f-3adc-4191-be61-4ef8874881c4
 ;;; calc-units.el ends here
--- a/lisp/calc/calc.el	Sat May 15 00:10:22 2010 -0400
+++ b/lisp/calc/calc.el	Fri May 14 23:50:25 2010 -0500
@@ -999,9 +999,12 @@
 (defvar math-working-step-2 nil)
 (defvar var-i '(special-const (math-imaginary 1)))
 (defvar var-pi '(special-const (math-pi)))
+(defvar var-Ï€ '(special-const (math-pi)))
 (defvar var-e '(special-const (math-e)))
 (defvar var-phi '(special-const (math-phi)))
+(defvar var-φ '(special-const (math-phi)))
 (defvar var-gamma '(special-const (math-gamma-const)))
+(defvar var-γ '(special-const (math-gamma-const)))
 (defvar var-Modes '(special-const (math-get-modes-vec)))
 
 (mapc (lambda (v) (or (boundp v) (set v nil)))
--- a/lisp/calc/calccomp.el	Sat May 15 00:10:22 2010 -0400
+++ b/lisp/calc/calccomp.el	Fri May 14 23:50:25 2010 -0500
@@ -663,6 +663,8 @@
 			      (and prevc nextc
 				   (or (and (>= nextc ?a) (<= nextc ?z))
 				       (and (>= nextc ?A) (<= nextc ?Z))
+				       (and (>= nextc ?α) (<= nextc ?ω))
+				       (and (>= nextc ?Α) (<= nextc ?Ω))
 				       (and (>= nextc ?0) (<= nextc ?9))
 				       (memq nextc '(?. ?_ ?#
 							?\( ?\[ ?\{))
@@ -732,7 +734,7 @@
 				(not (math-tex-expr-is-flat (nth 1 a))))))
 		   (list 'horiz
 			 (if lr "\\left" "")
-			 (if (string-match "\\`u\\([^a-zA-Z]\\)\\'" (car op))
+			 (if (string-match "\\`u\\([^a-zA-Zα-ωΑ-Ω]\\)\\'" (car op))
 			     (substring (car op) 1)
 			   (car op))
 			 (if (or lr (> (length (car op)) 2)) " " "")
@@ -758,7 +760,7 @@
 		(t
 		 (let ((rhs (math-compose-expr (nth 1 a) (nth 3 op))))
 		   (list 'horiz
-			 (let ((ops (if (string-match "\\`u\\([^a-zA-Z]\\)\\'"
+			 (let ((ops (if (string-match "\\`u\\([^a-zA-Zα-ωΑ-Ω]\\)\\'"
 						      (car op))
 					(substring (car op) 1)
 				      (car op))))
@@ -806,7 +808,7 @@
 		     (setq func (car func2)))
 		 (setq func (math-remove-dashes
 			     (if (string-match
-				  "\\`calcFunc-\\([a-zA-Z0-9']+\\)\\'"
+				  "\\`calcFunc-\\([a-zA-Zα-ωΑ-Ω0-9']+\\)\\'"
 				  (symbol-name func))
 				 (math-match-substring (symbol-name func) 1)
 			       (symbol-name func))))