From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.devel Subject: Re: With lexical-binding t, how do I bind an external symbol dynamicall? Date: Sat, 29 Aug 2015 17:30:20 +0000 Message-ID: References: <20150829163544.GB20484@acm.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a113ac11c90eed6051e768ebe X-Trace: ger.gmane.org 1440869453 10638 80.91.229.3 (29 Aug 2015 17:30:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 29 Aug 2015 17:30:53 +0000 (UTC) To: Alan Mackenzie , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 29 19:30:53 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 1ZVjxq-0005hf-P4 for ged-emacs-devel@m.gmane.org; Sat, 29 Aug 2015 19:30:50 +0200 Original-Received: from localhost ([::1]:53718 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVjxq-00021s-2Z for ged-emacs-devel@m.gmane.org; Sat, 29 Aug 2015 13:30:50 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVjxY-00021W-LZ for emacs-devel@gnu.org; Sat, 29 Aug 2015 13:30:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZVjxX-0000Ty-8R for emacs-devel@gnu.org; Sat, 29 Aug 2015 13:30:32 -0400 Original-Received: from mail-yk0-x235.google.com ([2607:f8b0:4002:c07::235]:35030) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVjxX-0000Tr-37 for emacs-devel@gnu.org; Sat, 29 Aug 2015 13:30:31 -0400 Original-Received: by ykbu129 with SMTP id u129so11577674ykb.2 for ; Sat, 29 Aug 2015 10:30:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-type; bh=VxNy7r37glfXUDbfI4IBemW567aZiOGMq8vCYjVZBfY=; b=QmuY6fw0YeQ0Salrj4f+KfOVKenTC9qT+4WajdSzIVaSN0005pw1cP59c0wr3y4bO5 0NKwSXvJ/ohhOB6DS0pLyIQzCDv8pCSs0G+vzw36DxbE46v+py4966SuekKOi08EMwc0 UoPKR7nDSfLlkBS+nBkxPeds3qri+uxq4KBLVUHSa74CMcultwj+HC3wYBjrFuOkB4Ig P54bt1LlOMzND5K78nZkV8hfWnL2s8bfEj1t+TkrgDKWSiRQvgiqxVNf8U9KzayWFMot rtdkTyZJDi07S87P70hIei6xzlr7T+nGq0/g0uMUj0UpDe83/F47VFQfNFKjUIOP40Pf WmPg== X-Received: by 10.170.88.213 with SMTP id f204mr14459759yka.32.1440869430388; Sat, 29 Aug 2015 10:30:30 -0700 (PDT) In-Reply-To: <20150829163544.GB20484@acm.fritz.box> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4002:c07::235 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:189297 Archived-At: --001a113ac11c90eed6051e768ebe Content-Type: text/plain; charset=UTF-8 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). > 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. --001a113ac11c90eed6051e768ebe Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


Alan M= ackenzie <acm@muc.de> schrieb am Sa= ., 29. Aug. 2015 um 18:34=C2=A0Uhr:
Hello, Emacs!

In some Elisp with no knowledge of the variable `some-flag', which will=
be defined elsewhere, I want to write

=C2=A0 =C2=A0 =C2=A0 =C2=A0 (let (some-flag) ....)

to bind `some-flag' dynamically.=C2=A0 The byte-compiler give me the wa= rning:

=C2=A0 =C2=A0 Unused lexical variable `some-flag'

.=C2=A0 Somehow, I need to tell the byte-compiler that `some-flag' will= be an
external dynamic variable.=C2=A0 How do I do this?


Use (defvar some-flag) before using so= me-flag. That will do nothing except marking some-flag as special (dynamic)= .
=C2=A0
I've had a look around the "Variables" page, and its sub-page= s, in the
elisp manual, yet didn't find any instructions on how to get round this=
problem.=C2=A0 Where in the manual is it described?


It's mentioned in 16.6 Compiler Errors, but without me= ntioning dynamic binding. I discovered the behavior by looking at the Emacs= source code; but this should be stated more prominently in the Elisp manua= l because it can lead to subtle errors if the warning is ignored or silence= d.
--001a113ac11c90eed6051e768ebe--