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

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

RE: Specifying plist requirements in defcustom?


From: Drew Adams
Subject: RE: Specifying plist requirements in defcustom?
Date: Sun, 12 Oct 2008 18:31:12 -0700

> I want to have a customization type that is a list of symbols, and I
> want those symbols to have certain plist requirements fulfilled.  Is
> there a way to specify this kind of requirement like
> (defcustom :type <complicated requirement goes here>)
> 
> I know you can have a plist type, but the true type of the customized
> variable is '(repeat (symbol)).  And I want a certain plist for these
> symbols.  For what it's worth, my plist is (branch <a string> drive <a
> string> path <a string>).  As an example, here's how I set the
> variable:
> 
> ;; I'd like this to be defcustom
> (defvar corext-enlistments nil
>   "list of enlistments where each enlistment has a property list of:
> branch, drive, and directory")

IIUYC, you want a repetition of symbols, each of which must have non-nil
properties `branch', `drive', and `path'. If so, something like this should do
the job (untested):

(defcustom corext-enlistments nil
  "..."
  :type
  '(repeat
    (restricted-sexp
     :match-alternatives
     ((lambda (x) (and (symbolp x)
                       (let ((pl (symbol-plist x)))
                         (and (plist-get pl 'branch)
                              (plist-get pl 'drive)
                              (plist-get pl 'path)))))))))

If nil property values are OK, then use plist-member instead of plist-get.





reply via email to

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