If its too tight, it will break. If its not tight enough, it will fall out easily
.
Evidently, the way I have the cable now *is* correct, as it works nicely. Last time I changed the cable I put it in [kinda] as shown in the earlier photo which is why it didn't work right, and it was so prone to coming off that I ended up tightening it up to the extent that some of the strands broke. Still, it lasted me well for two years until I got fed up of it recently.
I'm not sure how I didn't realise this at the time. It must have been done correctly before I changed it. But in the installation manual for the derailer, the diagrams make it look like my wrong way was actually the right way.