How are you given the set of rule names and corresponding regexps? Assuming you have them in a list, just iterate over the list. <!-- language: lang-el --> (defvar rule+regexp-alist '((haskell-comment . "\\(\\s-+\\)--\\s-+") (foo . "re1") (bar . "re2")) "(RULE . REGEXP) pairs, where RULE is a symbol and REGEXP is a string.") (dolist (rl+re rule+regexp-alist) (add-to-list 'align-rules-list `(,(car rl+re) (regexp . ,(cdr rl+re)) (mode 'haskell-mode) (repeat)))) (But are you sure it is `'haskell-mode` you want in the result, instead of just `haskell-mode`? IOW, you want `(mode 'haskell-mode)` in the result, not just `(mode haskell-mode)`?) (Yes, I ignored your request to "convert to a function", as I don't see the point of that, from your description. Sounds like you just want to make several similar calls to `add-to-list`. If so, then just do that - factor out the "similar" parts and iterate over the list of dissimilar parts.)