From version 12.03 ESS integrates out of the box with auto-complete package.
‘ac-source-R’ are included in ESS distribution. The latest combines previous two and makes them play nicely together.
From ESS 12.09 auto-complete is activated by default if you have auto-complete package installed. See the documentation of `ess-use-auto-complete` variable for more.
This activates ‘ac-source-R in both ESS and iESS buffers. If you want AC only in your ESS buffers do:
(setq ess-use-auto-complete 'script-only)
ESS provides AC help both for arguments and objects (default keys: `C-?` or `<f1>`)
You can bind `M-h` to display quick help pop-ups as in screen-shots above (requires a fairly recent version of AC https://github.com/m2ym/auto-complete):
(define-key ac-completing-map (kbd "M-h") 'ac-quick-help)
Ac binds M-n, and M-p for navigation in the completion menu, which might be inconvenient if you want it to use in the inferior R. Bind it to something else:
(define-key ac-completing-map "\M-n" nil) ;; was ac-next (define-key ac-completing-map "\M-p" nil) ;; was ac-previous (define-key ac-completing-map "\M-," 'ac-next) (define-key ac-completing-map "\M-k" 'ac-previous)
When selecting completion candidates the return key inserts the selected candidate. This can be a problem any time completion candidates are triggered and you want to insert a new line, because pressing return will complete the selected candidate rather than insert a new line as intended. One solution is to remove the binding of ac-complete to the return key”
(define-key ac-completing-map "\r" nil)
Optionally, you may wish to bind ac-complete to tab:
(define-key ac-completing-map "\t" 'ac-complete)
With recent versions of auto-complete you may need to set
(define-key ac-completing-map [tab] 'ac-complete) (define-key ac-completing-map [return] nil)
Example of dark config as in the snapshot:
(set-face-attribute 'ac-candidate-face nil :background "#00222c" :foreground "light gray") (set-face-attribute 'ac-selection-face nil :background "SteelBlue4" :foreground "white") (set-face-attribute 'popup-tip-face nil :background "#003A4E" :foreground "light gray")
You can play with AC settings to adjust the completion to your needs:
(setq ;; ac-auto-show-menu 1 ;; ac-candidate-limit nil ;; ac-delay 0.1 ;; ac-disable-faces (quote (font-lock-comment-face font-lock-doc-face)) ;; ac-ignore-case 'smart ;; ac-menu-height 10 ;; ac-quick-help-delay 1.5 ;; ac-quick-help-prefer-pos-tip t ;; ac-use-quick-help nil )
For some more tips see this comment https://stat.ethz.ch/pipermail/ess-help/2012-May/007835.html