The semantic minor mode changed the value of imenu-create-index-function on its startup, but does not restore the original value on its exiting.  Here are the steps to reproduce the issue: 1. Start the emacs and open a python script, now the imenu-create-index-function will be the `python-imenu-create-index'  $ emacs -nw -q ~/a.py    2. Turn-on the semantic by "M-x semantic-mode", then the  imenu-create-index-function will be the `semantic-create-imenu-index' 3. Turn-off the semantic by "M-x semantic-mode",  imenu-create-index-function is still the semantic one. This patch will store the original imenu-create-index-function before changing it, and restore the original value when turn-off the semantic-mode.