From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: lawrence mitchell Newsgroups: gmane.emacs.help Subject: Re: Help with elisp Date: Thu, 31 Jul 2003 12:30:58 +0100 Organization: funfunfun Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1059651394 10914 80.91.224.249 (31 Jul 2003 11:36:34 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 31 Jul 2003 11:36:34 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 31 13:36:28 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19iBjP-0002pY-00 for ; Thu, 31 Jul 2003 13:36:28 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19iBiY-0005tf-J2 for geh-help-gnu-emacs@m.gmane.org; Thu, 31 Jul 2003 07:35:34 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!vegetable.demon.co.UK!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 75 Original-NNTP-Posting-Host: vegetable.demon.co.uk (80.177.16.3) Original-X-Trace: news.uni-berlin.de 1059651058 23776761 80.177.16.3 (16 [97657]) X-No-Yes: No Mail-Copies-To: nobody User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 Cancel-Lock: sha1:X2X5out98lEPjDMvDabW2mNnkug= Original-Xref: shelby.stanford.edu gnu.emacs.help:115580 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:11498 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:11498 David Chadd wrote: > Apologies for a question demonstrating beginner's total Elisp > incompetence. I want to make lists out of series of > attribute-values in an xml file. (The values are sigla of > manuscripts.) These are e.g. in the form: > wit="CAO-C Alb2 Hyd" > Having found the string of values (CAO-C Alb2 Hyd) with a regexp > search, I simple-mindedly thought I would be able to do something like > (setq wits (split-string (match-string 1))) > This does indeed make a list --- (listp wits) returns T --- but the > lists don't behave as I would expect. For instance, they don't > respond correctly to (set-difference), (intersection) etc. And for > reasons I can guess at, but don't know enough to do anything about, > the lists are in the form ("CAO-C" "Alb2" "Hyd") rather than (CAO-C > Alb2 Hyd). > I'm obviously going totally the wrong way about this. How should I be > trying to make a conventional Lisp list out of a found string of this > kind? Advice and guidance gratefully received. In fact, you're almost there. The only thing you're missing is the correct equality test. You see, strings are not EQ, or EQL in emacs lisp. (eq "foo" "foo") => nil (eql "foo" "foo") => nil instead, you need to check for equality either with EQUAL, or, if you know you are using strings, STRING=. (equal "foo" "foo") => t (string= "foo" "foo") => t Now, the functions SET-DIFFERENCE and INTERSECTION by default test for equality with EQ, so you need to tell them to use a different testing function. This can be done by supplying them with a keyword argument. (setq foo '("foo" "bar" "baz") bar '("bar" "baz" "quux")) foo => ("foo" "bar" "baz") bar => ("bar" "baz" "quux") ;; Default, comparison done with EQ. (set-difference foo bar) => ("baz" "bar" "foo") (intersection foo bar) => nil ;; Comparison done with STRING= (set-difference foo bar :test 'string=) => ("foo") (intersection foo bar :test 'string=) => ("baz" "bar") Hope that clears things up a bit -- lawrence mitchell