Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> 1. I have a lisp code which saves file buffer and does some
>> manipulation on the file in shell. subsequently it is reverted.
>> However I have tried save-excursion before saving file which did not
>> restore the file position on reverting.
>
> save-excursion uses markers to remember the position. But markers only
> keep track of positions by keeping track of insertions/deletions and
> adjusting the position accordingly. When the changes happen outside
> Emacs, this doesn't work too well, because Emacs sees your revert-buffer
> as just one big delete&insert.
insert-file-contents tries to keep markers if possible, but that only
works if the marker points into the unchanged head or tail of the
replaced contents.
Andreas.