I have a bunch of add-to-list calls that I'd like to shorten in my .emacs
file. They all look like this:
(add-to-list 'align-rules-list
'(haskell-comment
(regexp . "\\(\\s-+\\)--\\s-+")
(mode . '(haskell-mode))
(repeat . nil)))
I don't know lisp but I tried to define a local function that I can call repeatedly. I'm not getting very far:
(let ((f (lambda (name re)
(add-to-list
'align-rules-list
(list name
('regexp . re)
'(mode . (haskell-mode))
'(repeat . nil))))))
(funcall f 'haskell-comment "\\(\\s-+\\)--\\s-+"))
Can someone point out my problem with the code above?
After much googling, I've arrived at something that seems to work:
(let ((f (lambda (name re)
(add-to-list
'align-rules-list
(list name
(cons 'regexp re)
'(mode . '(haskell-mode))
'(repeat . nil))))))
(funcall f 'haskell-comment "\\(\\s-+\\)--\\s-+")
But it seems messy. Quotes everywhere, cons
, list
. Is there a cleaner way?