10

私はほとんどの文章を書くために Emacs を使用しています。私は reStructuredText を使用して書き、いくつかの前処理を行った後、それらを LaTeX に変換します。これは私のテキストの 1 つ (スペイン語) の抜粋です。

En \cite[pp.~XXVIII--XXIX]{Crnkovic2002} se brindan algunos riesgos
que se pueden asumir con el desarrollo basado en componentes, los

このテキストは、パーツを処理するいくつかのカスタム スクリプトによって処理される\citeためrst2latex、そのジョブを実行できます。

flyspell-mode を有効にすると、ほとんどの引用キーがスペルミスとして通知されます。

コマンド内でスペルチェックを行わないように flyspell に指示するにはどうすればよいですか\cite

さらに、rst-mode と flyspell をどのように組み合わせて、rst-mode が flyspell で次のスペルチェックを行わないようにするにはどうすればよいですか?

  • reST コメント
  • reST コード リテラル
  • reST ディレクティブのパラメーターと引数
  • reST raw ディレクティブの内容

何か案は?

4

3 に答える 3

11

You can set the variable ispell-parser to the value 'tex so that flyspell will ignore (la)tex sequences. To do so, you can either set it manually in each buffer like so:

M-: (setq 'ispell-parser 'tex)

or you write a little function that will do that for you. Put the following in your .emacs file:

(defun flyspell-ignore-tex ()
  (interactive)
  (set (make-variable-buffer-local 'ispell-parser) 'tex))

Then you can still invoke it manually, using

M-x flyspell-ignore-tex

or you could add a hook that calls that function automatically whenever you edit a file of a certain type. You would do the latter by adding the newly defined function to your auto-mode-alist. Say your filenames typically end with ".rst", then add this line to your .emacs file:

(add-to-list 'auto-mode-alist '("\\.rst$" . flyspell-ignore-tex))

As for the second part of your question: making flyspell-mode ignore larger regions, such as, e.g., reST comments, is not easily achievable. It becomes clear when you think about the way flyspell works: it checks text on a word-by-word basis. For that, flyspell-word only looks at one word at a time which it sends to an ispell process running in the background. The ispell process does the dictionary lookup and returns whether or not the current word is correct. If flyspell-word had to check every single time whether or not the current word is part of a comment or other region that should not be checked, it would be rather slow, because that would include quite a bit of searching through the buffer.

Now of course, one could approach this a little bit smarter and first find the non-comment regions etc. and then do the word-by-word checking only in those parts that are outside of those regions - but unfortunately, that's not the way flyspell is implemented.

If you can do without the "fly" part, however, ispell-mode has a mechanism to customize which regions of a buffer can be skipped. This is done via the variable ispell-skip-region-alist. But although flyspell-mode works off ispell-mode, for the reasons outlined above that variable is not used by flyspell-mode.

于 2011-01-12T21:39:16.847 に答える
4

スーパーユーザーのこの質問flyspell-generic-check-word-predicateで説明したように使用することもできます。

于 2011-10-11T21:02:31.833 に答える
1

(aspell の tex フィルターはまさにあなたが望むことをするかもしれませんが、より一般的な解決策が必要な場合)

以下のコードを使用して flyspell に数字を含む特定の単語にフラグを立てさせないようにしていますが、この種のフックを使用して特定のコンテキストに一致させることができます。

見ることはあなたが望む位置から始まります - そのため、あなたが気にかけている文脈の開始/終了を逆方向に検索したいかもしれません.

(when "another attempt to accept certain words flyspell/ispell/aspell flags as incorrect"
  (defun flyspell-ignore-WordNumber99-stuff/ag (beg end info)
    (save-excursion
      (goto-char beg)
      (cond
    ((or
       (looking-at "\\bWord1\\b")
       (looking-at "\\bWord99Foo\\b")
       )
      t)
    (t nil)
    )
      )
    )
  )

(add-hook 'flyspell-incorrect-hook 'flyspell-ignore-WordNumber99-stuff/ag)
于 2014-06-19T02:28:06.300 に答える