help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: custom types using define-widget


From: Reiner Steib
Subject: Re: custom types using define-widget
Date: Sat, 14 Jan 2006 18:00:53 +0100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

On Sat, Jan 14 2006, Per Abrahamsen wrote:

> Reiner Steib <reinersteib+gmane@imap.cc> writes:
>
>> Now, I have six variables (more to come) like this one.  Repeating the
>> full blown custom type for each variable is inconvenient and error
>> prone in case of changes.  So I tried to define a widget using the
>> same type as above:
>>
>> (define-widget 'rs-tool-bar-list 'default
[...]
>
> Try to derive from "lazy" instead of "default"

That works.  Thanks.

> (probably requires cvs emacs).

Yes, it does require Emacs 22.  We already have `nnmail-lazy' in Gnus,
so I can use it (my code is for Gnus):

,----[ nnmail.el ]
| (define-widget 'nnmail-lazy 'default
|   "Base widget for recursive datastructures.
| 
| This is copy of the `lazy' widget in Emacs 22.1 provided for
| compatibility."
`----

A (hopefully) last question on this issue: As mentioned above, I have
six or more variables using this type of custom type.  Instead of
explaining the format of the list in each variable's doc string, it
would be nice to refer (with a link) to the doc string of the widget.
Is it possible?  Example:

(require 'message)
(require 'mml)
(require 'nnmail)

(define-widget 'rs-tool-bar-list-lazy 'nnmail-lazy ;; 'lazy
  "Tool bar list."
  :tag "Tool bar list"
  :type '(repeat (list (function :tag "Menu Command")
                       (string   :tag "Icon file")
                       (choice (const :tag "Default map" nil)
                               ;; We need non-nil attributes if map is t.
                               ;; (const :tag "No menu" t)
                               (sexp :tag "Other map"))
                       (repeat :tag "Properties" :inline t
                               (list :inline t
                                     (symbol :tag "Property")
                                     (sexp :tag "Value"))))))

(defcustom rs-TEST-use-widget-lazy
  '((message-kill-buffer "close")
    (mml-attach-file "attach" mml-mode-map)
    (ignore "separator" nil :help "foo"))
  "A list defined using a widget.

See the widget `rs-tool-bar-list-lazy' for details on the format
of the list.  How to refer to a widget like referring to a
`\\[mml-attach-file]' or a variable like `gnus-version'."
  :type 'rs-tool-bar-list-lazy)


Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]