-;; 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.
+ "\\({\\| \\)")
)
)