How do I navigate efficiently through emacs buffer modifying lines
<p>I am an elisp (but not programming) beginner and have some questions about the best practice to implement a function. I have written an elisp function that reformats assembler source code according to certain rules; this function currently works for a single line. It basically uses navigation within the line, looking-at and replace-match calls on subexpressions to achieve the goal.</p>

<p>Now I'd like to apply it to a marked region, processing the region line by line. The behaviour will be similar to the indent-region function.</p>

<p>What is the recommended (and efficient) way to implement this? I consider using <code>(line-number-at-pos ...)</code> applied to <code>(region-beginning)</code> and <code>(region-end)</code> to count line numbers and then move from top to bottom, working through the buffer line by line, modifying these.</p>

<p>Also, what would I need to preserve through this operation? I though about (save-match-data ...) and am not sure how to handle mark and point. I guess they will be useless because the text extent changed.</p>