From 36e47cd9620f76fe2b69b0e2604e5448353b0047 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 20 Aug 2010 17:23:44 -0400 Subject: [PATCH] Eliminate the last use of regexp-alt-raw and the function itself. --- nagios-mode.el | 67 ++++++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 41 deletions(-) diff --git a/nagios-mode.el b/nagios-mode.el index 5dd7274..e486edc 100644 --- a/nagios-mode.el +++ b/nagios-mode.el @@ -159,26 +159,6 @@ -;; 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]*" @@ -669,27 +649,32 @@ (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. + "\\({\\| \\)") ) ) -- 2.44.2