jit-spell icon indicating copy to clipboard operation
jit-spell copied to clipboard

Support for rcirc

Open phikal opened this issue 2 years ago • 8 comments
trafficstars

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.

phikal avatar Mar 08 '23 17:03 phikal

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?

astoff avatar Mar 08 '23 19:03 astoff

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).

phikal avatar Mar 08 '23 19:03 phikal

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?

astoff avatar Mar 08 '23 19:03 astoff

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?

phikal avatar Mar 08 '23 19:03 phikal

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.

astoff avatar Mar 08 '23 21:03 astoff

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.

minad avatar Mar 10 '23 11:03 minad

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.

astoff avatar Mar 10 '23 15:03 astoff

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.

aikrahguzar avatar Mar 23 '23 12:03 aikrahguzar