From eb979cc1755ca7cf5b42f0ec401777fd6a1c50ee Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 12 Feb 2009 22:42:38 -0500 Subject: [PATCH] Fixed regexp-word so that it treats newlines as word boundaries. --- nagios-mode.el | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) 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 "\\)\\>[^_-]\\)") + "\\)") ) -- 2.44.2