unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Kevin Rodgers <kevin.d.rodgers@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: What's the best way to do "string-memq"?
Date: Mon, 10 Nov 2008 21:05:32 -0700	[thread overview]
Message-ID: <gfb0ab$1ce$1@ger.gmane.org> (raw)
In-Reply-To: <20081110181422.GB1961@muc.de>

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





      parent reply	other threads:[~2008-11-11  4:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-10 18:14 What's the best way to do "string-memq"? Alan Mackenzie
2008-11-10 18:17 ` Drew Adams
2008-11-10 19:02   ` Alan Mackenzie
2008-11-10 19:00     ` Drew Adams
2008-11-11  4:05 ` Kevin Rodgers [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='gfb0ab$1ce$1@ger.gmane.org' \
    --to=kevin.d.rodgers@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).