From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: With lexical-binding t, how do I bind an external symbol dynamicall? Date: Sat, 29 Aug 2015 18:07:05 +0000 Message-ID: <20150829180705.GC20484@acm.fritz.box> References: <20150829163544.GB20484@acm.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1440871579 9253 80.91.229.3 (29 Aug 2015 18:06:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 29 Aug 2015 18:06:19 +0000 (UTC) Cc: emacs-devel@gnu.org To: Philipp Stephani Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 29 20:06:11 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZVkW2-0002np-Hi for ged-emacs-devel@m.gmane.org; Sat, 29 Aug 2015 20:06:10 +0200 Original-Received: from localhost ([::1]:53854 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVkW1-0008AA-A3 for ged-emacs-devel@m.gmane.org; Sat, 29 Aug 2015 14:06:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVkVy-00089W-HM for emacs-devel@gnu.org; Sat, 29 Aug 2015 14:06:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZVkVt-0008OR-Ik for emacs-devel@gnu.org; Sat, 29 Aug 2015 14:06:06 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:30394) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVkVt-0008OK-8q for emacs-devel@gnu.org; Sat, 29 Aug 2015 14:06:01 -0400 Original-Received: (qmail 72273 invoked by uid 3782); 29 Aug 2015 18:05:59 -0000 Original-Received: from acm.muc.de (p5B1468D1.dip0.t-ipconnect.de [91.20.104.209]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 29 Aug 2015 20:05:58 +0200 Original-Received: (qmail 21142 invoked by uid 1000); 29 Aug 2015 18:07:05 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x X-Received-From: 193.149.48.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:189298 Archived-At: Hello, Philipp. On Sat, Aug 29, 2015 at 05:30:20PM +0000, Philipp Stephani wrote: > Alan Mackenzie schrieb am Sa., 29. Aug. 2015 um 18:34 Uhr: > > Hello, Emacs! > > In some Elisp with no knowledge of the variable `some-flag', which will > > be defined elsewhere, I want to write > > (let (some-flag) ....) > > to bind `some-flag' dynamically. The byte-compiler give me the warning: > > Unused lexical variable `some-flag' > > . Somehow, I need to tell the byte-compiler that `some-flag' will be an > > external dynamic variable. How do I do this? > Use (defvar some-flag) before using some-flag. That will do nothing except > marking some-flag as special (dynamic). Ah! It's obvious, isn't it? ;-) Thank you very much indeed! I've now restored the lexical-binding to the pertinent file.el > > I've had a look around the "Variables" page, and its sub-pages, in the > > elisp manual, yet didn't find any instructions on how to get round this > > problem. Where in the manual is it described? > It's mentioned in 16.6 Compiler Errors, but without mentioning dynamic > binding. I discovered the behavior by looking at the Emacs source code; but > this should be stated more prominently in the Elisp manual because it can > lead to subtle errors if the warning is ignored or silenced. Yes. I think a bug report is in order. -- Alan Mackenzie (Nuremberg, Germany).