• drosophila@lemmy.blahaj.zone
    link
    fedilink
    English
    arrow-up
    3
    ·
    2 days ago

    I don’t know how Micro works, and I don’t actually use emacs day to day, but as I understand it emacs works a bit like:

    • When you press a key in emacs it invokes a Lisp function that takes as arguments the text buffer that has focus, the parameters of the ‘window’ into that buffer, and the cursor position in that window.
    • This is the case for any key you press in any context, even for typing normal letters.
    • A ‘mode’ in emacs is a set of bindings which associate specific keys with specific functions.
    • ‘modes’ can be stacked on top of each other, with higher modes being able to intercept key presses before they reach lower modes, and changes / manipulate lower modes (I think?)
    • All of the editor’s functionality, such as ‘search’ or ‘undo’, is implemented in that way.
    • All of this is completely customizable, so pressing a key combo can be made to do virtually anything or manipulate the rest of the editor’s systems in any way.

    Does Micro work anything like that?

    • flamingos-cant (hopepunk arc)@feddit.ukOP
      link
      fedilink
      English
      arrow-up
      3
      ·
      edit-2
      2 days ago

      A ‘mode’ in emacs is a set of bindings which associate specific keys with specific functions.

      Not quite, a mode is basically a lisp function defined with a different macro that integrates it into the various systems (like showing up in the modeline when active). It can do basically anything, including setting keybinds.

      ‘modes’ can be stacked on top of each other, with higher modes being able to intercept key presses before they reach lower modes, and changes / manipulate lower modes (I think?)

      No, a keybind can only run one function and what that function is is whatever last defined a binding for that key. Like, if one mode defines a key to be something and you activate another that also binds that key, the latter takes over.

      Emacs does have something like you describe, where functions can be ‘advised’.