emacs-devel
[Top][All Lists]
Advanced

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

Re: defcustom - help


From: Katsumi Yamaoka
Subject: Re: defcustom - help
Date: Thu, 04 Aug 2011 12:39:17 +0900
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (i686-pc-cygwin)

Jambunathan K wrote:
> There are two defcustoms - one for configuring a list of items and one
> for choosing the preferred among those. Read ahead ...
[...]
> Can someone help me with achieving the desired behaviour in step 4.

You can use :convert-widget to generate a custom type dynamically.

(defun kjn--widget-type-convert-widget (widget)
  "Convert the car of `:args' as a widget type in WIDGET."
  (apply 'widget-convert (widget-type widget)
         (eval (car (widget-get widget :args)))))

(defcustom kjn--preferred-list-item "a"
  "Preferred item in the list."
  :group 'kjn
  :type `(choice :convert-widget kjn--widget-type-convert-widget
                 `((const :tag "None" nil)
                   ,@(mapcar (lambda (c)
                               `(const :tag ,c ,c))
                             kjn--list-items))))

I'm not a custom expert so please don't ask me how/why it works. ;-)



reply via email to

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