Using examples from octave mode to explain this, but it would be useful in other places as well.
When going through the command history it would be nice to only display entries that match what's already been typed. For example,
if I've typed out
x= pressing M-p would go to the last commands beginning with that, eg
x=y+4, even if several unrelated commands have been entered.
What's the simplest way to achieve this in emacs?