tags:

views:

59

answers:

2

I know little elisp, and I'm trying to figure out how to call a function that takes a property list as one of its arguments. The particular function is rudel-join-session from the Rudel package; I'm trying to set it up so Rudel will automatically join a session when Emacs starts. I'm not sure how property lists work, so I tried doing this:

(rudel-join-session (list :backend 'obby
                          :host "foo"
                          :port 6522
                          :username "username"
                          :color "blue"
                          :global-password ""
                          :user-password ""
                          ))

I'm getting the error:

Wrong type argument: listp, obby

I assume it's from using property lists wrong. Any idea what the correct syntax is?

+3  A: 

No, that's a correct property list. I notice this snippet in rudel.el:

(let* ((backend    (cdr (plist-get info :backend)))

That means that the :backend parameter is expected to be a cons cell. All of the documentation I can find presumes that rudel-join-session is being called interactively, in which case the backend parameter is being generated programmatically, and I can't figure out from a casual perusal of the code just what it's supposed to be. But the first thing I'd try is this:

(rudel-join-session (list :backend '(dummy . obby) ...))

That way the expression (cdr (plist-get info :backend)) will evaluate to the symbol obby, which may be what's expected by the rest of the code.

Sean
I got an even more cryptic error message with `'(dummy . obby)`, but I discovered the magical `rudel-backend-get` function: `(rudel-backend-get 'protocol 'obby)` works. Anyway, this answered my main question (how in the world do you use property lists), so accepted. Thanks!
Michael Mrozek
A: 

In addition, you may want to look at the content of rudel-session-initiation.el.

That file contains the variable rudel-configured-sessions the documentation string of which explains "session information property lists" in more detail.

In the same file, there is rudel-session-initiation-adjust-info which resolves backend references in plists by replacing them with the actual backend objects. What this function does is replacing a backend name like 'obby or "obby" with a cons-cell of the form ('obby . #<backend object>). Internally, this uses rudel-backend-get as you suspected.