I am having an issue with syntax highlighting in emacs when writing c++ using the const
keyword. A MWE is the following
#include <iostream>
class MyClass{
pulbic:
void helloWorld();
};
void MyClass::helloWorld(){
std::cout << "Hello, World!\n";
}
int main(){
MyClass const * myClass0; // "MyClass" is not highlighted correctly
MyClass * const myClass1; // "myclass1" is not highlighted correctly
MyClass const * const myClass2; // both not highlighted correctly
return 0;
}
Referencing the above code, the issue is the highlighting for the Class type and for the name of the object instantiated. It is not highlighting them as another specific keyword type, it is just leaving them the neutral text color. (note that the highlighting in the actual code above is NOT what I see in emacs...)
I tried commenting out my `.emacs' file to see if any code in there was messing it up, but that didn't change anything.
My version of emacs is 23.3.1 and I'm running it in Ubuntu 12.04. My `.emacs' file is
(setq backup-by-copying t
backup-directory-alist '(("." . "~/.emacsBkups"))
delete-old-versions t
kept-new-versions 5
kept-old-versions 2
version-control t)
(auto-fill-mode 1)
(setq-default fill-column 80)
(setq LaTeX-item-indent 0)
(setq LaTeX-break-at-separators '(\\\( \\\) \\\[ \\\] \\\{ \\\} "$"))
(setq LaTeX-command-style '(("" "%(PDF)%(latex) -file-line-error %S%(PDFout)")))
(add-to-list 'auto-mode-alist '("\\.Rnw\\'" . Rnw-mode))
(add-to-list 'auto-mode-alist '("\\.Snw\\'" . Rnw-mode))
(setq reftex-file-extensions
'(("Snw" "Rnw" "nw" "tex" ".tex" ".ltx") ("bib" ".bib")))
(setq TeX-file-extensions
'("Snw" "Rnw" "nw" "tex" "sty" "cls" "ltx" "texi" "texinfo"))
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq TeX-PDF-mode t)
(require 'ess-site)
(ess-toggle-underscore nil)
(require 'whitespace)
(setq whitespace-style '(lines face))
(setq whitespace-line-column 80)
(add-hook 'c-mode-hook 'whitespace-mode)
(add-hook 'c++-mode-hook 'whitespace-mode)
(add-hook 'python-mode-hook 'whitespace-mode)
(c-set-offset (quote cpp-macro) 0 nil)
(c-set-offset 'access-label '/)
;; SyncTeX
(setq TeX-source-correlate-mode t)
(setq TeX-source-correlate-method 'synctex)
;;(setq TeX-source-correlate-start-server t)
(load "server")
(unless (server-running-p) (server-start))
'(LaTeX-command "latex -synctex=1")
;; evince viewer
;;(setq TeX-view-program-list '(("Evince" "evince --page-index=%(outpage) %o")))
;;(setq TeX-view-program-selection '((output-pdf "Evince")))
;; okular viewer
(setq TeX-view-program-list '(("Okular" "okular --unique %o#src:%n%b")))
(setq TeX-view-program-selection '((output-pdf "Okular")))
;; okular viewer
;;(setq TeX-view-program-list '(("Okular" "okular --unique %u")))
;;(add-hook 'LaTeX-mode-hook '(lambda ()
;; (add-to-list 'TeX-expand-list
;; '("%u" Okular-make-url))))
;;(defun Okular-make-url () (concat
;; "file://"
;; (expand-file-name (funcall file (TeX-output-extension) t)
;; (file-name-directory (TeX-master-file)))
;; "#src:"
;;'(100)
;; (expand-file-name (TeX-master-directory))
;; "./"
;; (TeX-current-file-name-master-relative)))
;;(setq TeX-view-program-selection '((output-pdf "Okular")))