unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* `compare-strings' style question
@ 2009-11-19 10:50 tomas
  2009-11-20  3:08 ` Kevin Rodgers
  0 siblings, 1 reply; 14+ messages in thread
From: tomas @ 2009-11-19 10:50 UTC (permalink / raw)
  To: help-gnu-emacs

-----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-----




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

end of thread, other threads:[~2009-11-24  9:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.11037.1258628274.2239.help-gnu-emacs@gnu.org>
2009-11-19 11:39 ` `compare-strings' style question David Kastrup
2009-11-19 15:27   ` tomas
2009-11-19 19:55     ` Andreas Politz
2009-11-20  6:47       ` tomas
     [not found]   ` <mailman.11057.1258644880.2239.help-gnu-emacs@gnu.org>
2009-11-19 16:17     ` David Kastrup
2009-11-19 20:54       ` Barry Margolin
2009-11-20  7:00         ` tomas
2009-11-20  8:13           ` Andreas Politz
2009-11-20  6:53       ` tomas
2009-11-19 10:50 tomas
2009-11-20  3:08 ` Kevin Rodgers
2009-11-20  7:03   ` tomas
2009-11-20 10:34     ` Kevin Rodgers
2009-11-24  9:32       ` tomas

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).