Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spell check of comments in C++ code with emacs

Is there a way to make a spell check of comments in C++ codes using emacs?

like image 239
Thomas W. Avatar asked Apr 16 '12 07:04

Thomas W.


4 Answers

The lisp-snippet below in .emacs got it to work for me on Ubuntu Linux

(add-hook 'c-mode-common-hook 'flyspell-prog-mode)

There exist alternative setups. But I think you can find them by googling flyspell-prog-mode.

like image 93
mirk Avatar answered Oct 09 '22 11:10

mirk


To spell check comments already in the file:

M-x ispell-comments-and-strings

To spell check comments as you type:

M-x flyspell-prog-mode

and the .emacs hooks kindahero suggested.

like image 23
sligocki Avatar answered Oct 09 '22 12:10

sligocki


as mirk said flyspell-prog-mode is the obvious way.

To share my config,

;;; for prog modes turn on flyspell-prog-mode (checks spell only in comments)
(dolist (hook '(lisp-mode-hook
                emacs-lisp-mode-hook
                ruby-mode-hook
                yaml-mode
                python-mode-hook
                shell-mode-hook
                php-mode-hook
                css-mode-hook
                nxml-mode-hook
                crontab-mode-hook
                perl-mode-hook
                javascript-mode-hook
                LaTeX-mode-hook))
  (add-hook hook 'flyspell-prog-mode))

Remove those modes you don't use/want.

like image 22
kindahero Avatar answered Oct 09 '22 11:10

kindahero


Edit -> Spelling -> Ispell -> Spell-Check Comments

like image 45
Matthias Avatar answered Oct 09 '22 13:10

Matthias