Bladeren bron

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 12 jaren geleden
bovenliggende
commit
0ce406151f
2 gewijzigde bestanden met toevoegingen van 7 en 7 verwijderingen
  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)
 
 (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.
 If a table column contains mostly numbers, it will be aligned to the
 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]*\\)$")
 	  (const :tag "Exponential, Floating point, Integer"
 		 "^[-+]?[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:")))
 
 (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 |
 ")
   (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 |
-| ab         | ab          |  ab | ab   | ab   | ab  |
+|         ab |          ab |  ab |   ab |   ab |  ab |
 "))
 
 (ert-deftest test-org-table/org-table-convert-refs-to-an/1 ()