all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Test for a list of words?
@ 2003-05-11 10:45 Svend Tollak Munkejord
  2003-05-11 14:12 ` Jesper Harder
  0 siblings, 1 reply; 3+ messages in thread
From: Svend Tollak Munkejord @ 2003-05-11 10:45 UTC (permalink / raw)


Hi,

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)

Thanks for any hint.
-- 
Svend Tollak Munkejord 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Test for a list of words?
  2003-05-11 10:45 Test for a list of words? Svend Tollak Munkejord
@ 2003-05-11 14:12 ` Jesper Harder
  2003-05-11 15:10   ` Svend Tollak Munkejord
  0 siblings, 1 reply; 3+ messages in thread
From: Jesper Harder @ 2003-05-11 14:12 UTC (permalink / raw)


Svend Tollak Munkejord <stm@bacchus.pvv.org> 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"))

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Test for a list of words?
  2003-05-11 14:12 ` Jesper Harder
@ 2003-05-11 15:10   ` Svend Tollak Munkejord
  0 siblings, 0 replies; 3+ messages in thread
From: Svend Tollak Munkejord @ 2003-05-11 15:10 UTC (permalink / raw)


Today, Jesper Harder <harder@myrealbox.com> wrote:

>Svend Tollak Munkejord <stm@bacchus.pvv.org> writes:
>
>>How can I test whether a buffer contains some words?
>
>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))

Great! Thanks!

-- 
Svend Tollak Munkejord 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-05-11 15:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-11 10:45 Test for a list of words? Svend Tollak Munkejord
2003-05-11 14:12 ` Jesper Harder
2003-05-11 15:10   ` Svend Tollak Munkejord

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.