Explorar el Código

Extend org-table-number-regexp

* lisp/org-table.el (org-table-number-regexp): Extend 0x hex to
fixed-point number, add <radix>#<number>, add Calc infinite numbers
uinf, -inf and inf.
* testing/lisp/test-org-table.el (test-org-table/align): Adapt
alignment.
Michael Brand hace 13 años
padre
commit
0ce406151f
Se han modificado 2 ficheros con 7 adiciones y 7 borrados
  1. 5 5
      lisp/org-table.el
  2. 2 2
      testing/lisp/test-org-table.el

+ 5 - 5
lisp/org-table.el

@@ -112,7 +112,7 @@ table, obtained by prompting the user."
   :type 'string)
   :type 'string)
 
 
 (defcustom org-table-number-regexp
 (defcustom org-table-number-regexp
-  "^\\([<>]?[-+^.0-9]*[0-9][-+^.0-9eEdDx()%:]*\\|\\(0[xX]\\)[0-9a-fA-F]+\\|nan\\)$"
+  "^\\([<>]?[-+^.0-9]*[0-9][-+^.0-9eEdDx()%:]*\\|[<>]?[-+]?0[xX][0-9a-fA-F.]+\\|[<>]?[-+]?[0-9]+#[0-9a-zA-Z.]+\\|nan\\|[-+u]?inf\\)$"
   "Regular expression for recognizing numbers in table columns.
   "Regular expression for recognizing numbers in table columns.
 If a table column contains mostly numbers, it will be aligned to the
 If a table column contains mostly numbers, it will be aligned to the
 right.  If not, it will be aligned to the left.
 right.  If not, it will be aligned to the left.
@@ -136,10 +136,10 @@ Other options offered by the customize interface are more restrictive."
 		 "^[-+]?\\([0-9]*\\.[0-9]+\\|[0-9]+\\.?[0-9]*\\)$")
 		 "^[-+]?\\([0-9]*\\.[0-9]+\\|[0-9]+\\.?[0-9]*\\)$")
 	  (const :tag "Exponential, Floating point, Integer"
 	  (const :tag "Exponential, Floating point, Integer"
 		 "^[-+]?[0-9.]+\\([eEdD][-+0-9]+\\)?$")
 		 "^[-+]?[0-9.]+\\([eEdD][-+0-9]+\\)?$")
-	  (const :tag "Very General Number-Like, including hex"
-		 "^\\([<>]?[-+^.0-9]*[0-9][-+^.0-9eEdDx()%]*\\|\\(0[xX]\\)[0-9a-fA-F]+\\|nan\\)$")
-	  (const :tag "Very General Number-Like, including hex, allows comma as decimal mark"
-		 "^\\([<>]?[-+^.,0-9]*[0-9][-+^.0-9eEdDx()%]*\\|\\(0[xX]\\)[0-9a-fA-F]+\\|nan\\)$")
+	  (const :tag "Very General Number-Like, including hex and Calc radix"
+		 "^\\([<>]?[-+^.0-9]*[0-9][-+^.0-9eEdDx()%]*\\|[<>]?[-+]?0[xX][0-9a-fA-F.]+\\|[<>]?[-+]?[0-9]+#[0-9a-zA-Z.]+\\|nan\\|[-+u]?inf\\)$")
+	  (const :tag "Very General Number-Like, including hex and Calc radix, allows comma as decimal mark"
+		 "^\\([<>]?[-+^.,0-9]*[0-9][-+^.0-9eEdDx()%]*\\|[<>]?[-+]?0[xX][0-9a-fA-F.]+\\|[<>]?[-+]?[0-9]+#[0-9a-zA-Z.]+\\|nan\\|[-+u]?inf\\)$")
 	  (string :tag "Regexp:")))
 	  (string :tag "Regexp:")))
 
 
 (defcustom org-table-number-fraction 0.5
 (defcustom org-table-number-fraction 0.5

+ 2 - 2
testing/lisp/test-org-table.el

@@ -32,9 +32,9 @@
 | ab | ab |   ab |      ab |      ab |          ab |      ab |   ab |
 | ab | ab |   ab |      ab |      ab |          ab |      ab |   ab |
 ")
 ")
   (org-test-table-target-expect "
   (org-test-table-target-expect "
-| 0          | 0           |   0 | 0    | 0    | 0   |
+|          0 |           0 |   0 |    0 |    0 |   0 |
 | <-0x0ab.cf | >-36#0vw.yz | nan | uinf | -inf | inf |
 | <-0x0ab.cf | >-36#0vw.yz | nan | uinf | -inf | inf |
-| ab         | ab          |  ab | ab   | ab   | ab  |
+|         ab |          ab |  ab |   ab |   ab |  ab |
 "))
 "))
 
 
 (ert-deftest test-org-table/org-table-convert-refs-to-an/1 ()
 (ert-deftest test-org-table/org-table-convert-refs-to-an/1 ()