[ESS] ~ symbol

Kasper Daniel Hansen khansen at stat.Berkeley.EDU
Thu Jun 22 18:03:43 CEST 2006


On Jun 22, 2006, at 3:01 AM, Stephen Eglen wrote:

> Dear Giovanni,
>
>> something that looks very nasty to students).
>> Question: is there a simple method in ESS Emacs
>> to extend the wonderful mechanism of pressing underscore
>> to obtain  <- ? For instance one could press another unused key
>> and obtain tilde. Or even press underscore three times-
>
> Try:
> (setq ess-S-assign "~")
>
> and then when you hit _ you get "~" rather than "<-".
>
> Beware though, I'm not sure if changing ess-S-assign will break other
> parts of ESS.
>
> (Making underscore cycle through three different items might be
> difficult).

My guess is that Giovanni wants to keep the assignment key as is, and  
instead map a different non-used key to tilde.

This is in principle easy to do, I used to do it when I was on a  
danish keyboard writing latex where \, {, } are accessible but  
requires quite some arm twisting to get. You can do it two ways. One  
is a global remap where it works in all of Emacs and one is a mode  
remap where it depends on the mode you are in.

Here are (some) of my code for LaTeX. And there are as far as I know  
several ways to do the code, this is just one of them

(add-hook 'LaTeX-mode-hook
'(lambda nil
    (define-key LaTeX-mode-map [?\'] '(lambda () (interactive)  
(insert "{")))
))

This remaps the ' key to { but only in LaTeX-mode. You need to  
replace LaTeX-mode with ess-mode. And I do not know if you need  
several modes or whether all the ESS modes are under one hook (as you  
know there are modes for .Rd, .R and an R session. And transcript.  
And perhaps more I forgot).

Often I make two remaps A->B and B->A so I switch the keys. But since  
you do not have the key to begin with, you probably just need one  
way. Or you could think about investigation getting some CTRL, META  
etc + key to get you the original value (beware of other conflicts).  
The sky is the limit, the biggest problem is selecting which keys to  
map to which symbols.

The biggest problem is usually finding the "key-code" associated with  
the key you are pressing. Especially if you start to play with  
modifier keys. Most of the keys are straightforward, but in my  
experience I always wanted to remap less-used keys which sometimes  
made it a bit more challenging. There is a way to get Emacs to report  
which symbol corresponds to which key-press but again I forgot how  
(actually it may be a function I found somewhere on the internet, he  
details are hazy).

A global change needs something like
(global-set-key [\C-home] 'beginning-of-buffer)

Well, I hope this was at least a pointer.


>
> Stephen
>
> ______________________________________________
> ESS-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help




More information about the ESS-help mailing list