On Fri, Aug 1, 2014 at 8:49 AM, Edward K. Ream <[email protected]> wrote:
> Leo's vim-emulation scanning code is also fairly complicated. However, Leo's > code should remain simpler than the real vim's code. Just a two or three more comments and then I'll be on to coding. The comments in this thread are pre-writing for a "Theory of Vim Emulation" section in Leo's documentation. 1. A big reason that Leo's code will be simpler than vim's own code is the Python language. The goal is always simplicity, and the resulting generality the simplicity makes possible. Well, it's almost infinitely easier to see patterns in Python rather than C. That single perceptual advantage leads to better code. 2. I am proud of the work I did yesterday. I spent about 6 hours trying all sorts of parsing schemes. Ironically, the more work I did, the simpler the code became, and the less work I appeared to do. Looking at git diffs gives you *no* idea of the effort involved! 3. I am particularly proud of the seamless integration of Leo's code into the massively complex code in leoKeys.py. At present there are only four "hooks" into the code in leoKeys.py: The most important hook is at the top level of k.masterKeyHandler. Its placement is brilliantly simple. Leo will handle all "modes" as it always does. This includes handling the minibuffer. After handling modes, k.masterKeyHandler calls vc.do_key if vim_mode is in effect. vc.do_key returns True if it has completely handled the key. In that case, k.masterKeyHandler just returns. Otherwise, k.masterKeyHandler continues as usual. This has the effect of handling *all* bindings exactly as before. This is clearly the simplest thing that could possibly work. The other three hooks are in k.keyboardQuit, k.resetLabel and k.showStateAndMode. When vim mode is in effect, these hooks just call vc methods to reset or display the vim state. Totally simple. I don't expect any more hooks will be needed; they would be very simple in any case. In short, the vim code is on a solid footing. I can reorganize code within leoVim.py with absolutely no effect on the rest of Leo. Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
