minad / jinx

🪄 Enchanted Spell Checker
GNU General Public License v3.0
435 stars 23 forks source link

Potential enhancement: post-correction hook (or similar) #154

Closed tecosaur closed 7 months ago

tecosaur commented 7 months ago

Hi Minad!

I've had this on my radar for a while, but been bogged down with other concerns and haven't been able to get around to taking jinx for a spin so far.

Thanks for producing yet another well-constructed utility package!

From my usage so far, other than a lack of clarity around how custom dictionaries work with enchant, and little funkiness with corrections on blacklisted faces (I'll open an issue on this if I can't figure it out / can construct a decent MWE), it's been great :slightly_smiling_face:

Now that I'm thinking about spell check a bit more, and having just revised some expansion setup in my config, it occurs to me that there's something quite nice that I think can be done with the two, that can be implemented as either advice around jinx-correct (I think), or in a cleaner way with some help from jinx (such as a post-correction hook).

My thought is that if I were to log every correction made via jinx to a file, I could then identify my most frequent misspellings, and turn them into an abbrev table to make my life easier.

To me this seems a bit much for jinx to potentially provide OOTB, but a "post correction" -type hook that provides the old and corrected word would make this pretty trivial to implement without having to resort to advice.

I don't mind using advice myself, but thought I'd mention this thought here in case you do like the sound of making this use-case easier.

All the best, and thanks again for the work you've done!

minad commented 7 months ago

Thanks. I think you are looking for this https://github.com/minad/jinx/wiki#save-misspelling-and-correction-as-abbreviation?

tecosaur commented 7 months ago

Wonderful! I hadn't thought to look at the wiki, but that very much answers the question of whether a hook or advice is the way you'd go for this use case.

minad commented 7 months ago

We could also add a hook if this is a commonly requested feature. The usage of hooks is slightly more obvious, but besides that an advice is as good as a hook for this. I don't think advices should be avoided under all circumstances, as is done in Emacs core.

tecosaur commented 7 months ago

I'm of a similar mind, if it's more than just me and a few others a hook seems nice, but otherwise advice seems perfectly reasonable. Even if it does feel a bit risky to rely on advice to a --* "private" function.

If you're interested, you can find what I've done here https://tecosaur.github.io/emacs-config/config.html#saving-corrections-abbreviations (just the code). It's like most of my config, effective but overengineered :stuck_out_tongue:.

minad commented 7 months ago

tecosaur @.***> writes:

If you're interested, you can find what I've done here https://tecosaur.github.io/emacs-config/config.html#saving-corrections-abbreviations (just the code). It's like most of my config, effective but overengineered :stuck_out_tongue:.

Hehe, indeed. I wonder what you want to do with those statistics. Abbrevs are nice, but as we learn (getting better at typing or spelling I mean), we likely do not repeat the same mistakes over and over again?

tecosaur commented 7 months ago

(getting better at typing or spelling I mean), we likely do not repeat the same mistakes over and over again?

Hey, speak for yourself! :joy: I'm ashamed to admit that after writing that I had to correct about ~20 instances of "mispelling" to "misspelling". Don't ask me why I didn't type that second s, I couldn't tell you :sweat_smile:.

That said, I see the largest use here being typo fixing. The requirement to make the same fix at least N times is mainly to avoid instances when typos with short words are ambiguous and the potential annoyance if it started being auto-corrected incorrectly is IMO rather high.

Edit: Oh, and also lazy miscapitalisation.

minad commented 7 months ago

tecosaur @.***> writes:

(getting better at typing or spelling I mean), we likely do not repeat the same mistakes over and over again?

Hey, speak for yourself! :joy: I'm ashamed to admit that after writing that I had to correct about ~20 instances of "mispelling" to "misspelling". Don't ask me why I didn't type that second s, I couldn't tell you :sweat_smile:.

That said, I see the largest use here being typo fixing. The requirement to make the same fix at least N times is mainly to avoid instances when typos with short words are ambiguous and the potential annoyance if it started being auto-corrected incorrectly is IMO rather high.

Okay, thinking about this more, if you do it well (with good stats and checking for ambiguities), you can turn this into a nice abbrevcorrect package, which hooks into various checkers like Jinx. You could maybe offer an interface where the user can tell your package if a correction has occurred. Then leave it to the user to glue this together with Jinx or other checkers.

However on "smart"phones I am mostly annoyed by autocorrect. I am glad that eMacs doesn't have this feature yet. :-P

tecosaur commented 7 months ago

At this point what I've got is pretty much a package (with a little renaming I have autocorrect.el. NB: disclamer is a bit overblown at this point).

you can turn this into a nice abbrevcorrect package, which hooks into various checkers like Jinx.

Only the last ~5 lines are jinx-specific.

You could maybe offer an interface where the user can tell your package if a correction has occurred.

That exists, it's (autocorrect-record-correction text corrected) :slightly_smiling_face:.

However on "smart"phones I am mostly annoyed by autocorrect. I am glad that eMacs doesn't have this feature yet. :-P

Oh the irony of having "eMacs" in a comment complaining about smartphone autocorrect :laughing:.

I've got a few more thoughts on this, which I've put in the rewritten introduction to the autocorrect section of my config.

tecosaur commented 7 months ago

Update: https://code.tecosaur.net/tec/autocorrect now exists (and is mirrored to https://github.com/tecosaur/autocorrect)