[Top][All Lists]

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

Re: jinx

From: Augusto Stoffel
Subject: Re: jinx
Date: Sat, 01 Apr 2023 10:29:13 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

On Fri, 31 Mar 2023 at 20:33, Arash Esbati wrote:

> Somewhat off-topic, but it would be great if ispell and flyspell could
> use the same logic for skipping portions of buffer text.  Take for
> example (La)TeX mode: ispell uses `ispell-tex-skip-alists' and flyspell
> uses `flyspell-tex-command-regexp' (which is not very powerful) and then
> a function added to `flyspell-generic-check-word-predicate' (AFAIU).  I
> once wrote an addition for AUCTeX (tex-ispell.el) which extends
> `ispell-tex-skip-alists' for many LaTeX packages but had hard times
> making it work with flyspell as well, skipping multi-line text portions
> was something I couldn't solve for flyspell, e.g.:
> \begin{verbatim}
> Please skip the entire text in this environment.
> \end{verbatim}
> Best, Arash

The logic used by Flyspell could easily be used by ispell.el, but not
vice-versa.  However, the flyspell-generic-check-word-predicate API also
has some issues (e.g., a minor mode can't plug into it easily).  Also,
it's quite messy in that some modes are supported in flyspell.el, while
all other are expected to implement their own predicate (of course, the
latter is a better approach).

So I'd suggest a generic API on these lines:

#+begin_src emacs-lisp
(defvar spelling-ignore-functions nil
  "Hook used to determine if a word should be excluded from spell checking.
These functions are called with two arguments, the start and end
positions of a word, until a non-nil value is returned.  Any
result other than nil or `never' indicates that the word should
be excluded from spell checking.

Modes derived from `prog-mode' should leave it up to the spell
checker to decide whether or not to ignore comments, strings or
code regions.  They may provide more specific rules, if desired,
but this typically not needed.

MAYBE ALSO: These functions should make no assumptions about the
point position, and are free to move it.")

(defun spelling-ignored-p (start end)
  "Return non-nil if the word between START and END should not be spell checked.
See `spelling-ignore-functions' for information on how this is
    (memq (run-hook-with-args-until-success spelling-ignore-functions start end)
          '(nil never))))

The above would go into a “neutral” place like simple.el.  Each mode
would be responsible to define its own hooks and each spell-checking
package could use it as it sees fit.

reply via email to

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