[ESS] First steps

Marc Schwartz marc_schwartz at me.com
Fri Jun 26 16:09:34 CEST 2009


On Jun 26, 2009, at 7:16 AM, baptiste auguie wrote:

> Dear list,
>
> I apologize for the really basic questions, but I'm completely new to
> emacs. I used to use Textmate with R.app on a Mac, but I'd like to
> switch to aquamacs now. I've installed this version,
>
> GNU Emacs 22.3.1 (i386-apple-darwin9.6.0, Carbon Version 1.6.0)
> of 2009-02-18 on plume.sr.unh.edu - Aquamacs Distribution 1.7
>
> ESS version 5.3.6
>
>
> The minor annoyances I'm facing are the following,
>
> i) how do you type the assignment operator <- more efficiently than
> with the 4 keystrokes I just used? (space on both sides)

Type an underscore character.

If you actually want an underscore, type it twice


> ii) with a comma-separated list (e.g. seq( 1, 3, by=0.1) is there a
> way to get automatic spacing after the commas whilst typing?

I have the following in my .emacs:

(defun ess-comma-space ()
   (global-set-key (kbd ",") (lambda () (interactive) (insert ", "))))

(add-hook 'ess-mode-hook 'ess-comma-space)
(add-hook 'inferior-ess-mode-hook 'ess-comma-space)


As with most keyboard shortcuts, it can take a bit to get used to  
using this and not getting two spaces, when you out of habit, type the  
comma followed by a space.

I have wrestled with using or not using this, so it may be a matter of  
personal choice.


> iii) is there a trick to get automatic pairing of open brackets? (say,
> if i type "plot(" i'd like automatic completion with the closing
> bracket ")".


I have the following in my .emacs, which uses skeleton mode to pair  
{}, [], (), '', "" and <>:

;; enable skeleton-pair insert globally
(setq skeleton-pair t)
;;(setq skeleton-pair-on-word t)
(global-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "[") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "{") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "\"") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "\'") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "\`") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "<") 'skeleton-pair-insert-maybe)


If you uncomment the third line, the pairing will occur at any time,  
even in a word. If you leave it as is, the pairing will only occur if  
the first character is not followed by other 'in word' characters or  
the beginning of a word.

This is set as a global, so is not unique to ESS/R modes. However, I  
find this of value when typing other content outside of R.

HTH,

Marc Schwartz


> I found lots of useful tips in the ESS-reference card, but nothing on
> these three particular points.
>
>
> Any input will be much appreciated!
>
> Sincerely,
>
> baptiste



More information about the ESS-help mailing list