In cl-case clauses (though naturally not the initial keyform), keys are apparently quoted:

(let ((mark ?.))
  (case mark
    (mark 'mark)
    (?. ?.))) ; 46 (?.)

(let ((mark ?.))
  (case 'mark
    (mark 'mark)
    (?. ?.))) ; mark

My reading of neither the cl-lib manual nor CLHS entry for case describe this behavior. Is this the intended behavior of cl-case? If so, is this behavior documented? Is there a succinct way to match the keyform against a variable in a cl-case (as opposed to using a cond)?

  • If you don't want to use cond, why not use pcase?
    – Basil
    Commented Jan 7, 2021 at 15:42
  • emacs.stackexchange.com/tags/elisp/info
    – Drew
    Commented Jan 7, 2021 at 16:41
  • @Drew: this question is about the semantics of an elisp construct. Wouldn't that be within the scope of that tag?
    – outis
    Commented Jan 8, 2021 at 0:23
  • The more specific tag conditionals covers that. Just like the specific tag elisp-macros is appropriate for a question about Elisp macros.
    – Drew
    Commented Jan 8, 2021 at 4:22
  • @Drew: that's clearer, thanks.
    – outis
    Commented Jan 8, 2021 at 4:26

1 Answer 1


That behavior is actually described there, albeit in terse form:

  • "Macro: cl-case keyform clause...": cl-case is a macro, macros do not evaluate their arguments.
  • "This macro evaluates KEYFORM [...]": One of the arguments is evaluated, the rest aren't.
  • Therefore the key forms aren't evaluated.

If you find yourself in that situation, just use cond and the appropriate equality predicate. To shorten matching for several keys, use memq, memql, member or cl-find with the :test keyword. In fact, I almost always use cond and only rarely resort to pattern matching constructs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.