]> gitweb.michael.orlitzky.com - nagios-mode.git/blobdiff - nagios-mode.el
Added the first_notification_delay directive.
[nagios-mode.git] / nagios-mode.el
index 0fb247af60532847b469ae3faeb36a4d512e2fcd..f94940ff6e07fcb4ee4f9e3883d3789d293ef86f 100644 (file)
 
 ;; Regular Expression Transformations
 
-(defun regexp-word(regexp)
-  "Takes a regular expression as an argument, and adds the word boundary condition to the beginning and end of it."
-
-  ;; I consider neither a hyphen nor an underscore to be a word
-  ;; boundary for the purpose of syntax highlighting.
-  (concat "[^_-]\\<\\(" regexp "\\)\\>[^_-]")
-  )
-
-
 (defun regexp-alt-raw(element-list)
   "Takes a list of elements, and returns the string '\\(element1\\|element2...\\)'"
   
 
 (defconst nagios-directives
   (eval-when-compile
+    (concat "^[ \t\r\n]*"
+
     (regexp-opt
      '("active_checks_enabled" "address" "alias" "check_command"
        "check_freshness" "check_interval" "check_period" "checks_enabled"
        "command_line" "command_name" "contact_groups" "contact_name"
-       "contactgroup_name" "dependent_host_name"
+       "contactgroup_name" "contacts" "dependent_host_name"
        "dependent_service_description" "email" "event_handler"
        "event_handler_enabled" "execution_failure_criteria"
        "failure_prediction_enabled" "first_notification"
-       "flap_detection_enabled" "freshness_threshold" "friday"
-       "high_flap_threshold" "host_name" "host_notification_commands"
+       "first_notification_delay" "flap_detection_enabled" "freshness_threshold"
+       "friday" "high_flap_threshold" "host_name" "host_notification_commands"
        "host_notification_options" "host_notification_period"
-       "hostgroup_name" "hostgroups" "is_volatile" "last_notification"
-       "low_flap_threshold" "max_check_attempts"
-       "members" "monday" "normal_check_interval"
-       "notification_failure_criteria"
+       "host_notifications_enabled" "hostgroup_name" "hostgroups"
+       "is_volatile" "last_notification" "low_flap_threshold"
+       "max_check_attempts" "members" "monday" "normal_check_interval"
+       "notes" "notification_failure_criteria"
        "notification_interval" "notification_options"
        "notification_period" "notifications_enabled"
        "obsess_over_service" "pager" "parallelize_check"
        "process_perf_data" "retain_nonstatus_information"
        "retain_status_information" "retry_check_interval"
        "retry_interval" "saturday" "service_description"
-       "service_notification_commands"
-       "service_notification_options"
-       "service_notification_period" "stalking_options"
-       "sunday" "thursday" "timeperiod_name" "tuesday" "wednesday") t))
+       "service_notification_commands" "service_notification_options"
+       "service_notification_period" "service_notifications_enabled"
+       "servicegroup_name" "stalking_options"
+       "sunday" "thursday" "timeperiod_name" "tuesday" "wednesday") t)
+
+    "[ \r\n\t]+")
+    )
   )
-    
+
 
 
 (defconst nagios-macros
 
 (defconst nagios-definitions
   (eval-when-compile
+
+    (concat "^[ \t\r\n]*"
+
     (regexp-alt-raw
      '("define +\\(host\\|service\\|timeperiod\\|contact\\|command\\)"
-       "define +\\(host\\|contact\\)group"
+       "define +\\(host\\|contact\\|service\\)group"
        "define +\\(service\\|host\\)dependency"
-       "define +\\(service\\|host\\|hostgroup\\)escalation")))
+       "define +\\(service\\|host\\|hostgroup\\)escalation"))
+
+    ;; These can be "terminated" by either an opening curly
+    ;; brace, or a space.
+    "\\({\\| \\)")
+    )
   )
 
 
 
 (defconst nagios-special
   (eval-when-compile
+    (concat "^[ \t\r\n]*"
+
     (regexp-opt
-     '("name" "register" "use") t))
+     '("name" "register" "use") t)
+
+    "[ \r\n\t]+"))
   )
 
 
 
+(defconst nagios-string
+  (eval-when-compile
+    "\\(\".*?\"\\)"))
+
+
 ;; The One True Font Locking Variable
 
 (defvar nagios-font-lock-keywords
   (list
 
-   ;; This first bit of ugliness allows us to override any
-   ;; other font-locking with the comment font.
-   (cons nagios-comments '(0 font-lock-comment-delimiter-face t))
+   ;; Font lock the comments first.
+   (cons nagios-comments font-lock-comment-delimiter-face)
+
+   ;; Strings have the highest priority. For now, this is broken,
+   ;; but I guess I would rather have strings miscolored within
+   ;; comments than the other way around.
+   (cons nagios-string '(0 font-lock-string-face t))
+
+   (cons nagios-special font-lock-keyword-face)
+   (cons nagios-directives font-lock-variable-name-face)
+   (cons nagios-macros font-lock-constant-face)
+   (cons nagios-definitions '(1 font-lock-function-name-face)))
 
-   ;; The rest just map regular expressions to font faces.
-   (cons (regexp-word nagios-directives) font-lock-variable-name-face)
-   (cons (regexp-word nagios-macros) font-lock-constant-face)
-   (cons (regexp-word nagios-definitions) font-lock-function-name-face)
-   (cons (regexp-word nagios-special) font-lock-keyword-face))
-  
   "Rules for highlighting Nagios configuration files."
   )
 
   ;; Configure font locking. Set the defaults to something
   ;; sensible, defined earlier.
   (make-local-variable 'font-lock-defaults)
-  (setq font-lock-defaults '(nagios-font-lock-keywords nil t))
+  (setq font-lock-defaults '(nagios-font-lock-keywords t t))
 
   ;; Keyboard Mapping
   (use-local-map nagios-mode-map)