-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A hydra for flyspell with flyspell-correct #69
Comments
@gusbrs thank you very much for sharing the code and your thoughts about spell I don't personally use hydra but I see how it can be useful when one needs to So, I am more than happy to provide hydra wrapper for spell correction. In order for it to function
I haven't tested the code itself, so maybe you solved (2) in a fancy way, it's I think that This is fascinating :) |
@d12frosted I thought you'd like it! :-) Do try it out. You'll see that most, if not all, of your workflow concerns are indeed covered. (This is not to say the way this is currently implemented there is ready to be somehow incorporated to If you are not much into hydra, you can abstract it for the time being. Just bind the body ( As to how it works (UI side) the starting or quitting the hydra will not move point by itself at all, point will only be moved if this is explicitly asked (with A typical spell-checking with it will be: call the hydra with "C-c k", normally call "flyspell-buffer" with "b" (unless already done before), if I want to start from BoB "M-<", otherwise just stay put, then start navigating through misspellings on the desired direction with either "n/SPC" or "p/DEL", when correction is desired "c/.", the same with the saving commands, and so on. When finished "q" or "C-g". If I want to return point "C-u C-SPC". Done. An important difference on the working of the hydra wrt And yes you are quite correct that the difference is subtle:
But it is a critical one in that the hydra does not call the correction interface automatically. You essentially navigate through the misspellings until you decide to do so explicitly. That makes a difference on fluidity for this use case. As said, here I wanted to "mostly skip, and sometimes correct". On the implementation side, note that as it stands the hydra uses So I did not "solve (2) in a fancy way", but by a really simple one: by not entering a loop, by not moving point by itself, so the issue does not arise. So there is also no "rapid" mode at play here. As to what to do with it, I'm not sure this functionality should be placed directly in As to:
Thank you very much! I'm at your disposal to think this through and, within my capabilities, try my hands on helping implement this in a way which fits properly into My suggestion is that you try it out with a look for the user interface first, and see how it feels/works. As I initially said, I think most of your concerns as to functionality should be addressed. How to fit this into |
Hey @gusbrs, Just wanted to say that I do remember about this issue! Don't worry. I just need to find time to tackle it. |
Hi @d12frosted , take your time, of course! And if you need something from me with this, let me know. |
Hi,
following the discussion at #58, I share here a hydra I cooked for flyspell spellchecking making use of
flyspell-correct-at-point
as basic correction interface. As I mentioned there, it is not strictly within the logic offlyspell-correct
but I believe it may complement it in the particular task of whole buffer checking, so it might be useful. So, this is not a "request" nor a "bug report". It is meant only as sharing some ideas I found worked well for me, for your use inflyspell-correct
as you please, if you please. Of course, if some of the ideas or code are deemed interesting enough to be somehow incorporated toflyspell-correct
, I'll be more than happy with that.If I understand the design choice correctly,
flyspell-correct
is mainly targeted at making fast spell corrections on a local scope, as you type, and excels at that. This is pretty much the same logic offlyspell
itself. But sometimes we also need to do a thorough "whole buffer" check, particularly when we reach a revision stage of a given document. The standard Emacs tool for this task isispell
. Here, in the sense of being designed for it: it keeps track of a ispell session, it defaults toispell-buffer
if there is no region, etc. Of course, we can useispell-word
to correct a word at point or go about a whole buffer withflyspell-goto-next-error
and then usingflyspell-correct-at-point
(or vanillaflyspell
facilities for that), but in either case things are less than optimal. (I probably wouldn't startflyspell-correct-wrapper
for a whole buffer spell-checking task myself, but it is of course possible, and seems to be so used, e.g. #60 (comment)).Sure, we could use either tool where it is most appropriate, and probably this is what many people actually do. But I wanted to keep a single UI for spellchecking to reduce the cognitive strain of switching between quite different interfaces. Flyspell would be then the natural candidate, for it is hard to beat for the "spell-checking as you type" task. I've also been reaching best results for LaTeX with it. And I use
flyspell-correct
(-ivy
) as my Flyspell interface, and like it very much.So I wanted to improve upon
flyspell
for this particular task of "whole buffer checking" while keeping the goodness offlyspell-correct
. This is what this hydra is about.That given, a couple of things stood out as differences with respect to the behavior of
flyspell-correct
for this particular task I wanted to address:point handling:
flyspell-correct
restores point after its task is finished. I find this brilliant for "correct while typing" kind of task (It was actually the killer behavior that brought me to useflyspell-correct
in the first place). But it is not what I want when doing a "whole buffer" kind of task. Sometimes the spell-checking requires some sort of special intervention/editing for which the want to actually leave the checker, do something else, and then take things back from where we were with spell-checking. Ispell handles this: it offers a way to leave point at the word which was being checked, and we can restart it again with a prefix etc.skipping: when doing a local "correct while typing" kind of task we see what the problem is and want to correct fast, but sometimes we have to skip some words to get there; when doing a "whole buffer" kind of task we are typically at a revision/polishing phase when the ratio of "skipping/correcting" is much larger. So for the first case we want "mostly correcting, and sometimes skipping", whereas for the second "mostly skipping, and sometimes correcting". Ispell is also sensitive to this: it is not by chance that the space-bar skips in
ispell
, whereas it replaces inquery-replace
.One thing I wanted to keep from
flyspell-correct
is it's bidirectional functioning, which is not really granted by eitherflyspell
orispell
. True, this is probably less important for a "whole buffer" kind of task, but I like this flexibility and, in my experience, sometimes things that show up further down the road of a checking session makes us regret a previous decision of skipping or accepting and I want to go back. So it's a nice flexibility I wanted to have: navigating back and forth the spelling mistakes.Those things given, I came up with the hydra plus auxiliary functions below. It admittedly is not within the logic of
flyspell-correct-move
, and just makes use offlyspell-correct-at-point
when needed, which grants the UI experience in line withflyspell-correct
in general. The core are the skip functions (just adapted versions offlyspell-goto-next-error
). The result is more akin to theispell
logic (given the task envisaged), but with even more flexibility and nicer interface granted byflyspell-correct
.See how you like it and, as said before, if there's anything you can take from it (including all of it) for
flyspell-correct
, I'd be very glad. If not, it is fine too, the fun in sharing and discussing is more than good enough.Notes: 1) I use
undo-tree
, place there whatever you use; 2) this lacks the facility of saving the word to the "global" dictionary, which I don't use, but it could easily be added; 3) this is an amaranth hydra, so the session will be mostly "sticky", which is meant, unless you explicitly want to leave it; 4) the hydra includes some navigation commands and alternative bindings for base actions which are not in explicit in the "menu".The text was updated successfully, but these errors were encountered: