Coder Social home page Coder Social logo

Comments (5)

calmofthestorm avatar calmofthestorm commented on June 7, 2024

I agree this is something that needs to be done, however it touches on a number of difficult issues which is why I have generally put it off.

First, there are some annoying properties of how Natlink loads and reloads modules. Whenever you turn your microphone off and then back on again, all modules will be reloaded. Unfortunately, it does not seem that that link was designed to work with modules that rely on other files. So only the files starting with _ are reloaded, not things they import. Incidentally, this is why it is currently necessary to exit and restart Dragon after changing grammars with my setup. I personally consider this an acceptable annoyance, but it has given me pause in terms of splitting things up too far.

Unfortunately it is not simple to simply extract the formatting functions into an independent grammar, since you have to pause between commands from different grammars. So for example, when speaking a phrase for verbal_emacs, I would need to pause and then speak the formatting command, and then resume. This is because the way that multi-edit and verbal_emacs are able to chain commands together is by creating grammars that make Dragon think it is one giant command.

A long-term goal of mine is to decouple this implementation detail (chaining) from the content that is actually being chained. In practice, this would mean changing multi-edit into a plug-in-based system, whereby multi-edit itself just contains the chaining logic and loads modules for the various actual formatting commands. This would also be a good way to handle things like grayjay's Eclipse bindings and my Python ones. This would also, in theory at least, open the possibility of chaining commands across grammars -- so I could say close frame to chromium, a window manager command to switch to a different tab, and then start typing all without pausing. Unfortunately, I still don't feel like I understand dragonfly/natlink enough to attempt something this complex, given I would basically be re-implementing the concept of a grammar with a shim layer to natlink. Perhaps at this point it would make more sense for me to read through the natlink code to see how it actually handles module loading -- it's possible he would not be terribly difficult to make the changes necessary to support this.

At any rate I am unlikely to have time to look into anything this complex in the near term. In the meantime, I suppose there's no reason not to move the formatting functions into their own module and then import them directly from where they are used.

from aenea.

nirvdrum avatar nirvdrum commented on June 7, 2024

Ahh, well that explains why I was getting weird errors like "TypeError: The grammar object a Dragonfly rule cannot be changed after it has been set (Grammar(verbal_emacs) != Grammar(verbal_emacs))." when turning the mic on and off. I figured out restarting Dragon fixed it mostly by chance. But now I understand why, so thanks for clarifying that.

from aenea.

calmofthestorm avatar calmofthestorm commented on June 7, 2024

The only way I know to get around this though would be to make each grammar contained in a single file, and I don't really see this as an option. At one point I experimented with manually reloading imports, but ran into issues where some of the dragonfly code was still using an old object so things like isinstance would fail to work as intended.

from aenea.

calmofthestorm avatar calmofthestorm commented on June 7, 2024

I am flagging this won't fix for now. I will open an issue for discussion of the plug-in-based architecture I was talking about, that will eventually solve this problem.

from aenea.

calmofthestorm avatar calmofthestorm commented on June 7, 2024

#19 is the general case of this.

from aenea.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.