8

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

1 Answer 1

10

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)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.