emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: void variable


From: Luc Teirlinck
Subject: Re: void variable
Date: Sun, 25 Jul 2004 18:39:37 -0500 (CDT)

Lars Hansen wrote:

   Maybe there should also be a warning somewhere that one must ensure that 
   a module is loaded before making local bindings of variables defined in 
   that module. I just fixed a bug in wdired where the following happened: 
   A custom variable in dired-aux was bound locally just before the call of 
   an autoloading  function from dired-aux. The result was that the custom 
   variable was left void if dired-aux was loaded at that point. That 
   caused dired renaming to malfunction afterwards.

Would the following patches be more useful than my original ones?

===File ~/eval.c-diff-2=====================================
*** eval.c      19 Jul 2004 07:02:32 -0500      1.220
--- eval.c      25 Jul 2004 18:20:38 -0500      
***************
*** 742,747 ****
--- 742,756 ----
   This means that M-x set-variable recognizes it.
   See also `user-variable-p'.
  If INITVALUE is missing, SYMBOL's value is not set.
+ 
+ WARNING: If SYMBOL has a local binding when this form is called, then
+ the call affects the local binding.  This is usually not what you want.
+ Thus, if you make a local binding for a variable that is defined in
+ some file FILE with this form \(or with `defconst' or `defcustom',
+ which behave similarly in this respect), you should carefully check
+ whether something in the scope of the binding can load FILE.  If so,
+ you should execute \(require FILE) before making the binding, unless
+ for some reason you know that the file is already loaded.
  usage: (defvar SYMBOL &optional INITVALUE DOCSTRING)  */)
       (args)
       Lisp_Object args;
***************
*** 784,789 ****
--- 793,802 ----
  If SYMBOL is buffer-local, its default value is what is set;
   buffer-local values are not affected.
  DOCSTRING is optional.
+ 
+ If SYMBOL has a local binding, then this form sets the local binding's
+ value.  However, you should normally not make local bindings for
+ variables defined with this form.
  usage: (defconst SYMBOL INITVALUE [DOCSTRING])  */)
       (args)
       Lisp_Object args;
============================================================

===File ~/custom.el-diff-2==================================
*** custom.el   05 Jun 2004 22:41:36 -0500      1.75
--- custom.el   25 Jul 2004 18:30:52 -0500      
***************
*** 247,253 ****
          VARIABLES when both have been customized.
  
  Read the section about customization in the Emacs Lisp manual for more
! information."
    ;; It is better not to use backquote in this file,
    ;; because that makes a bootstrapping problem
    ;; if you need to recompile all the Lisp files using interpreted code.
--- 247,263 ----
          VARIABLES when both have been customized.
  
  Read the section about customization in the Emacs Lisp manual for more
! information.
! 
! WARNING: If SYMBOL has a local binding when this form is called,
! then the call affects the local binding.  This is usually not
! what you want.  Thus, if you make a local binding for a variable
! that is defined in some file FILE with this form \(or with
! `defvar' or `defconst', which behave similarly in this respect),
! you should carefully check whether something in the scope of the
! binding can load FILE.  If so, you should execute \(require FILE)
! before making the binding, unless for some reason you know that
! the file is already loaded."
    ;; It is better not to use backquote in this file,
    ;; because that makes a bootstrapping problem
    ;; if you need to recompile all the Lisp files using interpreted code.
============================================================




reply via email to

[Prev in Thread] Current Thread [Next in Thread]