I am trying to use the following elisp function to align text using =
:
(defun align-= ()
"Align lines by `=`"
(interactive)
(align-regexp (region-beginning) (region-end) "="))
And I am trying to align the following text:
offer = stub('offer')
user = stub('user')
But emacs returns the following error:
align-region: Marker does not point anywhere
What am I doing wrong?
Thanks
I got it working by doing this:
(defun align-= (p1 p2)
"Align lines by ="
(interactive "r")
(align-regexp p1 p2 "\\(\\s-*\\)=" 1 1 nil)
)
As far as I understand it align-regexp
is not receiving what you think it is receiving.
You can test it manually by invoking M-x align-regexp <RET> = <RET>
and then hitting C-x ESC ESC
(by default repeat-complex-command
is bound to C-x ESC ESC
, you can also use M-n / M-p to move in the history) and you'll see exactly what is passed to align-regexp
. I then copied the line into the function. (I also used interactive "r" because it's convenient)
It's working for me on Emacs 24.
Related but not 100% identical to:
Inconsistent M-x align-regexp vs. C-u M-x align-regexp behaviour
And also:
Marker does not point anywhere from align-regexp (Emacs)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With