Path: utzoo!yunexus!ists!jarvis.csri.toronto.edu!rutgers!ucsd!usc!apple!bbn!gateway!rpi.UUCP!tale From: tale@rpi.UUCP (David C Lawrence) Newsgroups: comp.emacs Subject: Re: possible s-expr management error (? naw, but ...) Message-ID: <48417@bbn.COM> Date: 17 Nov 89 21:00:03 GMT Article-I.D.: bbn.48417 Sender: news@bbn.COM Reply-To: UNIX-EMACS@VM.TCS.Tulane.EDU Organization: BBN news/mail gateway Lines: 32 In <31688@news.Think.COM> barmar@leander.think.com (Barry Margolin) writes: Barry> SORT is a destructive operation; it actually reorders the Barry> original list by rearranging the cdr chain. [...] Barry> The above code should then be changed to Barry> (setq gnus-unsub-assoc (sort (copy-list gnus-unsub-assoc) 'gnus-assoc-lessp)) In <1989Nov16.061626.22143@rpi.edu> tale@pawl.rpi.edu (Me): Me> It should not. That screws the function up. I used sort because Me> sort was what I wanted. I am well aware of the lisp functions which Me> directly alter list structure and the usage of both sort and setcdr in Me> the function was for exactly that behaviour. Boy, do I love the taste of shoe leather. The nifty little sorting hack which worked for me because I had a mostly sorted list anyway ended up being a krufty mismanagement of pointers which is unnecessary because the function cleans up after itself later anyway. Blargh. As Barry suggests, but using an Emacs builtin: (setq gnus-unsub-assoc (sort (copy-sequence gnus-unsub-assoc) 'gnus-assoc-lessp)) is the appropriate thing to do. Sheepishly, Dave -- (setq mail '("tale@pawl.rpi.edu" "tale@ai.mit.edu" "tale@rpitsmts.bitnet"))