[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 13:39:40 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

On Sat,  1 Apr 2023 at 14:21, Eli Zaretskii wrote:

>> From: Augusto Stoffel <arstoffel@gmail.com>
>> Cc: Eli Zaretskii <eliz@gnu.org>,  rms@gnu.org,  m.eliachevitch@posteo.de,
>>   emacs-devel@gnu.org
>> Date: Sat, 01 Apr 2023 10:29:13 +0200
>> 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.
> If we pass START and END, why does the region have to be a single
> "word"?

This is a tricky point.  The notion of "word", for spell checking
purposes, is outside of the major mode's control.  For instance, some
languages include the apostrophe or hyphen as a word char, some don't.

Passing START and END means that the major mode can use the information
of how the spell-checker did the tokenization.  Typically, though, I
expect most function will look only at START or END.

>  why not let the caller specify a larger region to be skipped?

Then the return value can't be a boolean; it has to be a list of
regions, which is too complicated.

>> 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.
> Why?  I thought the purpose of this is to override what the
> spell-checker knows, and that includes comments and strings, if
> needed.  So I see no reason for such a recommendation.

Maybe.  But the above is exactly how Flyspell's
flyspell-generic-check-word-predicate works, and it makes sense IMO.

>> (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
>> determined."
>>   (save-excursion
> Why do we need save-excursion?

If we remove it here, then most spelling-ignore-functions will need to
call save excursion on their own, which would probably be fine as well.

>> The above would go into a “neutral” place like simple.el.
> Why not ispell.el?  All the spelling functions use ispell.el anyway.
> simple.el is preloaded, so having this there bloats every Emacs
> session for no good reason, IMO.

jit-spell only uses ispell.el to start a process and jinx doesn't use it
at all.  To me it makes sense to untangle the spellchecking support API
for major modes from any particular implementation.  But I guess this is
not a major issue.

reply via email to

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