[ESS] Help setting key binding for ess
maechler at stat.math.ethz.ch
Tue Mar 21 18:06:52 CET 2006
>>>>> "Seth" == Seth Falcon <sethfalcon at gmail.com>
>>>>> on Tue, 21 Mar 2006 05:33:25 -0800 writes:
Seth> "A.J. Rossini" <blindglobe at gmail.com> writes:
>> We really ought to use a defvar for this setting, so apologies,
Seth> Here is a patch that creates a variable ess-S-assign-key that the user
Seth> can use to specify a key that should get mapped to '<-'.
Seth> It doesn't use ess-smart-underscore, because that stops making sense
Seth> if you haven't mapped '_'.
Seth> For example, to have C-= insert '<-', you can put the following in
Seth> (setq ess-S-assign-key [?\C-=])
Seth> (ess-toggle-S-assign-key t)
quite nice; thank you, Seth!
However, the reversion (revert to previous state with smart
underscore) does not work, contrary to what the function name
I've applied your patch and improved it slightly
(- in doc string: `..', not `...`
- use local function instead of global ess-insert-S-assign ) :
(defun ess-toggle-S-assign-key (force)
"Set the key defined in `ess-S-assign-key'"
(let ((uscore (lookup-key ess-mode-map ess-S-assign-key))
(insert-S-assign #'(lambda() (interactive) (insert ess-S-assign))))
(if (and uscore
;; (stringp uscore) (string= uscore ess-S-assign)
(define-key ess-mode-map ess-S-assign-key nil)
(define-key inferior-ess-mode-map ess-S-assign-key nil))
;; else : "force" or uscore is "nil", i.e. default
(define-key ess-mode-map ess-S-assign-key insert-S-assign)
(define-key inferior-ess-mode-map ess-S-assign-key insert-S-assign))))
-- but I think one would really want the change such that a
second call to (ess-toggle-S-assign-key .)
would revert to smart underscore.
More information about the ESS-help