From xemacs-m  Tue Apr 15 13:45:58 1997
Received: from jagor.srce.hr (hniksic@jagor.srce.hr [161.53.2.130])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id NAA02518
	for <xemacs-beta@xemacs.org>; Tue, 15 Apr 1997 13:45:56 -0500 (CDT)
Received: (from hniksic@localhost)
          by jagor.srce.hr (8.8.5/8.8.4)
	  id UAA15125; Tue, 15 Apr 1997 20:45:41 +0200 (MET DST)
Cc: xemacs-beta@xemacs.org, emacs-custom@sunsite.auc.dk
Subject: Re: Specifiers in custom
References: <kigzpv3xjqu.fsf@jagor.srce.hr> <rj912mj446.fsf@zuse.dina.kvl.dk> <kigiv1qyjyr.fsf@jagor.srce.hr> <rjzpv2ho21.fsf@zuse.dina.kvl.dk> <kigohbgh9t8.fsf@jagor.srce.hr> <rj912kfu45.fsf@zuse.dina.kvl.dk> <kign2r0h6z5.fsf@jagor.srce.hr> <rj67xofpjo.fsf@zuse.dina.kvl.dk> <kig912kgvam.fsf@jagor.srce.hr> <rjn2r0dul6.fsf@zuse.dina.kvl.dk>
X-URL: ftp://gnjilux.cc.fer.hr/pub/unix/util/wget/
X-Attribution: Hrv
X-Face: &}4JQk=L;e.~x+|eo]#DGk@x3~ed!.~lZ}YQcYb7f[WL9L'Z*+OyA\nA
        EL1M(".[qvI#a2E6WYI5>>e7'@_)3Ol9p|Nn2wNa/;~06jL*B%tTcn/X
        vhAu7qeES0\|MF%$;sI#yn1+y"
From: Hrvoje Niksic <hniksic@srce.hr>
Date: 15 Apr 1997 20:45:40 +0200
In-Reply-To: Per Abrahamsen's message of 15 Apr 1997 20:11:49 +0200
Message-ID: <kigd8rw9lbf.fsf@jagor.srce.hr>
Lines: 71
X-Mailer: Gnus v5.4.45/XEmacs 19.15

Per Abrahamsen <abraham@dina.kvl.dk> writes:

> There is still a problem with initialization.  How and when should the
> `defcustom' construct call the :set function?
> 
> Here are some answers:
> 
> 1) Never.  It is only used when changing the value, not when
>    initializing.  This is the correct answer for `ispell-dictionary'.

I don't think this is satisfactory.  `:set' should be used to convert
from a simple external format to a complex internal format.  This goes
for both initialization, as well as changing.

> 2) Always.  Even if the variable is already bound, call the :set
>    function with its current value.  This way the user can use `setq'
>    to set the option is his .emacs, and get the code run anyway.  

This looks like the most correct option, unless you implement
`:initialize'.

> :get		function to get the current value (default: default-value)
> :set		function to set the current value (default: set-default)
> :initialize	function to initialize the the value
> 		(default: part of custom-declare-variable).

Looks good to me.  I think this makes it possible for all of the
examples to be worked out, with a very simple and intuitive API.  This
is the main virtue of customize, IMHO.

> :require	feature to require after (before?) setting the value with
> 		`custom-set-variables' (default: none).

This makes sense, too.

(defcustom menubar-visible-p t
  "*Whether the menubar is visible.
This is a specifier; use `set-specifier' (or customize:-) to change it."
  :type 'boolean
  :get (lambda (sym) (specifier-instance (symbol-value sym)))
  :set (lambda (sym val) (set-specifier (symbol-value sym) val))
  :group 'menubar)

Excellent.  Would a :initialize make sense here?



XEmacs note:

In the specifier case, we could define functions like:

(defun custom-set-specifier (sym val)
  "Set the specifier with symbol SYM to the value VAL, globally."
  (set-specifier (symbol-value sym) val))

(defun custom-get-specifier (sym)
  "Return the instance of the specifier with symbol SYM."
  (specifier-instance (symbol-value sym)))

Then a simple

  :get 'custom-get-specifier
  :set 'custom-set-specifier

would suffice.

-- 
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
* Q: What is an experienced Emacs user?
* A: A person who wishes that the terminal had pedals.

