Could we fix this by having `insert-file-contents-internal' bind
`coding-system-for-read' to the value of CODESYS if non-nil CODESYS
was provided?
Not sure. If it will only be used for file it was intended for, that
is, for (temporary) local file eventually obtained by file name
handlers, it is fine. But, AFAIK, nothing forbids file name handler
to depend on some additional (configuration?) data, which are taken
from additional files, and coding system defaults used while reading
files may affect that data.
how this is connected to the problem of dropping
CODESYS you described above.
If already set CODESYS was available to recurisively called
`insert-file-contents', the latter would not call
`insert-file-contents-pre-hook' again.