I want to write a function to indent SQL embedded in a markdown file.
It seems to make sense to use the region for this.
However, the looping form I am using is:
(defun rr/sql-indent-region (beginning end)
(interactive "r")
(while (< (point) end)
...
(forward-word 1)
The ...
is adding \n
characters after SELECT, FROM, GROUP BY etc, so that the block I started with no longer ends at END.
As I write this, I guess one option would be to copy the region to a temporary buffer, and use (< (point) (point-max))
. Is that the best way to proceed?