From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Thorpe Newsgroups: gmane.emacs.help Subject: Re: [SOLVED with `eval']: Why I cannot use this variable in macro call from function? Date: Thu, 10 Jun 2021 03:10:53 +0100 Message-ID: <87y2bibhaq.fsf@robertthorpeconsulting.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19751"; mail-complaints-to="usenet@ciao.gmane.io" To: Jean Louis , tomas@tuxteam.de, help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 10 04:12:03 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lrAAt-00050N-Pp for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 10 Jun 2021 04:12:03 +0200 Original-Received: from localhost ([::1]:51848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrAAr-0007ih-LN for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 09 Jun 2021 22:12:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrAAY-0007iU-To for help-gnu-emacs@gnu.org; Wed, 09 Jun 2021 22:11:42 -0400 Original-Received: from outbound-smtp47.blacknight.com ([46.22.136.64]:55791) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrAAW-00006J-5E for help-gnu-emacs@gnu.org; Wed, 09 Jun 2021 22:11:42 -0400 Original-Received: from mail.blacknight.com (pemlinmail05.blacknight.ie [81.17.254.26]) by outbound-smtp47.blacknight.com (Postfix) with ESMTPS id 79B41FA8DB for ; Thu, 10 Jun 2021 03:11:35 +0100 (IST) Original-Received: (qmail 16416 invoked from network); 10 Jun 2021 02:11:35 -0000 Original-Received: from unknown (HELO rt-inspiron-3480) (rt@robertthorpeconsulting.com@[109.76.69.158]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 10 Jun 2021 02:11:35 -0000 In-Reply-To: (message from Jean Louis on Wed, 9 Jun 2021 17:39:25 +0300) Received-SPF: pass client-ip=46.22.136.64; envelope-from=rt@robertthorpeconsulting.com; helo=outbound-smtp47.blacknight.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:130690 Archived-At: I just want to say a couple of things about this. I think you should read the Emacs lisp manual more. Or maybe even another book on Lisp. Understanding of scope is important. So are macros and quoting if you're using them. For the snippet of code that Tomas gives I get the same result: > (let () > (let ((x 42)) > (eval '(progn (setq x 43) (message "in eval: x is %S" x))) > (message "inner let: x is %S" x)) > (message "outer let: x is %S" x)) Gives: > in eval: x is 43 > inner let: x is 42 > outer let: x is 43 > "outer let: x is 43" I don't get any errors. However, I think that your problem doesn't really require any of that complexity. I think it can be done with an Alist. Why not save all of your histories into one alist? Instead of an alist you could use a hash. I don't see why you have to create a set of new global variables to solve the problem. You have a function that creates one of those variables. Why not replace it with a function that enters the information in a global alist? Then you only need one global variable. Then when you need to call "completing-read" use an assoc to find the sub-list to use. BR, Robert Thorpe