# Redefining the \printindex command and changing it to a desired form

In book class, I want to redefine the \printindex command and change it to something like the following:

‎\addcontentsline{toc}{chapter}{‎Index}‎‎‎‎
‎\fancypagestyle{plain}{%‎
‎\fancyhf{}‎
‎\renewcommand{\footrulewidth}{0pt}‎
}
‎\printindex‎


How can I do this?
My tex file is as follow:

\documentclass{‎book‎}‎‎
‎\usepackage{fancyhdr} ‎‎
‎\usepackage{makeidx}‎
‎\makeindex‎
‎‎\begin{document}‎‎
‎\tableofcontents‎
‎\chapter{One}‎‎
‎Hi!‎
\index{‎abc‎}
\index{‎def‎}‎‎
‎\fancypagestyle{plain}{%‎
‎\fancyhf{}‎
‎\renewcommand{\footrulewidth}{0pt}‎
}
‎\printindex‎
‎\end{document}

-
the page style plain is the default for the index. Why do you want to redefine it? –  Herbert Feb 10 '11 at 16:23
@Herbert: I wanted to delete the page number on the first page. –  Vahid Damanafshan Feb 10 '11 at 19:48

You can save a macro away using \let\origmacro\macro, where \origmacro is a name you can pick. Then your redefine the macro and call its original version internally, mostly at the very end:

\let\origprintindex\printindex‎
\renewcommand*{\printindex}{%
‎\fancypagestyle{plain}{%‎
‎  \fancyhf{}‎%

@Vahid: It should work for all user macros. But you must be careful not to redefine a robust macro in a fragile way. I'm talking about macros which are written into to ToC and .aux files, e.g. the ones used inside section titles. Also problems arise when two people/packages redefine the same macro and use the same name for '\origmacro'. –  Martin Scharrer Feb 10 '11 at 16:27