Loading ...
Sorry, an error occurred while loading the content.

TIP: Changing buffer bindings

Expand Messages
  • Steven Phillips
    I thought I d jot this down as it may be of use to others too... Problem: A buffer binding uses a certain key combination you just can t get on with, how do
    Message 1 of 1 , Dec 11, 2009
    • 0 Attachment
      I thought I'd jot this down as it may be of use to others too...

      Problem: A buffer binding uses a certain key combination you just can't get on with, how do you change it? As an example I can't get on with binary mode's rebinding of Alt-down to binary-move-forward, I would prefer to bind this to Shift-down and leave Alt-down as scroll.

      Changing global binding are easy, add global-bind-key lines to your <user>.emf should do the trick, but changing buffer bindings are more difficult as they depend on the buffer's major-mode configuration. Below I outline two methods, one which will change the binding for all major-modes and one which targets a specific major-mode - choose the most appropriate to you.

      1) Change the binding for all major-modes

      This can be done by taking advantage of the emulation feature, if you already use an emulation (user-setup -> Start-up -> Emulation) then you may need to append your mappings. ME's emulation buffer key-binding mapping is performed whether emulation is enabled or not, it simply looks for the key binding in a list variable and if found it looks at another list variable to get the mapping, i.e.:
      set-variable .buffer-bind-key.map-from "|<from-bind1>|<from-bind2>|<from-bind3>|.....|<from-bindN>|"
      set-variable .buffer-bind-key.map-to   "|<to-bind1>|<to-bind2>|<to-bind3>|.....|<to-bindN>|"
      so for my example I need to add the following two lines to my <user>.emf:
      set-variable .buffer-bind-key.map-from "|A-down|A-up|"
      set-variable .buffer-bind-key.map-to   "|S-down|S-up|"
      This does the trick, but for my issue this is a bit excessive as this problem only occurs for binary mode.

      2) Change the binding for a specific major-mode

      This is a little more tricky and is not guaranteed to work in all cases (see below), this method simply modifies the major-mode's key binding key list as follows:

      set-variable .fhook-<mode>.command-kbind &rep &rep ... &rep .fhook-<mode>.command-kbind "|<from-bind1>|" "|<to-bind1>|" "|<from-bind2>|" "|<to-bind2>|" .... "|<from-bindN>|" "|<to-bindN>|"

      The above should all be on one line and there needs to be N '&rep's. This line needs to be added to the file 'my<mode>.emf' located in your setup path (i.e. same folder as your <user>.emf). So for my example I have the following mybinary.emf file:

      ---- mybinary.emf start ----
      set-variable .fhook-binary.command-kbind &rep &rep .fhook-binary.command-kbind "|A-up|" "|S-up|" "|A-down|" "|S-down|"
      ---- mybinary.emf end ----

      If you don't know what '<mode>' go into the buffer and then execute 'list-variables' (Help -> List Variables) and look at the $buffer-fhook setting.

      This will work for the vast majority of major modes, but some use a slightly different binding setup (diff, latex & nroff), for these you should look for the offending 'set-variable .fhook-<mode>.command-# ....' line and copy it into your my<mode>.emf file and modify it.

      I hope this will be of help to you,


    Your message has been successfully submitted and would be delivered to recipients shortly.