Generate a file with this:
(echo '#!/bin/bash'
echo 'myfunc() {'
echo "cat <<'z'"
seq 135
echo zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
echo z
echo '}') >out
Open it in Emacs. When pressing C-M-f
I get the error:
Scan error: "Containing expression ends prematurely", 515, 515
Then I press M->
to get to end of file, C-x C-x
to move back to where I came from, and now I can press C-M-f
and move to the next sexp.
It is as if emacs does not really index the full file before I have been to the end of the file.
How can I fix this?