Emacs ess auto-complete - emacs

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)

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)

Auto-complete works for me with this setting
(setq ess-use-auto-complete t)

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)

Related

Emacs: list-packages [no match]

I'm new to Emacs. I'd like to install a package, but doing M-x package-install says there is no such command.
Trying to look which packages are installed with M-x list-packages does not work either. GNU Emacs manual does not say much about it (or I looked in a wrong place), and I can't quite come up with meaningful keywords for search due to my limited Emacs knowledge.
Thanks phils and shyamupa for setting me on track. Indeed, I am using emacs 23 ("M-x version" to check).
I used instruction from here to install packaging system. I had to copy the following in scratch:
(let ((buffer (url-retrieve-synchronously
"http://tromey.com/elpa/package-install.el")))
(save-excursion
(set-buffer buffer)
(goto-char (point-min))
(re-search-forward "^$" nil 'move)
(eval-region (point) (point-max))
(kill-buffer (current-buffer))))
and then M-x eval-buffer
Then, M-x package-list-packages works.
UPDATE:
It turns out I was looking for a package in MELPA, and the above procedure sets you up for ELPA only. The content of my .emacs file after installation was following:
(when
(load
(expand-file-name "~/.emacs.d/elpa/package.el"))
(package-initialize))
To enable MELPA load I had to replace the contents of package.el with this and change .emacs as follows (inspired by this SO question):
(load (expand-file-name "~/.emacs.d/elpa/package.el"))
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
(package-initialize)
This did the trick and I got a huge list of packages from MELPA. Hope this will save someone time in future.

Emacs does not see new installation of Org-Mode

I had installed org-mode version 8.2.1 from emacs list-packages.
I downloaded the latest version 8.2.4 and placed it in .emacs.d and added the following to my .emacs,
(add-to-list 'load-path "~/.emacs.d/org-8.2.4/lisp")
Emacs still reports org-mode version to be 8.2.1
Try removing old installation(s) of org-mode from the load-path first:
(require 'cl)
;; Org-mode that was shipped with Emacs
(setq load-path (remove-if (lambda (x) (string-match-p "org$" x)) load-path))
;; ELPA
(setq load-path (remove-if (lambda (x) (string-match-p "org-20" x)) load-path))
(setq custom-org-path "~/.emacs.d/org-8.2.4/lisp")
(add-to-list 'load-path custom-org-path)
Also make sure to do it as early as possible in your init.el - especially if you use org-mode-based system for your emacs configuration files.
Add the following to your init.el file.
(require 'package)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
From the org compact guide here.

emacs auto-complete don't work with jde

I want to develop java in emacs. I install ecb, jde and auto-complete extensions. Each one works well without starting others. But when i want to use them together, some problem happened.
auto-complete-mode doesn't auto start with jde, I need to start it by M-x auto-complete-mode. If without jde, auto-complete-mode will auto start
When I manually start the auto-complete-mode in jde, the auto complete is not work well. It just auto complete the word that is appeared.
Here is my .emacs content:
(global-linum-mode 1)
(setq linum-format "%2d| ")
(setq default-tab-width 4)
(setq debug-on-error t)
;;no backup file
(setq make-backup-files nil)
(setq debug-on-error t)
;;auto complete config
(add-to-list 'load-path "D:/emacs-24.1/custom_el/auto-complete-1.3.1")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "D:/emacs-24.1/custom_el/auto-complete-1.3.1/dict")
(ac-config-default)
(setq stack-trace-on-error t)
(add-to-list 'load-path (expand-file-name "D:/emacs-24.1/custom_el/jdee-2.4.0.1/lisp"))
(add-to-list 'load-path (expand-file-name "D:/emacs-24.1/custom_el/cedet-1.1/common"))
(add-to-list 'load-path (expand-file-name "D:/emacs-24.1/custom_el/elib-1.0"))
(add-to-list 'load-path' "d:/emacs-24.1/custom_el/ecb-2.40")
;; Initialize CEDET.
(load-file (expand-file-name "D:/emacs-24.1/custom_el/cedet-1.1/common/cedet.el"))
(load-file (expand-file-name "D:/emacs-24.1/custom_el/ecb-2.40/ecb.el"))
(require 'ecb)
(ecb-activate)
(ecb-byte-compile)
;; If you want Emacs to defer loading the JDE until you open a
;; Java file, edit the following line
(setq defer-loading-jde nil)
;; to read:
;;
;; (setq defer-loading-jde t)
;;
(if defer-loading-jde
(progn
(autoload 'jde-mode "jde" "JDE mode." t)
(setq auto-mode-alist
(append
'(("\\.java\\'" . jde-mode))
auto-mode-alist)))
(require 'jde))
;; Sets the basic indentation for Java source files
;; to two spaces.
(defun my-jde-mode-hook ()
(setq c-basic-offset 2))
(add-hook 'jde-mode-hook 'my-jde-mode-hook)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ecb-options-version "2.40")
'(ecb-primary-secondary-mouse-buttons (quote mouse-1--C-mouse-1)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
The version info is :
emacs : 24.1
auto complete : 1.3.1
ecb : 2.40
cedet : 1.1
elib : 1.0
jdee : 2.4.0.1
To auto-start auto-complete-mode with jde-mode, you need to add jde-mode to ac-modes:
(push 'jde-mode ac-modes)
Then you need to add a JDEE-specific source to ac-sources. I'm not sure of the extent of JDEE integration with Semantic, you may be able to use the pre-defined source for it:
(add-hook 'jde-mode-hook (lambda () (push 'ac-source-semantic ac-sources)))
If not, you may need to define a specialized source with ac-define-source. See auto-complete-config.el for examples.

Emacs auto-complete-mode at startup

I just install auto-complete-mode, however everytime I start emacs I have to M-x auto-complete-mode. Is there anyway to have it loaded automatically ?
My .emacs is as follows:
;; auto-complete
(add-to-list 'load-path "~/.emacs.d/")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d//ac-dict")
(ac-config-default)
Thanks
I think you can do it in various ways. To enable it globally you should use
(global-auto-complete-mode t)
But it uses auto-complete-mode-maybe, which turn AC on only those listed in ac-modes. You can add them manually just like this
(add-to-list 'ac-modes 'sql-mode)
You can make your own list if you wish AC be active only for few modes
(setq ac-modes '(c++-mode sql-mode))
Or rewrite it to have AC everywhere.
(defun auto-complete-mode-maybe ()
"No maybe for you. Only AC!"
(auto-complete-mode 1))
edited:
Autocomplete in minibuffer is bad. I think this will be better.
(defun auto-complete-mode-maybe ()
"No maybe for you. Only AC!"
(unless (minibufferp (current-buffer))
(auto-complete-mode 1)))
I just needed this:
(require 'auto-complete)
(global-auto-complete-mode t)
added to my .emacs.d/init.el file.
I installed auto-complete with the package manager. I'm using Emacs 24.

Setting up SLIME via macports

I followed the instructions as best I could for installing terminal SLIME on Mac OS X, but when I press M-x it does not prompt me.
I installed emacs and Lisp using the following two sudo commands:
sudo port install emacs +carbon
sudo port install sbcl slime
I got the following instructions:
(add-to-list 'load-path "/opt/local/share/emacs/site-lisp/slime")
(require 'slime-autoloads)
(setq slime-lisp-implementations
`((sbcl ("/opt/local/bin/sbcl"))
(abcl ("/opt/local/bin/abcl"))
(clisp ("/opt/local/bin/clisp"))))
(add-hook 'lisp-mode-hook
(lambda ()
(cond ((not (featurep 'slime))
(require 'slime)
(normal-mode)))))
(eval-after-load "slime"
'(slime-setup '(slime-fancy slime-banner)))
Populate the initialization list in SLIME-LISP-IMPLEMENTATIONS with
the correct paths to the Common Lisp exectuables you wish to use.
I'm not sure what that last bit means...
Anyways, I've never used Lisp or emacs before, most literal n00b directed instructions would be best. Just the bare minimum to write and execute common lisp with emacs.
Thanks!
Looks like you're on the right track already. Since you've only installed sbcl, and not the other lisps, just cut your initialization code down to this:
(add-to-list 'load-path "/opt/local/share/emacs/site-lisp/slime")
(require 'slime-autoloads)
(setq slime-lisp-implementations `((sbcl ("/opt/local/bin/sbcl")))
(add-hook 'lisp-mode-hook
(lambda () (cond ((not (featurep 'slime)) (require 'slime) (normal-mode)))))
(eval-after-load "slime" '(slime-setup '(slime-fancy slime-banner)))
After that, use M-x slime, and you should be good to go.