(Emacs Lisp): Use `...?' rather than `\(...\|\)' in regular expressions.
[profile] / el / dot-emacs.el
index d477859..8ca49a5 100644 (file)
@@ -100,11 +100,11 @@ This may be at the expense of cool features.")
                     (replace-match with t))))
            (with-temp-buffer
              (insert-file-contents "~/.mdw.conf")
-             (replace  "^[ \t]*\\(#.*\\|\\)\n" "")
+             (replace  "^[ \t]*\\(#.*\\)?\n" "")
              (replace (concat "^[ \t]*"
                               "\\([-a-zA-Z0-9_.]*\\)"
                               "[ \t]*=[ \t]*"
-                              "\\(.*[^ \t\n]\\|\\)"
+                              "\\(.*[^ \t\n]\\)?"
                               "[ \t]**\\(\n\\|$\\)")
                       "(\\1 . \"\\2\")\n")
              (car (read-from-string
@@ -2225,7 +2225,7 @@ name, as a symbol."
           ;; Fontify include files as strings.
           (list (concat "^[ \t]*\\#[ \t]*"
                         "\\(include\\|import\\)"
-                        "[ \t]*\\(<[^>]+\\(>\\|\\)\\)")
+                        "[ \t]*\\(<[^>]+>?\\)")
                 '(2 font-lock-string-face))
 
           ;; Preprocessor directives are `references'?.
@@ -2381,8 +2381,8 @@ name, as a symbol."
           ;; The following isn't quite right, but it's close enough.
           (list (concat "\\<\\("
                         "0\\([xX][0-9a-fA-F]+\\|[0-7]+\\)\\|"
-                        "[0-9]+\\(\\.[0-9]*\\|\\)"
-                        "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)\\)"
+                        "[0-9]+\\(\\.[0-9]*\\)?"
+                        "\\([eE][-+]?[0-9]+\\)?\\)"
                         "[lLfFdD]?")
                 '(0 mdw-number-face))
 
@@ -2440,8 +2440,8 @@ name, as a symbol."
           ;; The following isn't quite right, but it's close enough.
           (list (concat "\\_<\\("
                         "0\\([xX][0-9a-fA-F]+\\|[0-7]+\\)\\|"
-                        "[0-9]+\\(\\.[0-9]*\\|\\)"
-                        "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)\\)"
+                        "[0-9]+\\(\\.[0-9]*\\)?"
+                        "\\([eE][-+]?[0-9]+\\)?\\)"
                         "[lLfFdD]?")
                 '(0 mdw-number-face))
 
@@ -2498,8 +2498,8 @@ name, as a symbol."
           ;; As usual, not quite right.
           (list (concat "\\_<\\("
                         "0\\([xX][0-9a-fA-F]+\\|[0-7]+\\)\\|"
-                        "[0-9]+\\(\\.[0-9]*\\|\\)"
-                        "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)\\)"
+                        "[0-9]+\\(\\.[0-9]*\\)?"
+                        "\\([eE][-+]?[0-9]+\\)?\\)"
                         "[lLfFdD]?")
                 '(0 mdw-number-face))
 
@@ -2585,8 +2585,8 @@ name, as a symbol."
           ;; The following isn't quite right, but it's close enough.
           (list (concat "\\<\\("
                         "0\\([xX][0-9a-fA-F]+\\|[0-7]+\\)\\|"
-                        "[0-9]+\\(\\.[0-9]*\\|\\)"
-                        "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)\\)"
+                        "[0-9]+\\(\\.[0-9]*\\)?"
+                        "\\([eE][-+]?[0-9]+\\)?\\)"
                         "[lLfFdD]?")
                 '(0 mdw-number-face))
 
@@ -2777,8 +2777,8 @@ name, as a symbol."
           ;; The following isn't quite right, but it's close enough.
           (list (concat "\\<\\("
                         "0\\([xX][0-9a-fA-F]+\\|[0-7]+\\)\\|"
-                        "[0-9]+\\(\\.[0-9]*\\|\\)"
-                        "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)\\)")
+                        "[0-9]+\\(\\.[0-9]*\\)?"
+                        "\\([eE][-+]?[0-9]+\\)?\\)")
                 '(0 mdw-number-face))
 
           ;; And anything else is punctuation.
@@ -2918,8 +2918,8 @@ name, as a symbol."
           ;; The following isn't quite right, but it's close enough.
           (list (concat "\\<\\("
                         "0\\([xX][0-9a-fA-F]+\\|[0-7]+\\)\\|"
-                        "[0-9]+\\(\\.[0-9]*\\|\\)"
-                        "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)\\)"
+                        "[0-9]+\\(\\.[0-9]*\\)?"
+                        "\\([eE][-+]?[0-9]+\\)?\\)"
                         "[uUlL]*")
                 '(0 mdw-number-face))
 
@@ -2985,8 +2985,8 @@ name, as a symbol."
 
           ;; At least numbers are simpler than C.
           (list (concat "\\<0\\([xX][0-9a-fA-F_]+\\|[0-7_]+\\)\\|"
-                        "\\<[0-9][0-9_]*\\(\\.[0-9_]*\\|\\)"
-                        "\\([eE]\\([-+]\\|\\)[0-9_]+\\|\\)")
+                        "\\<[0-9][0-9_]*\\(\\.[0-9_]*\\)?"
+                        "\\([eE][-+]?[0-9_]+\\)?")
                 '(0 mdw-number-face))
 
           ;; And anything else is punctuation.
@@ -3037,8 +3037,8 @@ strip numbers instead."
 
         ;; At least numbers are simpler than C.
         (list (concat "\\_<0\\([xX][0-9a-fA-F]+\\|[oO]?[0-7]+\\|[bB][01]+\\)\\|"
-                      "\\_<[0-9][0-9]*\\(\\.[0-9]*\\|\\)"
-                      "\\([eE]\\([-+]\\|\\)[0-9]+\\|[lL]\\|\\)")
+                      "\\_<[0-9][0-9]*\\(\\.[0-9]*\\)?"
+                      "\\([eE][-+]?[0-9]+\\|[lL]\\)?")
               '(0 mdw-number-face))
 
         ;; And anything else is punctuation.
@@ -3223,8 +3223,8 @@ strip numbers instead."
   (setq font-lock-keywords
        (list
         (list (concat "\\<0\\([xX][0-9a-fA-F_]+\\|[0-7_]+\\)\\|"
-                      "\\<[0-9][0-9_]*\\(\\.[0-9_]*\\|\\)"
-                      "\\([eE]\\([-+]\\|\\)[0-9_]+\\|\\)")
+                      "\\<[0-9][0-9_]*\\(\\.[0-9_]*\\)?"
+                      "\\([eE][-+]?[0-9_]+\\)?")
               '(0 mdw-number-face))
         (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
               '(0 mdw-punct-face)))))
@@ -3469,12 +3469,12 @@ strip numbers instead."
                 '(0 font-lock-keyword-face))
 
           ;; At least numbers are simpler than C.
-          (list (concat "\\<\\(\\~\\|\\)"
-                           "\\(0\\(\\([wW]\\|\\)[xX][0-9a-fA-F]+\\|"
+          (list (concat "\\<\\~?"
+                           "\\(0\\([wW]?[xX][0-9a-fA-F]+\\|"
                                   "[wW][0-9]+\\)\\|"
-                               "\\([0-9]+\\(\\.[0-9]+\\|\\)"
-                                        "\\([eE]\\(\\~\\|\\)"
-                                               "[0-9]+\\|\\)\\)\\)")
+                               "\\([0-9]+\\(\\.[0-9]+\\)?"
+                                        "\\([eE]\\~?"
+                                               "[0-9]+\\)?\\)\\)")
                 '(0 mdw-number-face))
 
           ;; And anything else is punctuation.
@@ -3559,8 +3559,8 @@ strip numbers instead."
           (list "\\_<[A-Z]\\(\\sw+\\|\\s_+\\)*\\_>"
                 '(0 font-lock-variable-name-face))
           (list (concat "\\_<0\\([xX][0-9a-fA-F]+\\|[oO][0-7]+\\)\\|"
-                        "\\_<[0-9]+\\(\\.[0-9]*\\|\\)"
-                        "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)")
+                        "\\_<[0-9]+\\(\\.[0-9]*\\)?"
+                        "\\([eE][-+]?[0-9]+\\)?")
                 '(0 mdw-number-face))
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
                 '(0 mdw-punct-face))))))
@@ -3597,7 +3597,7 @@ strip numbers instead."
                 '(0 font-lock-keyword-face))
           (list (concat "^-\\sw+\\>")
                 '(0 font-lock-keyword-face))
-          (list "\\<[0-9]+\\(\\|#[0-9a-zA-Z]+\\|[eE][+-]?[0-9]+\\)\\>"
+          (list "\\<[0-9]+\\(#[0-9a-zA-Z]+\\|[eE][+-]?[0-9]+\\)?\\>"
                 '(0 mdw-number-face))
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
                 '(0 mdw-punct-face))))))
@@ -3629,7 +3629,7 @@ strip numbers instead."
               '(2 font-lock-variable-name-face))
 
         ;; Make sure we get comments properly.
-        (list "@c\\(\\|omment\\)\\( .*\\)?$"
+        (list "@c\\(omment\\)?\\( .*\\)?$"
               '(0 font-lock-comment-face))
 
         ;; Command names are keywords.
@@ -4067,7 +4067,7 @@ that character only to be normal punctuation.")
     (setq messages-mode-keywords
          (append (list (list (concat "^[ \t]*\\#[ \t]*"
                                      "\\(include\\|import\\)"
-                                     "[ \t]*\\(<[^>]+\\(>\\|\\)\\)")
+                                     "[ \t]*\\(<[^>]+\\(>\\)?\\)")
                              '(2 font-lock-string-face))
                        (list (concat "^\\([ \t]*#[ \t]*\\(\\("
                                      preprocessor-keywords
@@ -4113,7 +4113,7 @@ that character only to be normal punctuation.")
          (list
           (list (concat "^%\\s *\\(}\\|\\(" keywords "\\)\\>\\).*$")
                 '(0 font-lock-keyword-face))
-          (list "^%\\s *\\(#.*\\|\\)$"
+          (list "^%\\s *\\(#.*\\)?$"
                 '(0 font-lock-comment-face))
           (list "^%"
                 '(0 font-lock-keyword-face))
@@ -4297,8 +4297,8 @@ that character only to be normal punctuation.")
         (list "\\<[A-Z][a-zA-Z0-9]*\\>"
               '(0 font-lock-keyword-face))
         (list (concat "\\<0\\([xX][0-9a-fA-F_]+\\|[0-7_]+\\)\\|"
-                      "[0-9][0-9_]*\\(\\.[0-9_]*\\|\\)"
-                      "\\([eE]\\([-+]\\|\\)[0-9_]+\\|\\)")
+                      "[0-9][0-9_]*\\(\\.[0-9_]*\\)?"
+                      "\\([eE][-+]?[0-9_]+\\)?")
               '(0 mdw-number-face))
         (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
               '(0 mdw-punct-face)))))