From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/13756 Path: main.gmane.org!not-for-mail From: Colin Rafferty Newsgroups: gmane.emacs.gnus.general Subject: Re: function to pack folders Date: 02 Feb 1998 15:00:07 -0500 Sender: owner-ding@hpc.uh.edu Message-ID: References: NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 (generated by tm-edit 7.108) Content-Type: text/plain; charset=US-ASCII X-Trace: main.gmane.org 1035153064 10965 80.91.224.250 (20 Oct 2002 22:31:04 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 20 Oct 2002 22:31:04 +0000 (UTC) Return-Path: Original-Received: from xemacs.org (xemacs.cs.uiuc.edu [128.174.252.16]) by altair.xemacs.org (8.8.8/8.8.8) with ESMTP id MAA04835 for ; Mon, 2 Feb 1998 12:03:55 -0800 Original-Received: from sina.hpc.uh.edu (root@Sina.HPC.UH.EDU [129.7.3.5]) by xemacs.org (8.8.5/8.8.5) with ESMTP id OAA01003 for ; Mon, 2 Feb 1998 14:00:59 -0600 (CST) Original-Received: from sina.hpc.uh.edu (lists@Sina.HPC.UH.EDU [129.7.3.5]) by sina.hpc.uh.edu (8.7.3/8.7.3) with ESMTP id OAH12039; Mon, 2 Feb 1998 14:01:00 -0600 (CST) Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Mon, 02 Feb 1998 14:00:37 -0600 (CST) Original-Received: from claymore.vcinet.com (claymore.vcinet.com [208.205.12.23]) by sina.hpc.uh.edu (8.7.3/8.7.3) with SMTP id OAA12025 for ; Mon, 2 Feb 1998 14:00:28 -0600 (CST) Original-Received: (qmail 9391 invoked by uid 504); 2 Feb 1998 20:00:25 -0000 Original-Received: (qmail 9387 invoked from network); 2 Feb 1998 20:00:25 -0000 Original-Received: from wfdutilf01.ml.com (HELO wfdutilgw.ml.com) (206.3.74.31) by claymore.vcinet.com with SMTP; 2 Feb 1998 20:00:24 -0000 Original-Received: from ml1.ml.com ([199.201.57.130]) by wfdutilgw.ml.com (8.8.7/8.8.7/MLgwo-3.05) with ESMTP id OAA02087 for ; Mon, 2 Feb 1998 14:58:13 -0500 (EST) Original-Received: from pme-mail.spspme.ml.com (pme-mail.spspme.ml.com [192.168.111.94]) by ml1.ml.com (8.8.7/8.8.7/MLml4-2.08) with SMTP id PAA04244 for ; Mon, 2 Feb 1998 15:00:09 -0500 (EST) Original-Received: from spssunp.spspme.ml.com by pme-mail.spspme.ml.com (SMI-8.6/ML55SMX-1.02) id PAA04409; Mon, 2 Feb 1998 15:00:08 -0500 Original-Received: by spssunp.spspme.ml.com (SMI-8.6/SMI-SVR4) id PAA07860; Mon, 2 Feb 1998 15:00:07 -0500 Original-To: (ding) GNUS Mailing List X-Face: ByE+UMAp1klWR3?\RNGx(A-~Ri!YT%C6M!sxoJL+.;9`Q/|+dj7[KR>gGMyV.2qZeot0NI`4\MA^_Qg`F9=+Ox&zaE?Y9dV%F~Xzf';Zyk2Aobs.uu^Ey0_C6^~q';G#$HkA!ZAHXPpG-"*|Dd*Z4U$4y{{aI0c%75}i~Of(jxYtI[uIpYF<*Zoe|\*/ufb X-Y-Zippy: The Korean War must have been fun. In-Reply-To: Mark Moll's message of "02 Feb 1998 13:22:53 -0500" Original-Lines: 108 X-Mailer: Gnus v5.5/XEmacs 20.5(beta22) - "Grison's Striped" Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:13756 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:13756 Mark Moll writes: > I wrote this little function to renumber articles in my nnml folders. I > don't know that much about elisp, but this seemed a reasonable way to do it. > For some reason, however, I get the following error when I call the function > below in the summary buffer. > Symbol's value as variable is void: group > It's probably something very trivial, but can anybody tell me what I'm > doing wrong? > ... > (let ((group gnus-newsgroup-name) > (folder (replace-in-string > (replace-in-string group > "\\(nnml\\+archive:\\)\\(.*\\)" > "archive/\\2") > "\\(nnml:\\)\\(.*\\)" "\\2")) > (dir (concat message-directory folder))) > ... Short answers (two independent solutions): 1. Use `let*' instead of `let'. 2. Use `gnus-newsgroup-name' instead of `group' in the call to `replace-in-string'. Long answer: The problem is the `group' in the call to replace-in-string. Since you are using `let', the variables are not bound until the body is being executed. Specifically, a `let' form is really just syntactic sugar for calling a lambda-expression, and you cannot use the values of some of the arguments to evaluate the other arguments. For example, imagine I had the following let form: (let ((x (* 2 3)) (y (+ 5 6))) (+ x y)) It will be translated into the following: (funcall #'(lambda (x y) (+ x y)) (* 2 3) (+ 5 6)) Therefore, if you have something that looks like this: (let ((group gnus-newsgroup-name) (folder (replace-in-string (replace-in-string group "\\(nnml\\+archive:\\)\\(.*\\)" "archive/\\2") "\\(nnml:\\)\\(.*\\)" "\\2")) (dir (concat message-directory folder))) (call-process "gunzip" nil nil nil (concat dir "/*.gz")) (call-process "folder" nil nil nil (concat "+" folder) "-pack") (nnml-generate-nov-databases-1 (concat dir)) (call-process "gzip" nil nil nil (concat dir "/*")) (gnus-summary-reselect-current-group)) It would be translated into this: (funcall #'(lambda (group folder dir) (call-process "gunzip" nil nil nil (concat dir "/*.gz")) (call-process "folder" nil nil nil (concat "+" folder) "-pack") (nnml-generate-nov-databases-1 (concat dir)) (call-process "gzip" nil nil nil (concat dir "/*")) (gnus-summary-reselect-current-group)) gnus-newsgroup-name (replace-in-string (replace-in-string group "\\(nnml\\+archive:\\)\\(.*\\)" "archive/\\2") "\\(nnml:\\)\\(.*\\)" "\\2") (concat message-directory folder)) As you can see, the reference to `group' in the `replace-in-string' is unbound, since it only exists in the lambda-expression itself. By the way, while I was writing this reply, I realized that, while `let' is a built-in function, I could write it as a macro. I really need to get a more exciting job. (defmacro mac-let (varlist &rest body) "Macro version of let." (append (list 'funcall (append (list 'lambda (mapcar #'(lambda (varspec) (cond ((symbolp varspec) varspec) ((consp varspec) (car varspec)) (error "invalid varspec %s" varspec))) varlist)) body)) (mapcar #'(lambda (varspec) (and (consp varspec) (car (cdr varspec)))) varlist))) I'll leave writing `mac-let*' as an exercise to the reader. :-) -- Colin