"Francesco Pizzolante" <fpz-djc/ipccudyqhejpep6iedvlejwur...@public.gmane.org> writes:
> Hi, > > Jambunathan K wrote: >> Julian Burgos <julian-ymfcbn36...@public.gmane.org> writes: >> >>> It is possible to make flyspell to ignore (i.e. do not spell check) >>> the text within code blocks (I mean blocks of texts separated by >>> #+begin_src and #+end src)? I did my homework but could not find a >>> good answer. >> >> See >> http://lists.gnu.org/archive/html/help-gnu-emacs/2012-02/msg00162.html >> >> which links to the following bug report >> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10804 > > I'm not sure whether this issue has been fixed or not. > > But, while I was testing Jambunathan's following code: > > ╭──── > │ (defadvice org-mode-flyspell-verify > │ (after my-org-mode-flyspell-verify activate) > │ "Don't spell check src blocks." > │ (setq ad-return-value > │ (and ad-return-value > │ (not (org-in-src-block-p)) > │ (not (member 'org-block-begin-line (text-properties-at > (point)))) > │ (not (member 'org-block-end-line (text-properties-at > (point))))))) > ╰──── > > I found that it only works when setting the org-src-fontify-natively variable: > > ╭──── > │ (setq org-src-fontify-natively t) > ╰──── > > I hope this helps. The following replacement wouldn't depend on fontification. (defadvice org-mode-flyspell-verify (after my-org-mode-flyspell-verify activate) "Don't spell check src blocks." (setq ad-return-value (and ad-return-value (not (eq (org-element-type (org-element-at-point)) 'src-block))))) > > an even better solution would be to use flyspell-prog-mode (to spellcheck > comments and strings in source code) within the Org source blocks. > > Any idea how to achieve this? > > Thanks, > Francesco > > --