help-gnu-emacs
[Top][All Lists]
Advanced

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

`compare-strings' style question


From: tomas
Subject: `compare-strings' style question
Date: Thu, 19 Nov 2009 11:50:24 +0100
User-agent: Mutt/1.5.15+20070412 (2007-04-11)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

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?

Thanks for any insight
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFLBSLwBcgs9XrR2kYRAn3iAJwOzo2LTQ+BErcPHhMcb44QDW34nACfcx86
5wH5HvOVPQ/i92mkZzvJWgc=
=XpNM
-----END PGP SIGNATURE-----




reply via email to

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