Auto-Complete with Emacs 24 doesn't work with Java, C or C++ modes - emacs

I installed auto-complete using the marmalade repo. Everything installed correctly and after moving stuff around I managed to start up and run auto-correct without any errors with the following code in my init.el:
;; auto-complete
(add-to-list 'load-path "~/.emacs.d/elpa/auto-complete")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/elpa/auto-complete/dict")
(ac-config-default)
Now I can use auto-complete with no hick-ups with Emacs Lisp but whenever I use any other mode, like, Java, C, or C++ it doesn't work at all.
I have yasnippet installed too (it works perfectly), not sure if that might have anything to do with it. Here's the relevant code in my init.el:
;;yasnippet
(add-to-list 'load-path
"~/.emacs.d/plugins/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)
I am in the process of learning Emacs and currently I'm still a noob. I've been looking all over the documentation and SO but haven't found anything. I'd really appreciate any help whatsoever on this.

You may need to add completion sources. Here's what's in my config:
(set-default 'ac-sources
'(ac-source-abbrev
ac-source-dictionary
ac-source-yasnippet
ac-source-words-in-buffer
ac-source-words-in-same-mode-buffers
ac-source-semantic))
Update: ac-config-default should cover this, but if autocomplete isn't activating for those modes, try putting the following in your init.el:
(dolist (m '(c-mode c++-mode java-mode))
(add-to-list 'ac-modes m))
(global-auto-complete-mode t)
Update2: I've posted a gist that adapts your init.el to pull autocomplete using package-install.
I can't tell what version of auto-complete you were referencing, but the latest is working fine for me.

I have exact same issue as you. Emacs-Lisp works perfect with auto-complete but C, C++ doesn't work. After trying with various combination, I find out that commenting out yasnippet from .emacs solve my issue. Hope this could help you. My auto-complete version is 1.3.1.

Related

How to turn on evil mode on emacs startup

I've been using nvim for a while and recently thought about checking emacs out after learning about evil mode. I made init.el in .config/emacs, installed evil mode and figured i would try to enable it whenever i start up emacs.
So i wrote this bit of code in init.el:
(defun evil-mode-on ()
(require evil)
(evil-mode 1))
(add-hook 'after-init-hook 'evil-mode-on)
But unfortunately it doesn't seem to work and i'm not sure what i'm doing wrong. Any help would be very much appreciated and thanks in advance.
You seems to be missing apostrophe(') in require. It should be (require 'evil)
Enabling evil mode at startup could be as simple as specifying
(require 'evil)
(evil-mode 1)
in your init.el file as long as package is already installed and/loaded.
Github page has in detailed instruction to install it automatically with the help of use-package.

how to open ede projects after closing emacs

I've tried to find an answer to this specific question but had no luck. Or maybe I'm simply asking the wrong question.
To keep it simple: I follow the emacs' EDE Quick Start guide. Everything flows just fine and I get the expected results.
The problem arises when i close emacs and try to open the project again.
At that point I get the infamous "Corrupt object on disk" error.
I see it can be used another kind of project (ede-cpp-root-project) but it lacks all basic functionalities that should be hand-made, but that's not what I'm interested in. I would like to use ede-proj-project.
I'm interested in understanding why this happens. Why I can't open a project that worked just fine before closing emacs? What's changed just by closing emacs?
Am I missing something?
FYI: If it is useful information, I'm using emacs version 25.3.1 but I've tried few other earlier versions with the same result.
PS: As you can probably tell, I'm not really skilled so, please, forgive me if it is an annoying question.
I had the same problem.
Copy this into your .emacs startup configuration file
(require 'cedet)
(require 'eieio)
(require 'eieio-speedbar)
(require 'eieio-opt)
(require 'eieio-base)
(require 'ede/source)
(require 'ede/base)
(require 'ede/auto)
(require 'ede/proj)
(require 'ede/proj-archive)
(require 'ede/proj-aux)
(require 'ede/proj-comp)
(require 'ede/proj-elisp)
(require 'ede/proj-info)
(require 'ede/proj-misc)
(require 'ede/proj-obj)
(require 'ede/proj-prog)
(require 'ede/proj-scheme)
(require 'ede/proj-shared)
I found the solution here:
https://emacs.stackexchange.com/questions/17950/ede-load-project
which lead to CEDE project:
https://www.emacswiki.org/emacs/CEDET_Quickstart
It worked for me. - GNU Emacs 25.2.2

Built-in Evil mode for Emacs 24

I've read in a lot of places such as the WikEmacs (http://wikemacs.org/wiki/Evil) that Emacs24 already came with support for Evil mode, no need to install it via el-get. But I can't seem to understand how do I activate it.
I tried just adding the
(require 'evil)
(evil-mode 1)
lines to my .emacs but it can't seem to work, how do you guys use the built-in evil mode on emacs24? without cloning git repositories, etc.
The statement on WikEmacs is false; evil-mode is not included in Emacs 24. (As it's a wiki, I just edited the page and removed that text.)
There are many ways to install evil-mode. I'd suggest activating the MELPA package repository by adding the following to your .emacs file:
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
Then type M-x list-packages, find evil in the list, and install it.

auto-complete-mode not working

I just followed this site to install auto-complete on Emacs. I installed it with "M-x load-file RETURN ~/path/to/etc/install.el".
The output of my installation was: http://paste.ubuntu.com/6184523/
After that, I added the recommended code to my ~/.emacs file and restarted Emacs. Typing "M-x auto-complete-mode" says "No match". I also tried to fix it by replacing flet with c-flet etc. but it hasn't changed anything too.
Version: GNU Emacs 24.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.8.2)
Emacs has a package manager now. So just install the package from the list and you're done.
Here's the configuration that adds the two most popular repositories:
(package-initialize)
(add-to-list
'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list
'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/"))
After this, M-x package-list-packages. The rest is pretty intuitive.
UPD: A simple auto-complete setup for C++
(add-hook 'c++-mode-hook
(lambda()
(semantic-mode 1)
(define-key c++-mode-map (kbd "C-z") 'c++-auto-complete)))
(defun c++-auto-complete ()
(interactive)
(let ((ac-sources
`(ac-source-semantic
,#ac-sources)))
(auto-complete)))
I tried some solutions that worked for other people, but it didn't quite work out.
Try setting the environment variable(s) to ~/emacs.d/ in both .profile and .bashrc
If that doesn't work out, try exporting the environment variable(s) with su root (won't work with sudo).
At least that worked for me while trying to install auto-complete-mode with golangs auto-complete-mode

Emacs load-path scala-mode

I am trying to install ENSIME for emacs. On the first step, when I integrate the ./misc/scala-tool-support/emacs .elc files, the instructions say to
(add-to-list 'load-path "/path/to/some/directory/scala-mode")
Because of the way the directory is structured (where there is no dir scala-mode but all of the .el files are called scala-mode), I am unsure what this exactly specifies. I originally thought it jsut meant to do something like:
(add-to-list 'load-path "~/...../misc/scala-tool-support/emacs/"), but reading further down to the following made me rethink my assumption.
(setq yas/my-directory "/path/to/some/directory/scala-mode/contrib/yasnippet/snippets")
(yas/load-directory yas/my-directory)
Can someone clarify this please?
Thanks much.
The yas/load-directory call has nothing to do with your load-path. Yes, you had it right originally. Is this not working? If so, what error message do you get?
Here is my setup for scala-mode and ensime on Emacs. I'm on OS X.
In the vendor/scala directory, it's just all the .el files from the compiler distribution.
And ensime/dist is bin/ elisp/ and lib/ directories from a github download.
;; Scala Mode
(add-to-list 'load-path "/Users/you/.emacs.d/vendor/scala")
(require 'scala-mode-auto)
(add-to-list 'auto-mode-alist '("\\.scala$" . scala-mode))
(add-to-list 'load-path "/path/to/ensime/dist")
(require 'ensime)
(add-hook 'scala-mode-hook 'ensime-scala-mode-hook)
I've checked the scala-tool-support repo, all of the scala-related snippets for had been included in Yasnippet now. If we use the Yasnippet release version newer than 0.5.7 , the snippets for scala-mode should be included in /path/to/yasnippet/text-mode/scala-mode, so we don't need to set yas/load-directory by ourselves.