[Top][All Lists]

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

Re: `compare-strings' style question

From: Kevin Rodgers
Subject: Re: `compare-strings' style question
Date: Thu, 19 Nov 2009 20:08:59 -0700
User-agent: Thunderbird (Macintosh/20090812)

address@hidden wrote:
In Elisp, I'm trying to test whether a string is a prefix of another.
Poking around the documentation, I stumbled upon `compare-strings',
which seems to do the job fairly well. The interface is a bit weird
(at least as seen from Lisp) It feels more like C's strcmp.

It returns t on exact match, and some numbers on mismatch. I understand
that the result might be useful in some cases (it tells one by how many
chars we miss a match), but then I can't just do

  (when (compare-strings foo 0 5 bar 0 5)

but must do

  (when (eq (compare-strings foo 0 5 bar 0 5) t)

which looks rather funny. My question: are there better idioms? Am I
barking up the wrong function?

(when (string-match (concat "^" (regexp-quote foo)) bar)

Kevin Rodgers
Denver, Colorado, USA

reply via email to

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