-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Aligning on spaces doesn't work correctly #13
Comments
Until now evil-lion has been designed to not handle tabs. Supporting tabs would be a nice feature but the hard part would be to figure out what's the best behavior from the user's standpoint. This particular example has intermixed tabs (lines 2, 3, 4) and spaces (lines 1, 5, 6). Let me know if you have any suggestions for an algorithm for this case, the best thing which comes to my mind is A) bail out with an error when the given region has both spaces and tabs, and B) turn tabs into spaces (but how many?) and then align |
I see. but suppose it was all spaces. would it be possible? |
I see that it's not working correctly right now. I'll rename the issue and let you know when fixed |
I have a version which works, but it only works when
Do you happen to know if align.el is capable of aligning on spaces so I can re-use its functionality? |
Hum. I use an align function from spacemacs which I think uses align-regexp. Will that test later. |
@edkolev, I've just used a function (from spacemacs) to align the block with success. All I did was As this function uses interesting to note, it leaved 2 spaces between the columns.
#<ip-address> <hostname.domain.org> <hostname>
127.0.0.1 localhost.localdomain localhost
::1 localhost.localdomain localhost
# 127.0.0.1 thinkpad.localdomain thinkpad
192.168.0.4 julicloud.local julicloud
127.0.1.1 thinkpad.localdomain thinkpad
#<ip-address> <hostname.domain.org> <hostname>
127.0.0.1 localhost.localdomain localhost
::1 localhost.localdomain localhost
# 127.0.0.1 thinkpad.localdomain thinkpad
192.168.0.4 julicloud.local julicloud
127.0.1.1 thinkpad.localdomain thinkpad
;; function copied from spacemacs source code
;; modified function from http://emacswiki.org/emacs/AlignCommands
(defun spacemacs/align-repeat (start end regexp &optional justify-right after)
"Repeat alignment with respect to the given regular expression.
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 repeat regexp: ")
(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 "complete-regexp: %S" complete-regexp)
(align-regexp start end complete-regexp group 1 t))) |
I see... so align.el also squeezes (removes) the whitespace. Thanks for looking into this, I'll try to reuse align.el's functionality but also try to avoid the double-space after aligning. |
hi @edkolev,
is it possible to turn this:
into this:
with your package?
The text was updated successfully, but these errors were encountered: