Emacs ess auto-complete

自古美人都是妖i 提交于 2019-12-19 10:12:04

问题


I am a R user, I want to use R in emacs. But, I am in trouble with customizing ess in emacs. I have installed the auto-complete packages and the latest ess in my emacs. But when I run r in emacs, the auto-complete don't work well. When I type app, I suppose to show like the image in (http://www.emacswiki.org/pics/static/ess-ac3) , but in my emacs neither of the auto-complete nor the yellow part shows.

My OS: ubuntu 12.04 amd64

my ~/.emacs file

;; Auto-complete
(add-to-list 'load-path "~/.emacs.d/site-lisp")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/site-lisp/ac-dict")
(ac-config-default)
; ess-site
(add-to-list 'load-path "/usr/share/emacs/site-lisp/ess")
(require 'ess-site)
(setq ess-eval-visibly-p nil)
(setq ess-ask-for-ess-directory nil) 

回答1:


Auto-complete works for me with this setting

(setq ess-use-auto-complete t)



回答2:


I got the same problem and the following code worked for me:

(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(package-initialize)  ;load and activate packages, including auto-complete
(ac-config-default)
(setq ess-use-auto-complete 'script-only)
;;if not working, use the following instead of (setq ess-use-auto-complete 'script-only)
;;(global-auto-complete-mode t)



回答3:


I recently started using ESS on Windows, and struggled with the same issue. I don't know all of the ins and outs but recent versions of ESS suggest using company-mode rather than auto-complete-mode. This minimal setup seems to have autocomplete working quite well for me on the following setup:

  • Windows 10 x64
  • R 3.4.3 x64
  • Emacs 25 x64 installed normally
  • MELPA repo enabled in init.el
  • package-install [RET] company
  • package-install [RET] ess
  • open a new R file in some directory
  • M-x company-mode to enable company-mode in the current buffer
  • `C-c C-z' to start an inferior R process

At this point, with the init.el file shown below, R completion is working, completing function calls, and package members. I think more configuration is needed to tailor it to your liking, but getting to this point took me long enough I consider it a success

init.el:

(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
                    (not (gnutls-available-p))))
       (proto (if no-ssl "http" "https")))
  (add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
  )
(package-initialize)

;; emacs controlled settings
(custom-set-variables
 '(package-selected-packages (quote (company ess)))
 '(show-paren-mode t)
 '(tool-bar-mode nil))
(custom-set-faces
 '(default ((t (:family "Consolas" :foundry "outline" :slant normal :weight normal :height 113 :width normal)))))

(require 'company)


来源:https://stackoverflow.com/questions/16075012/emacs-ess-auto-complete

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!