* Specifying plist requirements in defcustom?
@ 2008-10-12 20:46 jrwats
2008-10-12 23:18 ` Lennart Borgman (gmail)
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: jrwats @ 2008-10-12 20:46 UTC (permalink / raw
To: help-gnu-emacs
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")
;;name (symbol - this is arbitrary), branch (string), drive (string),
path (string)
(corext-set-enlistments '((wcdeskcomm "working.client.dekscomm"
"e:" "e:\\wcdeskcomm")
(wcdc
"working.client.dcplatform" "e:" "e:\\wcdc")))
(defun corext-set-enlistments (enlistment-list)
(setq corext-enlistments
(mapcar (lambda (arg-list)
(apply (lambda (new-enlistment pbranch pdrive ppath)
(setplist new-enlistment `(branch ,pbranch
drive ,pdrive path ,ppath))
new-enlistment)
arg-list))
enlistment-list)))
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Specifying plist requirements in defcustom?
2008-10-12 20:46 Specifying plist requirements in defcustom? jrwats
@ 2008-10-12 23:18 ` Lennart Borgman (gmail)
2008-10-13 1:31 ` Drew Adams
[not found] ` <mailman.901.1223861517.25473.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 12+ messages in thread
From: Lennart Borgman (gmail) @ 2008-10-12 23:18 UTC (permalink / raw
To: jrwats; +Cc: help-gnu-emacs
jrwats wrote:
> 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 am not sure, but I believe you have to define a new widget type.
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: Specifying plist requirements in defcustom?
2008-10-12 20:46 Specifying plist requirements in defcustom? jrwats
2008-10-12 23:18 ` Lennart Borgman (gmail)
@ 2008-10-13 1:31 ` Drew Adams
[not found] ` <mailman.901.1223861517.25473.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 12+ messages in thread
From: Drew Adams @ 2008-10-13 1:31 UTC (permalink / raw
To: 'jrwats', help-gnu-emacs
> 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.
^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <mailman.901.1223861517.25473.help-gnu-emacs@gnu.org>]
* Re: Specifying plist requirements in defcustom?
[not found] ` <mailman.901.1223861517.25473.help-gnu-emacs@gnu.org>
@ 2008-10-15 14:32 ` jrwats
2008-10-15 14:50 ` Drew Adams
0 siblings, 1 reply; 12+ messages in thread
From: jrwats @ 2008-10-15 14:32 UTC (permalink / raw
To: help-gnu-emacs
> IIUYC, you want a repetition of symbols, each of which must have non-nil
> properties `branch', `drive', and `path'.
yep
> (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)))))))))
>
From what I could tell, this worked, but I was also to have a user-
friendly customization interface when a user, say, clicked customoize
corext-enlistments. I'd like a prompt for the symbol-name, and the
individual property list values: branch, drive, and path. It seems
that to acheive something like this, I'd need to just make them
alists....
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: Specifying plist requirements in defcustom?
2008-10-15 14:32 ` jrwats
@ 2008-10-15 14:50 ` Drew Adams
2008-10-15 14:54 ` Lennart Borgman (gmail)
0 siblings, 1 reply; 12+ messages in thread
From: Drew Adams @ 2008-10-15 14:50 UTC (permalink / raw
To: 'jrwats', help-gnu-emacs
> > (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)))))))))
> >
> From what I could tell, this worked, but I was also to have a user-
> friendly customization interface when a user, say, clicked customoize
> corext-enlistments. I'd like a prompt for the symbol-name, and the
> individual property list values: branch, drive, and path. It seems
> that to acheive something like this, I'd need to just make them
> alists....
You'll have to extend Customize to get that, AFAIK. Or write your own command to
customize this particular option. Customize doesn't really guide you with
prompts and such. Customize could use a little more guidance, especially for
complex structures such as this one.
There are a lot of ways in which Customize could be improved, but no one seems
to want to work on it. Many Emacs developers have, I think, written it off as
being either (1) superfluous (~real Emacs users don't use Customize~, meaning
that they don't use it) or (2) too difficult/bothersome (the Customize code is
hard to follow). No flames please - that's just one person's impression.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Specifying plist requirements in defcustom?
2008-10-15 14:50 ` Drew Adams
@ 2008-10-15 14:54 ` Lennart Borgman (gmail)
2008-10-15 15:41 ` Drew Adams
[not found] ` <mailman.1123.1224085332.25473.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 12+ messages in thread
From: Lennart Borgman (gmail) @ 2008-10-15 14:54 UTC (permalink / raw
To: Drew Adams; +Cc: 'jrwats', help-gnu-emacs
Drew Adams wrote:
>>> (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)))))))))
>>>
>> From what I could tell, this worked, but I was also to have a user-
>> friendly customization interface when a user, say, clicked customoize
>> corext-enlistments. I'd like a prompt for the symbol-name, and the
>> individual property list values: branch, drive, and path. It seems
>> that to acheive something like this, I'd need to just make them
>> alists....
>
> You'll have to extend Customize to get that, AFAIK. Or write your own command to
> customize this particular option. Customize doesn't really guide you with
> prompts and such. Customize could use a little more guidance, especially for
> complex structures such as this one.
I do not think that you have to extend Customize. Writing a new widget
type should be enough.
> There are a lot of ways in which Customize could be improved, but no one seems
> to want to work on it. Many Emacs developers have, I think, written it off as
> being either (1) superfluous (~real Emacs users don't use Customize~, meaning
> that they don't use it) or (2) too difficult/bothersome (the Customize code is
> hard to follow). No flames please - that's just one person's impression.
>
>
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: Specifying plist requirements in defcustom?
2008-10-15 14:54 ` Lennart Borgman (gmail)
@ 2008-10-15 15:41 ` Drew Adams
[not found] ` <mailman.1123.1224085332.25473.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 12+ messages in thread
From: Drew Adams @ 2008-10-15 15:41 UTC (permalink / raw
To: 'Lennart Borgman (gmail)'; +Cc: 'jrwats', help-gnu-emacs
> >> From what I could tell, this worked, but I was also to have a user-
> >> friendly customization interface when a user, say, clicked
> >> customoize corext-enlistments. I'd like a prompt for the symbol-name,
> >> and the individual property list values: branch, drive, and path.
> >> It seems that to acheive something like this, I'd need to just make them
> >> alists....
> >
> > You'll have to extend Customize to get that, AFAIK. Or
> > write your own command to customize this particular option.
> > Customize doesn't really guide you with prompts and such.
> > Customize could use a little more guidance, especially for
> > complex structures such as this one.
>
> I do not think that you have to extend Customize. Writing a new widget
> type should be enough.
I call that extending Customize. Customize out of the box won't provide that
behavior.
~All you have to do is write...~ means that it's not there already. Playing with
widgets is, in my book, extending Customize. And it's not necessarily a
clear-cut exercise.
^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <mailman.1123.1224085332.25473.help-gnu-emacs@gnu.org>]
* Re: Specifying plist requirements in defcustom?
[not found] ` <mailman.1123.1224085332.25473.help-gnu-emacs@gnu.org>
@ 2008-10-15 16:27 ` jrwats
2008-10-15 16:33 ` jrwats
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: jrwats @ 2008-10-15 16:27 UTC (permalink / raw
To: help-gnu-emacs
> ~All you have to do is write...~ means that it's not there already. Playing with
> widgets is, in my book, extending Customize. And it's not necessarily a
> clear-cut exercise.
I ostensibly agree. Despite all the searching I did, I could not find
a solid example of creating a new widget. And they all seemed
graphics related... The default customization prompt that occurs with
something like this:
(defcustom rep-list '(("wcdc" "working.client.deskcomm" "e:" "e:
\wcdeskomm"))
"test this!"
:type '(repeat (list
(string :tag "name")
(string :tag "branch")
(string :tag "drive")
(string :tag "path"))))
is EXACTLY what I want - I just want a plist with keys: name, branch,
drive, and path rather than a list, so I don't have to write silly
things like:
(defun path (cadddr list))
...I might just give in to silly application code for the sake of user-
friendly client experience.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Specifying plist requirements in defcustom?
2008-10-15 16:27 ` jrwats
@ 2008-10-15 16:33 ` jrwats
2008-10-15 16:48 ` jrwats
2008-10-15 16:58 ` Drew Adams
[not found] ` <mailman.1126.1224089933.25473.help-gnu-emacs@gnu.org>
2 siblings, 1 reply; 12+ messages in thread
From: jrwats @ 2008-10-15 16:33 UTC (permalink / raw
To: help-gnu-emacs
;; some of the worst lisp i've written...
;;(defun path (cadddr list))
(defun path (a-list) (cadddr a-list))
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Specifying plist requirements in defcustom?
2008-10-15 16:33 ` jrwats
@ 2008-10-15 16:48 ` jrwats
0 siblings, 0 replies; 12+ messages in thread
From: jrwats @ 2008-10-15 16:48 UTC (permalink / raw
To: help-gnu-emacs
On Oct 15, 9:33 am, jrwats <jrw...@gmail.com> wrote:
> ;; some of the worst lisp i've written...
> ;;(defun path (cadddr list))
> (defun path (a-list) (cadddr a-list))
I shoud also mention I'm willing to get rid of the symbol, and just
have a plist (where what was the symbol is now a string accessed by
'name key)
So corext-enlistments would look like
((name "enlistment name" branch "a.branch.we.are.in" drive "drive:"
path "drive:/path/to/files")
(name "another name" branch "another.branch" drive "b:" path "b:/
another/path"))
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: Specifying plist requirements in defcustom?
2008-10-15 16:27 ` jrwats
2008-10-15 16:33 ` jrwats
@ 2008-10-15 16:58 ` Drew Adams
[not found] ` <mailman.1126.1224089933.25473.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 12+ messages in thread
From: Drew Adams @ 2008-10-15 16:58 UTC (permalink / raw
To: 'jrwats', help-gnu-emacs
> > ~All you have to do is write...~ means that it's not there
> > already. Playing with widgets is, in my book, extending
> > Customize. And it's not necessarily a clear-cut exercise.
>
> I ostensibly agree. Despite all the searching I did, I could not find
> a solid example of creating a new widget. And they all seemed
> graphics related... The default customization prompt that occurs with
> something like this:
>
> (defcustom rep-list '(("wcdc" "working.client.deskcomm" "e:" "e:
> \wcdeskomm"))
> "test this!"
> :type '(repeat (list
> (string :tag "name")
> (string :tag "branch")
> (string :tag "drive")
> (string :tag "path"))))
>
> is EXACTLY what I want - I just want a plist with keys: name, branch,
> drive, and path rather than a list, so I don't have to write silly
> things like: (defun path (cadddr list))
>
> ...I might just give in to silly application code for the
> sake of user-friendly client experience.
I'm no expert on Customize. The code in wid-edit+.el might help
(http://www.emacswiki.org/emacs/wid-edit%2b.el), or it might not - dunno.
If not, I believe that Lennart has some widget code that might help. And of
course you can look in the Lisp sources that come with Emacs. And there's the
widget Info manual, FWIW.
If you do write some useful widget/Customize code, please share it (e.g.
gnu-emacs-sources@gnu.org or Emacs Wiki).
^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <mailman.1126.1224089933.25473.help-gnu-emacs@gnu.org>]
* Re: Specifying plist requirements in defcustom?
[not found] ` <mailman.1126.1224089933.25473.help-gnu-emacs@gnu.org>
@ 2008-10-15 17:43 ` jrwats
0 siblings, 0 replies; 12+ messages in thread
From: jrwats @ 2008-10-15 17:43 UTC (permalink / raw
To: help-gnu-emacs
> I'm no expert on Customize. The code in wid-edit+.el might help
> (http://www.emacswiki.org/emacs/wid-edit%2b.el), or it might not - dunno.
>
> If not, I believe that Lennart has some widget code that might help. And of
> course you can look in the Lisp sources that come with Emacs. And there's the
> widget Info manual, FWIW.
>
> If you do write some useful widget/Customize code, please share it (e.g.
> gnu-emacs-sour...@gnu.org or Emacs Wiki).- Hide quoted text -
>
Thanks for all the help guys. I'll definitely look into it, but will
likely cave and use the list type :)
What would be magically cool is if a repeat type could have the
options tag in it (which specifies keys in alists/plists).
(defcustom plist-opts3 nil
"uh"
:type '(repeat plist
:options '((name string) (branch string) (drive
string) (path string))))
Alas the options tag only works w/ defcustom...
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2008-10-15 17:43 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-12 20:46 Specifying plist requirements in defcustom? jrwats
2008-10-12 23:18 ` Lennart Borgman (gmail)
2008-10-13 1:31 ` Drew Adams
[not found] ` <mailman.901.1223861517.25473.help-gnu-emacs@gnu.org>
2008-10-15 14:32 ` jrwats
2008-10-15 14:50 ` Drew Adams
2008-10-15 14:54 ` Lennart Borgman (gmail)
2008-10-15 15:41 ` Drew Adams
[not found] ` <mailman.1123.1224085332.25473.help-gnu-emacs@gnu.org>
2008-10-15 16:27 ` jrwats
2008-10-15 16:33 ` jrwats
2008-10-15 16:48 ` jrwats
2008-10-15 16:58 ` Drew Adams
[not found] ` <mailman.1126.1224089933.25473.help-gnu-emacs@gnu.org>
2008-10-15 17:43 ` jrwats
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.