emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] flyspell and code blocks


From: Jambunathan K
Subject: Re: [O] flyspell and code blocks
Date: Sat, 22 Dec 2012 19:34:48 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

"Francesco Pizzolante"
<fpz-djc/address@hidden> writes:

> Hi,
>
> Jambunathan K wrote:
>> Julian Burgos <address@hidden> 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
>
>

-- 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]