[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: `compare-strings' style question
From: |
Andreas Politz |
Subject: |
Re: `compare-strings' style question |
Date: |
Thu, 19 Nov 2009 20:55:27 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
tomas@tuxteam.de writes:
> On Thu, Nov 19, 2009 at 12:39:33PM +0100, David Kastrup wrote:
>> tomas@tuxteam.de writes:
>>
>> > Hi,
>> >
>> > In Elisp, I'm trying to test whether a string is a prefix of another.
>
> [...]
>
>> > (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 ...
>
> Thanks. Still looks a bit funna, though :-)
>
> -- tomás
(defun string-prefixp (string prefix &optional ignore-case)
"Return t if PREFIX is a prefix of STRING."
(eq t
(compare-strings string 0 (length prefix)
prefix 0 (length prefix)
ignore-case)))
I defined this function in one of my elisp files. Why don't you do just
the same ? Where is the problem.
-ap