简体   繁体   中英

ESS (R) Auto-complete

I try to get a practical development environment for R in Emacs, hoping to get auto-completion working as shown in http://www.emacswiki.org/emacs/ESSAuto-complete .

However, even in a minimal configuration, I can't get it working.

See what I get on http://screencast.com/t/qcyVwkECX . In fact, while AC does work (see completion menu appearing), it's like if there was no info from the R language itself, while ac-source-R is WELL added to ac-sources.

Do you understand what's happening?

Best regards.

PS- Here is my minimal Emacs configuration file for the demo:

;; Auto Completion
(add-to-list 'load-path "~/.emacs.d/elpa/auto-complete-20140824.1658/")
(add-to-list 'load-path "~/.emacs.d/elpa/popup-20140815.629/")
(when (require 'auto-complete-config)

(ac-config-default)

;; use `C-n/C-p' to select candidates
(setq ac-use-menu-map t)
(define-key ac-menu-map (kbd "C-n") 'ac-next)
(define-key ac-menu-map (kbd "C-p") 'ac-previous)

;; unbind some keys (inconvenient in iESS buffers)
(define-key ac-completing-map (kbd "M-n") nil)
(define-key ac-completing-map (kbd "M-p") nil)

;; set default sources
(setq ac-sources
      (append '(ac-source-features
        ac-source-functions
        ac-source-yasnippet
        ac-source-variables
        ac-source-symbols)
          ac-sources))

(setq ac-delay 0)               ; faster than default 0.1
(setq ac-auto-show-menu 0.2)
(setq ac-quick-help-delay 0.5)
(setq ac-quick-help-height 10)
(setq ac-candidate-limit 100)

;; completion by TAB
(define-key ac-completing-map
  (kbd "<tab>") 'ac-complete)

;; avoid Flyspell processes when auto completion is being started
(ac-flyspell-workaround))

;; ESS: Emacs Speaks Statistics
(add-to-list 'load-path "~/.emacs.d/elpa/ess-20140824.1452/lisp/")

  (setq shell-file-name "zsh.exe")

(add-to-list 'auto-mode-alist '("\\.[rR]\\'" . R-mode))

(autoload 'R "ess-site" "Call 'R', the 'GNU S' system from the R Foundation." t)
(autoload 'R-mode "ess-site" "Major mode for editing R source." t)

(setq ess-ask-for-ess-directory nil)
(setq inferior-ess-same-window nil)
(setq ess-default-style 'DEFAULT)

(with-eval-after-load "ess-site"

  ;; use eldoc to report R function names
  (require 'ess-eldoc)
  (add-hook 'inferior-ess-mode-hook 'ess-use-eldoc))

PPS- In fact, ElDoc does not seem to work either!

UPDATE

  1. I just discovered it almost works when the iESS buffer gets created, not when just editing R code in its own buffer. See http://screencast.com/t/fKRjLmIC6K0 .

    What would explain that iESS must be run first before it finally works?

  2. Still, something that does not work is the completion on function arguments (like with the cat function on the page http://www.emacswiki.org/emacs/ESSAuto-complete ).

    Why does that not work?

After opening a R file with emacs, if you have this mode described into your emacs status bar:

(ESS[S] [none] ElDoc AS)

You can run this shortcut Cc Cs to attach a R session to you ESS[S] editor mode.

If you already have one or some R session open, emacs will ask you to choose the R session you want to use. Otherwise if you have not already open a R session then emacs will open a new one for you.

Next, you should have this information inside your status bar:

(ESS[S] [R db -] ElDoc AS)

and the completion should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM