         # cat1_top: move certain categories to the top of the list -- see sort functions in @get_catlistN
         # TODO this is something that should be part of the "data" itself, not hardcoded here at all
         @set
-            cat0           : null # idx integer
-            cat1           : null # idx integer
-            cat2           : null # idx integer
-            catlist0       : []
-            catlist1       : []
-            catlist2       : []
-            code           : ''
-            descr          : ''
-            hits           : []
-            search_str     : null
-            search_sel     : null
-            submittable    : false
-            cat1_top       : ["Introduction", "Tutorial", "Help"]
-            unknown_lang   : false
+            cat0                : null # idx integer
+            cat1                : null # idx integer
+            cat2                : null # idx integer
+            catlist0            : []
+            catlist1            : []
+            catlist2            : []
+            code                : ''
+            setup_code          : undefined
+            descr               : ''
+            hits                : []
+            search_str          : null
+            search_sel          : null
+            submittable         : false
+            cat1_top            : ["Introduction", "Tutorial", "Help"]
+            unknown_lang        : false
 
     hide: =>
         @set(show: false)

    insert: (descr) ->
        # this is the essential task of the example dialog:
        # call the callback with the selected code snippet
        data =
            code  : @get('code')
            lang  : @get('lang')
            descr : if descr then @get('descr') else null
        @get('handler')?(data)

                @set(cat1 : if idx == -1 then @get('catlist1').size - 1 else idx)
                catlist2 = @get_catlist2()
                @set
                    cat2       : undefined
                    catlist2   : catlist2
                if catlist2.length == 1
                    @set_selected_category(2, 0)

            when 2
                k0    = @get('catlist0').get(@get('cat0'))
                k1    = @get('catlist1').get(@get('cat1'))
                idx   = if idx == -1 then @get('catlist2').size - 1 else idx
                doc   = lang.getIn([k0, k1, 'entries', idx])
                setup = lang.getIn([k0, k1, 'setup'])
                @set(cat2:idx, setup_code:setup)
                @show_doc(doc)

# The top part of the dialog. Shows the Title (maybe with the Language), a selector for the language, and search
