From: Jorgen Schaefer <forcer@forcix.cx>
To: 13814@debbugs.gnu.org
Subject: bug#13814: 24.3.50; Dynamic variables shadowing prevent defvar
Date: Mon, 25 Feb 2013 20:30:29 +0100 [thread overview]
Message-ID: <87hal0199m.fsf@orion.kollektiv-hamburg.de> (raw)
When a file is autoloaded, defvar will fail to define locally-set,
dynamic variabls, resulting in such variables not being defined at all,
even after their local binding ends.
Situation:
(let ((some-var-that-influences-behavior t))
(some-function-that-autoloads-a-library))
If the library which is autoloaded by
`some-function-that-autoloads-a-library' defines
`some-var-that-influences-behavior' using defvar or defcustom, the
variable is never bound globally because defvar thinks it's already
defined.
I would expect defvar to notice that the variable is bound only
locally/temporarily and define a global binding anyhow.
Reproduction:
Put this file, bug-lib.el, somewhere in `load-path':
-----8<----- bug-lib.el -----8<-----
(defvar bug-variable t
"This variable is not defined when autoloaded.")
(defun bug-variable-value ()
bug-variable)
----->8----- ---------- ----->8-----
Then execute the following lines:
(autoload 'bug-variable-value "bug-lib.el")
(let ((bug-variable nil))
(bug-variable-value))
=> nil
(bug-variable-value)
=> Error, `bug-variable' is not defined.
Regards,
-- Jorgen
In GNU Emacs 24.3.50.1 (x86_64-unknown-linux-gnu)
Bzr revision: 111608 schwab@linux-m68k.org-20130126151309-wk3nb8t4xitw94lh
Configured using:
`configure --without-x --with-x-toolkit=no'
next reply other threads:[~2013-02-25 19:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-25 19:30 Jorgen Schaefer [this message]
2013-02-25 23:15 ` bug#13814: 24.3.50; Dynamic variables shadowing prevent defvar Glenn Morris
2013-02-26 0:03 ` Stefan Monnier
2021-08-23 1:21 ` Lars Ingebrigtsen
2021-08-24 21:25 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-08-25 11:00 ` Lars Ingebrigtsen
2021-08-25 14:41 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-08-25 16:03 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87hal0199m.fsf@orion.kollektiv-hamburg.de \
--to=forcer@forcix.cx \
--cc=13814@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).