Re: Non-nil default value in hook variables

2011-04-16 Thread Roland Winkler
On Fri Apr 15 2011 Leo wrote:
 When people use add-hook they think they are adding another function to
 a hook so if this isn't the case it will surprise them. People who are
 setting hook to nil is in a different thinking.

There are add-hook and remove-hook. The latter fails (now) if you
want to remove the default hook function via a simple call to
remove-hook in your .eamcs. It only works if you make sure it is
called after loading bbdb. (Yet as I said, this case is probably
more rare, so it is probably OK.)

Roland

--
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
___
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/


Re: Non-nil default value in hook variables

2011-04-15 Thread Ted Zlatanov
On Thu, 14 Apr 2011 21:15:12 -0500 Roland Winkler wink...@gnu.org wrote: 

RW What should someone do who simply wants the hook to be nil?

IMHO you should never set a hook to nil outside the file scope that
created it.  Do you have such a use case?

Ted


--
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
___
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/


Non-nil default value in hook variables

2011-04-14 Thread Leo
Hello,

I have been bitten more than once by non-nil default values in hook
variables such as:

(defcustom bbdb-create-hook 'bbdb-creation-date
  :group 'bbdb
  :type 'hook)

Then if one does

(add-hook 'bbdb-create-hook 'bbdb-add-uuid) in one's .emacs, the default
value may be ignored.

I suggest change all these defcustom instances something like:

(defcustom bbdb-create-hook nil
  :group 'bbdb
  :type 'hook)
(add-hook 'bbdb-create-hook 'bbdb-creation-date)

Leo


--
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
___
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/


Re: Non-nil default value in hook variables

2011-04-14 Thread Roland Winkler
On Fri Apr 15 2011 Leo wrote:
 I suggest change all these defcustom instances something like:
 
 (defcustom bbdb-create-hook nil
   :group 'bbdb
   :type 'hook)
 (add-hook 'bbdb-create-hook 'bbdb-creation-date)

Agreed and thanks, that looks much cleaner!

Roland

--
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
___
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/


Re: Non-nil default value in hook variables

2011-04-14 Thread Stefan Monnier
 I suggest change all these defcustom instances something like:
 
 (defcustom bbdb-create-hook nil
 :group 'bbdb
 :type 'hook)
 (add-hook 'bbdb-create-hook 'bbdb-creation-date)

 Agreed and thanks, that looks much cleaner!

But then don't define them as defcustom but just defvars since Custom
gets confused by the add-hook.


Stefan


--
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
___
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/


Re: Non-nil default value in hook variables

2011-04-14 Thread Roland Winkler
On Thu Apr 14 2011 Stefan Monnier wrote:
  I suggest change all these defcustom instances something like:
  
  (defcustom bbdb-create-hook nil
  :group 'bbdb
  :type 'hook)
  (add-hook 'bbdb-create-hook 'bbdb-creation-date)
 
  Agreed and thanks, that looks much cleaner!
 
 But then don't define them as defcustom but just defvars since Custom
 gets confused by the add-hook.

...another good point! -- It would be nice to have a possibility to
define hook variables with defcustom such that these variables can
have a non-nil default value. But the more I think about this, the
more this appears to be a nasty and messy problem (allowing the user
both to extend the hook and to replace the hook). Oh well...

Roland

--
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
___
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/


Re: Non-nil default value in hook variables

2011-04-14 Thread Roland Winkler
On Thu Apr 14 2011 Stefan Monnier wrote:
  I suggest change all these defcustom instances something like:
  
  (defcustom bbdb-create-hook nil
  :group 'bbdb
  :type 'hook)
  (add-hook 'bbdb-create-hook 'bbdb-creation-date)
 
  Agreed and thanks, that looks much cleaner!
 
 But then don't define them as defcustom but just defvars since Custom
 gets confused by the add-hook.

One more thought on this:

What should someone do who simply wants the hook to be nil?
If add-hook is called explicitly in bbdb.el such people are stuck:
their setting is lost when bbdb.el is loaded (whereas there was no
such problem with the original code where the default value of the hook
variable is set with a call to defcustom).

It seems to me that whatever scheme is used here, at best it can
only make some people happy. Oh well!

(Yet here it is probably more likely that people want to add
elements to the hook than making it nil. This makes calling add-hook
in bbdb.el the better solution here.)

Roland

--
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
___
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/


Re: Non-nil default value in hook variables

2011-04-14 Thread Leo
On 2011-04-15 10:15 +0800, Roland Winkler wrote:
 One more thought on this:

 What should someone do who simply wants the hook to be nil?
 If add-hook is called explicitly in bbdb.el such people are stuck:
 their setting is lost when bbdb.el is loaded (whereas there was no
 such problem with the original code where the default value of the hook
 variable is set with a call to defcustom).

When people use add-hook they think they are adding another function to
a hook so if this isn't the case it will surprise them. People who are
setting hook to nil is in a different thinking.

 It seems to me that whatever scheme is used here, at best it can
 only make some people happy. Oh well!

 (Yet here it is probably more likely that people want to add
 elements to the hook than making it nil. This makes calling add-hook
 in bbdb.el the better solution here.)

 Roland

Leo


--
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
___
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/