-(defun regexp-word(regexp)
- "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, so I stick
- ;; the no-hyphens-or-underscores class on each end of the
- ;; expressions.
-
- (concat "\\("
- (concat "\\(^\\<\\(" regexp "\\)\\>[^_-]\\)")
- "\\|"
- (concat "\\([^_-]\\<\\(" regexp "\\)\\>[^_-]\\)")
- "\\)")
- )
-
-