The following works:

(rx-let ((headers (? (or "From" "To" "Cc") ":")))
  (list "mail.amazon"  (rx bol headers anything "amazon" anything)
     ;; ("mail.amazon" "^\\(?:\\(?:Cc\\|From\\|To\\):\\)?[^z-a]amazon[^z-a]")

But the following fails:

(rx-let ((headers (bol (or "From" "To" "Cc") ":")))
  (list "mail.amazon"  (rx headers anything "amazon" anything)
     ;; rx--translate-form: Unknown rx form ‘bol’

Why is rx-let having issues with rx forms like bol? I've also tried its alias, line-start, but the result was the same.

  • 2
    Each rx-let binds a single rx form to a name. (? ...) is a single form (? takes any number of rx forms as arguments), but (bol ...) is not a valid rx form (bol is an rx form of its own, without taking an argument list). Try (: bol ...), (seq bol ...), or similar instead.
    – Basil
    Jan 9 at 22:19
  • It works! Make an answer out of it and I can accept it Jan 10 at 15:37

1 Answer 1


The docstring of rx-let describes the expected format of each binding (^^ emphasis mine):

rx-let is an autoloaded Lisp macro in ‘rx.el’.

(rx-let BINDINGS BODY...)

Evaluate BODY with local BINDINGS for ‘rx’.
BINDINGS is an unevaluated list of bindings each on the form
(NAME [(ARGS...)] RX).

Note that it binds a single RX form to each NAME.

(rx-let ((headers (? (or "From" "To" "Cc") ":"))) ...)

This first example works because (? ...) is a valid rx form (which in turn takes other rx forms as arguments).

(rx-let ((headers (bol (or "From" "To" "Cc") ":"))) ...)

But the error message for this example is expected, since (bol ...) is not a valid rx form: bol is an atomic rx form that does not take an argument list.

The forms bol, (or ...), and ":" can be sequenced/wrapped as a single rx form using the seq form (alias :):

(rx-let ((headers (seq bol (or "From" "To" "Cc") ":"))) ...)

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.