On Thu, Jun 21, 2007 at 09:55:51AM -0500, John Hawley wrote: > A bit off topic, but a question about getting an emacs macro to find alternative regexp's. Can't seem to get the right syntax. > Here's the macro. Should find and jump to either 'foo' or 'bar'. > > The macro displays a message about not finding '\(foo\|bar\)'. > I've tried myriad variations of the search string pattern with differing quoting and escaping. :( > > (defconst search_patterns "\\(foo\\|bar\\)") > (defun search-for-patterns () > "Search for alternative patterns." > (interactive) > (message "searching for %s" search_patterns) > (let ((cur (point))) > (search-forward search_patterns nil t) > (let ((pnt (point))) > (cond ((= cur pnt) > (message "no find %s" search_patterns)) > (t > (goto-char pnt) > (message "found %s at char %s" search_patterns pnt))) > ))) I don't know Lisp or Emacs, but I do know that (, ), and | shouldn't be escaped (at all) in your regular expression.. Dan