remacskey-bindingsess

How to change smart assign key ("_" to "<-") binding in ESS


In emacs ESS, how do I correctly change the keybinding for ess-smart-S-assign?

What I tried is adding

(custom-set-variables
    '(ess-smart-S-assign-key ":"))

to my .emacs, but that made weird things happen: When I press :, just a normal : appears. On the other hand, pressing _ once yields <- as usual, whereas pressing _ a second time then converts this to :. The desired behavior would be to be able to use _ as a normal key, with : being converted to <-.

I am using the official emacs 24.3 for windows and the latest development version of ESS (14.06).


Solution

  • Here's the docstring for ess-smart-S-assign-key:

    Documentation:
    Key used by `ess-smart-S-assign'. By default bound to
    underscore, but can be set to any key. If this key is customized,
    you must add
    
     (ess-toggle-S-assign nil)
     (ess-toggle-S-assign nil)
    
    after the line that sets the customization and evaluate these
    lines or reboot emacs. The first call clears the default
    `ess-smart-S-assign' assignment and the second line re-assigns
    it to the customized setting. 
    

    So: put this in your .emacs file to get the desired behavior:

    (setq ess-smart-S-assign-key ":")
    (ess-toggle-S-assign nil)
    (ess-toggle-S-assign nil)
    

    Kind of ugly, but it works.