[Top][All Lists]

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

Re: doc elisp intro cross reference fixes

From: Luc Teirlinck
Subject: Re: doc elisp intro cross reference fixes
Date: Sat, 29 Nov 2003 14:29:15 -0600 (CST)

Richard Stallman wrote:

       Indeed:  (defalias 'set-variable 'customize-set-variable)

       Note that if you mean this literally, this is a non-trivial change in
       as far as prefix arguments are concerned.  Right now, C-u set-variable
       will set the buffer-local value.

   Yes, we would want to add a similar C-u feature to customize-set-variable
   before doing this.

Note that the optional argument is not the only difference between
`customize-set-variable' and `set-variable'.  Differences if both are
called without optional argument on a variable VAR:

1.  If VAR already has a buffer-local binding `set-variable' sets that
    buffer-local binding _even_ when called without prefix argument.
    The prefix argument just guarantees that a buffer-local binding
    will be made if there was none before.  `custom-set-variable' sets
    the default value.

2.  If we enter a form in the minibuffer, set-variable uses the
    unevaluated value, custom-set-variable the evaluated value.

(See the ielm run below for examples.)

If we would merge the two functions into one, we have to decide
how to reconcile those two differences.

The buffer-local issue is more complex.

Currently there is a variable "custom-local-buffer".  It _only_ tries
to set a local value if the variable already has a local value, it
does not make a buffer-local binding itself.  It is essentially
undocumented and unsupported.  The necessary code to support it was
never installed and was lost.  There is some minimal supporting code
in `custom-set-default' and `custom-set-minor-mode', but in no other
part of Custom.  I grepped.  Not a single :set function (other than
the two mentioned ones) supports it.

That variable is more or less irrelevant to the issue at hand anyway.
The buffer current at the time will be the buffer from which
set-variable or custom-set-variable was called.

The problem is that :set functions usually are not written to deal
with buffer-local values.  The authors of :set functions are not to
blame for that, because (elisp)Customization does not mention
anything about dealing with buffer-local-values:

   The default for SETFUNCTION is `set-default'.

Hence, :set functions are supposed to generalize `set-default',
nothing buffer-local in sight.

Do we just ignore the :set function and use `set' when dealing with
buffer-local values?  Do we come up with a means to declare a :set
function "safe for buffer-local use" and call it if it satisfies that

Ielm run illustrating some of the above:

===File ~/set-var-ielm======================================
*** Welcome to IELM ***  Type (describe-mode) for help.
ELISP> (defvar aa 1 "*aha")
ELISP> (make-variable-buffer-local 'aa)
ELISP> (setq aa 2)
ELISP> ;; M-x set-variable RET aa RET (list (current-buffer) (point)) 
*** Read error ***  End of file during parsing

ELISP> (default-value 'aa)
ELISP> ;; M-x custom-set-variable RET aa RET (list (current-buffer) (point)) 
*** Read error ***  End of file during parsing

ELISP> (default-value 'aa)
(#<buffer *ielm*> 420)


reply via email to

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