vm-summary-faces-alist format not quite right?
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
VM |
Fix Released
|
Low
|
Uday Reddy |
Bug Description
I think this could be a bug, but it could just as well be a misunderstanding on my part. I'm still investigating.
I think there is a mismatch in some of the code in what it iexpects the format of vm-summary-
The doc string for the variable and its custom definition say
"*Alist of virtual folder conditions and corresponding faces.
Order matters. The first matching one will be used as face.
See `vm-virtual-
:type '(repeat (cons (sexp) (face)))
However, the default definition is not a 'straight' alist i.e.
'(((or (header "Priority: urgent")
(header "Importance: high")
(header "X-Priority: 1")
(label "!")
(label "\\flagged")
(header "X-VM-postponed
vm-summary-
((collapsed) vm-summary-
((marked) vm-summary-
((deleted) vm-summary-
((new) vm-summary-
((unread) vm-summary-
((replied) vm-summary-
((or (filed)
(written)) vm-summary-
((or (forwarded)
(redistributed)) vm-summary-
((edited) vm-summary-
((outgoing) vm-summary-
((expanded) vm-summary-
((any) vm-summary-
Note that this is a quoted list, not evaluated. The problem is that it appears the code treats it as a standard alist, with bits like
(setq prop (completing-read "Face name: "
(mapcar (lambda (f)
(list (format "%s" (caar f))))
nil t "deleted")))
The mapcar in the above list will result in
(("or") ("collapsed") ("marked") ("deleted") ("new") ("unread") ("replied")
("or") ("or") ("edited") ("outgoing") ("expanded") ...)
Notice the "or" entries.
Later in the function, the value of prop is used to define a face name i.e.
(face (intern (concat "vm-summary-" prop "-face")))
but 'vm-summary-or-face would not be a valid face name.
The function vm-summary-face-add also has what looks to be incorrect behavior. It has the following
(let ((faces vm-summary-
and later
(while faces
(when (apply 'vm-vs-or msg (list (caar faces)))
with
(setq faces (cdr faces)))))
to iterate through the list until vm-vs-or returns a true value
The potential set of values vm-vs-or could be called with would be
((or (header Priority: urgent) (header Importance: high) (header X-Priority: 1) (label !) (label \flagged) (header X-VM-postponed-
((collapsed))
((marked))
((deleted))
((new))
((unread))
((replied))
((or (filed) (written)))
((or (forwarded) (redistributed)))
((edited))
((outgoing))
((expanded))
((any))
Which doesn't look right. I stripped things down a little to try and see what was going on. I defined
(defun tx-vm-vs-or (m &rest selectors)
(let ((result nil) selector arglist function)
(while selectors
(setq selector (car (car selectors))
function (cdr (assq selector vm-virtual-
(message (format "Selector %s" (or selector "NULL")))
(message (format "Function %s" (or function "NULL")))
(setq arglist (cdr (car selectors)))
(message (format "Arglist %s" (or arglist "NULL")))
(setq selectors (cdr selectors)))))
and called it by (let ((faces vm-summary-
(while faces
(message "|%s|" (list (caar faces)))
(tx-vm-vs-or "message data" (list (caar faces)))
(setq faces (cdr faces))))
and got as a result
|((or (header Priority: urgent) (header Importance: high) (header X-Priority: 1) (label !) (label \flagged) (header X-VM-postponed-
Selector (or (header Priority: urgent) (header Importance: high) (header X-Priority: 1) (label !) (label \flagged) (header X-VM-postponed-
Function NULL
Arglist NULL
|((collapsed))|
Selector (collapsed)
Function NULL
Arglist NULL
|((marked))|
Selector (marked)
Function NULL
Arglist NULL
|((deleted))|
Selector (deleted)
Function NULL
Arglist NULL
|((new))|
Selector (new)
Function NULL
Arglist NULL
|((unread))|
Selector (unread)
Function NULL
Arglist NULL
|((replied))|
Selector (replied)
Function NULL
Arglist NULL
|((or (filed) (written)))|
Selector (or (filed) (written))
Function NULL
Arglist NULL
|((or (forwarded) (redistributed)))|
Selector (or (forwarded) (redistributed))
Function NULL
Arglist NULL
|((edited))|
Selector (edited)
Function NULL
Arglist NULL
|((outgoing))|
Selector (outgoing)
Function NULL
Arglist NULL
|((expanded))|
Selector (expanded)
Function NULL
Arglist NULL
|((any))|
Selector (any)
Function NULL
Arglist NULL
Note that all the function values returned from
function (cdr (assq selector vm-virtual-
appear to return nul for all possible selector values. The problem appears to be that the assq is getting a nested list i.e. ((any)) rather than 'any etc, so always fails to find a match, but I'm guessing here. At any rate, it doesn't seem to be doing what we want/expect.
Note also that there is a redundant bit of code in vm-vs-or i.e.
(setq arglist (cdr (car selectors))
arglist (cdr (car selectors))
result (apply function m arglist)
So, even if the rest of this bug report is totally off the mark, at least it does point out one bit that should be removed!
Note that if desired, I'm happy to look at this, but others who are more familiar may be able to sort it out faster/quicker (assuming it is a real issue that is).
If you want me to look at it, just assign this bug report back to me.
Related branches
Changed in vm: | |
milestone: | 8.1.93a → none |
Changed in vm: | |
milestone: | none → 8.1.94a |
Changed in vm: | |
status: | Fix Committed → Fix Released |
I forgot to mention that I suspect changing the vm-summary- face-alist to be a simple alist would probably fix the problems. It would also make the definition of the custom format easier. This would remove the 'or' from the list of possible faces and would (I think) get rid of the nested values so that the assq would match for the search in vm-virtual- selector- function- alist. However, don't know what other impact such a change may have elsewhere.