From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Jesper Harder Newsgroups: gmane.emacs.help Subject: Re: Test for a list of words? Date: Sun, 11 May 2003 16:12:14 +0200 Organization: http://purl.org/harder/ Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1052664087 12275 80.91.224.249 (11 May 2003 14:41:27 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 11 May 2003 14:41:27 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Sun May 11 16:41:23 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19Es0x-0003Be-00 for ; Sun, 11 May 2003 16:41:23 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19Es0g-0003kk-04 for gnu-help-gnu-emacs@m.gmane.org; Sun, 11 May 2003 10:41:06 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!logbridge.uoregon.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!not-for-mail Original-Newsgroups: gnu.emacs.help X-Face: ^RrvqCr7c,P$zTR:QED"@h9+BTm-"fjZJJ-3=OU7.)i/K]<.J88}s>'Z_$r; List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:9563 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:9563 Svend Tollak Munkejord 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"))