|
From: | Kevin Rodgers |
Subject: | Re: What's the best way to do "string-memq"? |
Date: | Mon, 10 Nov 2008 21:05:32 -0700 |
User-agent: | Thunderbird 2.0.0.17 (Macintosh/20080914) |
Alan Mackenzie wrote:
Hi, everybody, I need a predicate which I'd ideally like to write as (string-memq (char-after) skip-chars) , where skip-chars is a string like "^;{}?:", and the predicate should return t when (char-after) is one of (?^ ?\; ?\{ ?\} ?\? ?\:). I can't see a convenient way to code this (no, I haven't looked into CL, and don't want to). Isn't there some elisp function something like C's strchr? Or must I dissect the string into its component characters for a memq, or (almost as bad), regexp-quote the character from the buffer and do `string-match' with that?
How about: (looking-at (format "[%s]" skip-chars)) The only problem is that '^' is special within "[...]", as are ']' and '-' (see the Regexp Special node of the Emacs Lisp manual). Or perhaps: (save-excursion (> (skip-chars-forward skip-chars) 0)) In skip-chars-forward (and -backward) `^' is still special within "[...]", but it can be quoted with `\'. -- Kevin Rodgers Denver, Colorado, USA
[Prev in Thread] | Current Thread | [Next in Thread] |