On Thu, 21 Jun 2007, 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.  :(

I'm trying to learn this kind of thing too.  So does it do what you want 
if you search for foo alone?  In other words, is this all about getting 
the OR to work correctly?  Is the grouping (parens) always needed?

Mike


> (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)))
>      )))
>
>
> Any clues?
>
> ~jh
>
> _______________________________________________
> TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
> tclug-list at mn-linux.org
> http://mailman.mn-linux.org/mailman/listinfo/tclug-list
>