help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Test for a list of words?


From: Jesper Harder
Subject: Re: Test for a list of words?
Date: Sun, 11 May 2003 16:12:14 +0200
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (gnu/linux)

Svend Tollak Munkejord <address@hidden> writes:

> How can I test whether a buffer contains some words? Here is an
> example:
>
> (re-search-forward "foo\\|bar\\|baz" nil t)
>
> tests if one or more of the words are present, but I would like to
> test for all of them. (This is inside a function)

You could make a small function, say, `all-words-present-p':

  (require 'cl)

  (defun all-words-present-p (words)
    (every (lambda (word) 
             (goto-char (point-min)) 
             (search-forward word nil t))
           words))

and then test like this:

  (all-words-present-p '("foo" "bar" "baz"))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]