]> gitweb.michael.orlitzky.com - nagios-mode.git/commitdiff
Eliminate the last use of regexp-alt-raw and the function itself.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 20 Aug 2010 21:23:44 +0000 (17:23 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 20 Aug 2010 21:23:44 +0000 (17:23 -0400)
nagios-mode.el

index 5dd7274fe7343f91e2e9358af759d0247b0f736a..e486edc5b4f93e290a418926017b03976e2e3278 100644 (file)
   
 
 
-;; Regular Expression Transformations
-
-(defun regexp-alt-raw(element-list)
-  "Takes a list of elements, and returns the string '\\(element1\\|element2...\\)'"
-  
-  ;; This is necessary since regexp-opt does not accept regular
-  ;; expressions as arguments. We use regexp-opt when we can, of
-  ;; course.
-  
-  (let ((regexp "\\("))
-    (mapcar (lambda(elem)
-             (setq regexp (concat regexp "\\(" elem "\\)" "\\|")))
-           element-list)
-    (concat (substring regexp 0 -2) ; Cut the last "\\|"
-           "\\)")
-    )
-  )
-
-
-
 (defconst nagios-directives
   (eval-when-compile
     (concat "^[ \t\r\n]*"
 
     (concat "^[ \t\r\n]*"
 
-    (regexp-alt-raw
-     '("define command"
-       "define contact"
-       "define contactgroup"
-       "define host"
-       "define hostdependency"
-       "define hostescalation"
-       "define hostextinfo"
-       "define hostgroup"
-       "define hostgroupescalation"
-       "define null"
-       "define service"
-       "define servicedependency"
-       "define serviceescalation"
-       "define serviceextinfo"
-       "define servicegroup"
-       "define timeperiod"))
-
-    ;; These can be "terminated" by either an opening curly
-    ;; brace, or a space.
-    "\\({\\| \\)")
+           "\\(" ;; Stick parenthesis around whatever comes out
+                 ;; of regexp-opt. We use this to match a
+                 ;; subexpression during font-lock.
+           (regexp-opt
+            '("define command"
+              "define contact"
+              "define contactgroup"
+              "define host"
+              "define hostdependency"
+              "define hostescalation"
+              "define hostextinfo"
+              "define hostgroup"
+              "define hostgroupescalation"
+              "define null"
+              "define service"
+              "define servicedependency"
+              "define serviceescalation"
+              "define serviceextinfo"
+              "define servicegroup"
+              "define timeperiod"))
+                 ;; This closes the parentheses that we opened
+           "\\)" ;; before regexp-opt.
+
+           ;; These can be "terminated" by either an opening curly
+           ;; brace, or a space.
+           "\\({\\| \\)")
     )
   )