astoff / jit-spell

Just-in-time spell checking for Emacs
45 stars 2 forks source link

Support for rcirc #2

Open phikal opened 1 year ago

phikal commented 1 year ago

What do you think would be the best way to support rcirc? All we need is actually spell checking after the prompt, since I am neither interested in indications that nicks are not real words or that the messages someone else wrote (but for the sake of simplicity all messages) might have typos.

I tried something like this,

(setq-local ispell-skip-region-alist
        (cons '("\\(?:.*$\\)*")
          ispell-skip-region-alist))

but it appears to have had no effect.

astoff commented 1 year ago

Right, I use ispell.el to start the ispell process and that's it.

Supporting rcirc should be doable by doing (add-function :filter-return (local 'jit-spell--filter-region) something), where something receives a list of conses (start . end) and return another such list. You just want to intersect that with the prompt region.

Now, how could we do that in a way that rcirc (which is too specific) doesn't need to know about jit-spell (even more specific) and vice-versa? Is it by any chance a comint-derived mode?

phikal commented 1 year ago

I would like to have ricrc work OOTB for all users, not just for me so the advice isn't the right approach for me.

Now, how could we do that in a way that rcirc (which is too specific) doesn't need to know about jit-spell (even more specific) and vice-versa?

Is there a reason why jit-spell doesn't use ispell-skip-region-alist or some other option like that?

Is it by any chance a comint-derived mode?

No, most rcirc buffer don't even have an associated process. Also, I don't think it would make sense for most comint derived modes to have spell checking (or at least I wouldn't know why -- you are usually writing non-prose).

astoff commented 1 year ago

I would like to have ricrc work OOTB for all users, not just for me so the advice isn't the right approach for me.

Yes, sorry, I meant to say what has to be done, either by you or me, for everybody else's profit :-).

Also, I don't think it would make sense for most comint derived modes to have spell checking (or at least I wouldn't know why -- you are usually writing non-prose).

Might be, but I come back to my question, what could I do in this package that is reasonably generic and doesn't involve special-casing rcirc?

phikal commented 1 year ago

Might be, but I come back to my question, what could I do in this package that is reasonably generic and doesn't involve special-casing rcirc?

If rcirc and jit-spell both add support for ispell-skip-region-alist, then to that would seem to be a solution, or am I missing something obvious?

astoff commented 1 year ago

If both add support then yes, but I can't quite see how to use ispell-skip-region-alist effectively. This API seems too focused on a command that will iteratively skip from word to word. In fact I don't quite understand the docstring. There's some procedure of how to use these regexps that is not explained there AFAICS.

If you could set a flyspell-generic-check-word-predicate, then jit-spell would work out of the box.

minad commented 1 year ago

If rcirc and jit-spell both add support for ispell-skip-region-alist, then to that would seem to be a solution, or am I missing something obvious?

FWIW, I would like to have some regexp-based mechanism to exclude certain text. For example in Elisp files I get a lot of false positives on comments like autoloads, the package header or dashed symbol names.

astoff commented 1 year ago

I think there's no way I could reasonable handle a list of excluded regexps. It really has to be a hook called with the start and end of the word in question, and you decide which excursion you need to do in order to figure things out. (“You” here refers to the major mode author, probably).

Jit-spell has the function var jit-spell--default-ignored-p that you can add things to. It's probably over-engineered, I accept that. I will change it to a hook, I guess, but ideally this would be some API in Emacs itself. I sent you guys a sketch of how I think this could look like.

aikrahguzar commented 1 year ago

I think there's no way I could reasonable handle a list of excluded regexps.

This will probably make #9 worse (although I am not affected by it myself) but I think one way to do so is to add jit-spelled-ignored to font-lock-extra-managed-props and then use font-lock-add-keywords to add it to the text matching regexps. It would be nice to be able drown out the noise of cookies and similar stuff in elisp.