In general you should avoid using advice, but since align.el
directly reads the value of indent-tabs-mode
, it's probably the best way:
(defadvice align-regexp (around align-regexp-with-spaces activate)
(let ((indent-tabs-mode nil))
ad-do-it))
Here was my original version:
(defadvice align-regexp (around align-regexp-with-spaces activate)
(let ((old-indent-tabs-mode indent-tabs-mode))
(setq indent-tabs-mode nil)
ad-do-it
(setq indent-tabs-mode old-indent-tabs-mode)))
As @Phils pointed out, this is unnecessarily complex and less fool proof, so use the code at the top of the post.