Allow align-repeat to work with empty regexps

This commit is contained in:
Eivind Fonn 2016-08-23 07:12:19 +02:00
parent b47d0661c2
commit c1a8427488
1 changed files with 8 additions and 4 deletions

View File

@ -762,10 +762,14 @@ If JUSTIFY-RIGHT is non nil justify to the right instead of the
left. If AFTER is non-nil, add whitespace to the left instead of
the right."
(interactive "r\nsAlign regexp: ")
(let ((complete-regexp (if after
(concat regexp "\\([ \t]*\\)")
(concat "\\([ \t]*\\)" regexp)))
(group (if justify-right -1 1)))
(let* ((ws-regexp (if (string-empty-p regexp)
"\\(\\s-+\\)"
"\\(\\s-*\\)"))
(complete-regexp (if after
(concat regexp ws-regexp)
(concat ws-regexp regexp)))
(group (if justify-right -1 1)))
(message "%S" complete-regexp)
(align-regexp start end complete-regexp group 1 t)))
;; Modified answer from http://emacs.stackexchange.com/questions/47/align-vertical-columns-of-numbers-on-the-decimal-point