From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.help Subject: Re: `compare-strings' style question Date: Thu, 19 Nov 2009 12:39:33 +0100 Organization: Organization?!? Message-ID: <878we2kakq.fsf@lola.goethe.zz> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1258631155 32114 80.91.229.12 (19 Nov 2009 11:45:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 19 Nov 2009 11:45:55 +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 12:45:48 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 1NB5S6-0002Dg-37 for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Nov 2009 12:45:30 +0100 Original-Received: from localhost ([127.0.0.1]:59374 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NB5S5-0008Sn-GE for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Nov 2009 06:45:29 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!goblin1!goblin2!goblin.stu.neva.ru!feeder.erje.net!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help X-Face: 2FEFf>]>q>2iw=B6, xrUubRI>pR&Ml9=ao@P@i)L:\urd*t9M~y1^:+Y]'C0~{mAl`oQuAl \!3KEIp?*w`|bL5qr,H)LFO6Q=qx~iH4DN; i"; /yuIsqbLLCh/!U#X[S~(5eZ41to5f%E@'ELIi$t^ Vc\LWP@J5p^rst0+('>Er0=^1{]M9!p?&:\z]|;&=NP3AhB!B_bi^]Pfkw User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) Cancel-Lock: sha1:KdHpTzUpuQlk+MdYtiPsAjKBYck= Original-Lines: 33 Original-NNTP-Posting-Date: 19 Nov 2009 12:39:33 CET Original-NNTP-Posting-Host: a2842173.newsspool2.arcor-online.net Original-X-Trace: DXC=WBd^W_iF=XLk:C4l9A; OcOA9EHlD; 3YcB4Fo<]lROoRA8kF5MOK` 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:69914 Archived-At: tomas@tuxteam.de writes: > 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? (unless (numberp ... or (if (symbolp ... -- David Kastrup