Re: Custom type for "&rest props" style arguments?

Kevin Rodgers <[email protected]> Thu, 12 Jan 2006 10:12:03 -0700
Newsgroups gmane.emacs.help,gmane.emacs.customize
Message-ID <[email protected]>
Reiner Steib wrote:
> Hi,
> 
> I'd like to have a customizable list as follows:
> 
> (defcustom rs-test-list
>   '((gnus-summary-save-newsrc "save" nil :visible nil)
>     (gnus-summary-print-article "print")
>         (gnus-summary-edit-article
>      "search" nil :visible (not (gnus-group-read-only-p))))
>   "List of tool bar function items.
> 
> The first element of each item must be a menu command.  The
> second must be an icon file name.  The first two elements are
> required, all other are optinal.  The third argument is a keymap
> or nil (default keymap).  The forth and all following arguments
> are passed as the PROPS argument to `tool-bar-local-item'."
>   :type '(repeat (list (function :tag "Menu Command")
> 		       (string   :tag "Icon file")
> 		       (choice (const :tag "Default map" nil)
> 			       (sexp :tag "Other map"))
> 		       (choice :tag "Properties"
> 			       (const :tag "None" nil)
> 			       (sexp :tag "Other")))))
> 
> My problem is how to express "the forth and all following arguments"
> as a custom type.  My code results in a "mismatch" when calling `M-x
> customize-variable RET rs-test-list RET'.  The "Properties" are
> supposed to be passed as the PROPS argument to `tool-bar-local-item':
> 
> ,----[ <f1> f tool-bar-local-item RET ]
> | tool-bar-local-item is a compiled Lisp function in `tool-bar.el'.
> | (tool-bar-local-item ICON DEF KEY MAP &rest PROPS)
> | 
> | Add an item to the tool bar in map MAP.
> | ICON names the image, DEF is the key definition and KEY is a symbol
> | for the fake function key in the menu keymap.  Remaining arguments
> | PROPS are additional items to add to the menu item specification.  See
> | Info node `(elisp)Tool Bar'.  [...]
> `----
> 
> Here is an attempt for a defcustom of a single element:
> 
> (defcustom rs-test-item
>   '(gnus-summary-save-newsrc "save" nil :visible nil) ;; -> mismatch
>   ;; '(gnus-summary-print-article "print") ;; -> works
>   ;; '(gnus-summary-edit-article
>   ;;   "search" nil :visible (not (gnus-group-read-only-p))) ;; -> mismatch
>   "A single item for testing."
>   :type '(list (function :tag "Menu Command")
> 	       (string   :tag "Icon file name")
> 	       (choice (const :tag "Default map" nil)
> 		       (const :tag "No menu" t)
> 		       (sexp :tag "Other map"))
> 	       (choice :tag "Properties"
> 		       (const :tag "None" nil)
> 		       (sexp  :tag "Other"))))
> 
> (Instead of `:visible test-function' there could also arbitrary other
> arguments accepted by `tool-bar-local-item' such as `:help "Do
> this"')
> 
> Any hints?

I think you need the list widget's :inline keyword, described in the
"composite" node of the widget manual, perhaps like this:

(repeat :tag "Properties" :inline t
         (list :inline t
               ;; is there a keyword type, instead of symbol?
               (symbol :tag "Property") (sexp :tag "Value")))

-- 
Kevin Rodgers