Please see the attached code that implements isearch in comint mode. It is not posted as a patch because it has one remaining problem: `comint-previous-input' and `comint-next-input' don't signal an error at the beginning/end of the history ring. This is unlike the minibuffer's commands `previous-history-element' and `next-history-element' that signal an error at the beginning/end of the minibuffer history. So Isearch on the minibuffer history can stop and wrap. But in comint mode Isearch with an unmatched string doesn't stop and goes into the loop. Maybe we should change `comint-previous-input' and `comint-next-input' to signal an error at the beginning/end of the history ring?