From: Michael Orlitzky Date: Fri, 13 Feb 2009 03:42:38 +0000 (-0500) Subject: Fixed regexp-word so that it treats newlines as word boundaries. X-Git-Tag: v0.1~20 X-Git-Url: http://gitweb.michael.orlitzky.com/?p=nagios-mode.git;a=commitdiff_plain;h=eb979cc1755ca7cf5b42f0ec401777fd6a1c50ee Fixed regexp-word so that it treats newlines as word boundaries. --- diff --git a/nagios-mode.el b/nagios-mode.el index 9863688..e157334 100644 --- a/nagios-mode.el +++ b/nagios-mode.el @@ -156,11 +156,23 @@ ;; 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." + "Takes a regular expression as an argument, and adds the word boundary condition to the beginning and end of it. Newlines are treated as word boundaries." + ;; This basically joins two expressions in an alternation. + ;; The first allows for a newline followed by our regexp (on + ;; a word boundary), and the second checks for any-non-word + ;; character followed by our regexp. + ;; ;; I consider neither a hyphen nor an underscore to be a word - ;; boundary for the purpose of syntax highlighting. - (concat "[^_-]\\<\\(" regexp "\\)\\>[^_-]") + ;; boundary for the purpose of syntax highlighting, so I stick + ;; the no-hyphens-or-underscores class on each end of the + ;; expressions. + + (concat "\\(" + (concat "\\(^\\<\\(" regexp "\\)\\>[^_-]\\)") + "\\|" + (concat "\\([^_-]\\<\\(" regexp "\\)\\>[^_-]\\)") + "\\)") )