Upon @egreg's request, I try to be more verbose on this. I assume you are using GNU Emacs; if so, your OS shouldn't make a difference.
Installation
I suggest you install the latest version of AUCTeX from ELPA by doing M-x list-packages RET, move the cursor on auctex (version 11.88.4 as writing), hit i followed by x and you have the latest version installed (probably under ~/.emacs.d/elpa/)
Activation
If installed from ELPA, you must not, I repeat, must not have this in your init file:
(load "auctex.el" nil t t)
AUCTeX is installed and should start as soon as you load a file with .tex extension.
Basic customization
AUCTeX's strength is in supporting basic LaTeX and contributed packages. Currently, more than 180 style files (jargon for "name-of-supported-LaTeX-package.el") are available. AUCTeX can parse your input file and load the right style if you put this in your init file:
(setq TeX-parse-self t)
Otherwise, you have to hit C-c C-n afterwards. Keep that in your init file.
AUCTeX manual suggests also:
(setq TeX-auto-save t)
(setq-default TeX-master nil)
It's up to you; I have only the second line in my .emacs.
Usage
Now, you can hit C-c C-e and AUCTeX offers lstlisting in completion and asks you for key-value options. Further, note that Emacs doesn't indent the content since spaces are significant:
\begin{lstlisting}
a$ = b$ + c$;
a_{d}=a_{c}
\end{lstlisting}
The fontification (aka syntax highlighting) should work as well.
(setq LaTeX-verbatim-environments-local '("Verbatim" "lstlisting"))in my.emacsfile, so bothVerbatimandlstlistingare considered likeverbatim. – egreg Apr 28 '15 at 15:09lstlistingbut withemacsand its coloring system. – Ignasi Apr 28 '15 at 15:09