I fonud a perfect Emacs project ,which is called Emacs IPython Notebook.It can connect to a running IPython notebook server,and work as the IPython notebook do in browser.
Maybe it can provide some ideas for Sage-mode.Without syntax hightlight and line number show in the textarea,it is hard to deal with long codes.