From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: tomas@tuxteam.de Newsgroups: gmane.emacs.help Subject: `compare-strings' style question Date: Thu, 19 Nov 2009 11:50:24 +0100 Message-ID: <20091119105024.GA6950@tomas> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; x-action=pgp-signed Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1258628310 23094 80.91.229.12 (19 Nov 2009 10:58:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 19 Nov 2009 10:58:30 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Nov 19 11:58:25 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NB4iW-0007pi-CP for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Nov 2009 11:58:24 +0100 Original-Received: from localhost ([127.0.0.1]:57355 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NB4iV-0001j6-Uo for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Nov 2009 05:58:24 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NB4i1-0001iz-7t for help-gnu-emacs@gnu.org; Thu, 19 Nov 2009 05:57:53 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NB4hu-0001iH-V9 for help-gnu-emacs@gnu.org; Thu, 19 Nov 2009 05:57:51 -0500 Original-Received: from [199.232.76.173] (port=34851 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NB4hu-0001iE-LY for help-gnu-emacs@gnu.org; Thu, 19 Nov 2009 05:57:46 -0500 Original-Received: from alextrapp1.equinoxe.de ([217.22.192.104]:35794 helo=www.elogos.de) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NB4hu-00036F-6D for help-gnu-emacs@gnu.org; Thu, 19 Nov 2009 05:57:46 -0500 Original-Received: by www.elogos.de (Postfix, from userid 1000) id 3CE6090048; Thu, 19 Nov 2009 11:50:24 +0100 (CET) Content-Disposition: inline User-Agent: Mutt/1.5.15+20070412 (2007-04-11) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:69910 Archived-At: -----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=C3=A1s -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFLBSLwBcgs9XrR2kYRAn3iAJwOzo2LTQ+BErcPHhMcb44QDW34nACfcx86 5wH5HvOVPQ/i92mkZzvJWgc=3D =3DXpNM -----END PGP SIGNATURE-----