emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jambunathan K <kjambunathan@gmail.com>
To: Org mode <emacs-orgmode@gnu.org>
Subject: Re: flyspell and code blocks
Date: Sat, 22 Dec 2012 19:34:48 +0530	[thread overview]
Message-ID: <87k3sa41vf.fsf@gmail.com> (raw)
In-Reply-To: <87licr5scz.fsf@somewhere.org> (Francesco Pizzolante's message of "Fri, 21 Dec 2012 16:37:16 +0100")

"Francesco Pizzolante"
<fpz-djc/iPCCuDYQheJpep6IedvLeJWuRmrY@public.gmane.org> writes:

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

-- 

      reply	other threads:[~2012-12-22 14:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-23 13:57 flyspell and code blocks Julian Burgos
2012-04-23 14:13 ` Jambunathan K
     [not found]   ` <81397ua64z.fsf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-12-21 15:37     ` Francesco Pizzolante
2012-12-22 14:04       ` Jambunathan K [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k3sa41vf.fsf@gmail.com \
    --to=kjambunathan@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).