[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

15. Customizing Objects

In Emacs 20 a useful customization utility became available called `custom'. EIEIO supports custom through two new widget types. If a variable is declared as type 'object, then full editing of slots via the widgets is made possible. This should be used carefully, however, because objects modified are cloned, so if there are other references to these objects, they will no longer be linked together.

If you want in place editing of objects, use the following methods:

Function: eieio-customize-object object
Create a custom buffer and insert a widget for editing object. At the end, an Apply and Reset button are available. This will edit the object "in place" so references to it are also changed. There is no effort to prevent multiple edits of a singular object, so care must be taken by the user of this function.

Function: eieio-custom-widget-insert object flags
This method inserts an edit object into the current buffer in place. It's sole code is (widget-create 'object-edit :value object) and is provided as a locale for adding tracking, or specializing the widget insert procedure for any object.

To define a slot with an object in it, use the object tag. This widget type will be automatically converted to object-edit if you do in place editing of you object.

If you want to have additional actions taken when a user clicks on the Apply button, then overload the method eieio-done-customizing. This method does nothing by default, but that may change in the future. This would be the best way to make your objects persistent when using in-place editing.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

15.1 Widget extention

When widgets are being created, one new widget extention has been added, called the :slotofchoices. When this occurs in a widget definition, all elements after it are removed, and the slot is specifies is queried and converted into a series of constants.

 
(choice (const :tag "None" nil)
        :slotofchoices morestuff)

and if the slot morestuff contains (sym1 sym2 sym3), the above example is converted into:

 
(choice (const :tag "None" nil)
        (const sym1)
        (const sym2)
        (const sym3))

This is useful when a given item needs to be selected from a list of items defined in this second slot.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by XEmacs shared group account on December, 19 2009 using texi2html 1.65.