Last active
December 12, 2015 03:08
-
-
Save chrisbarrett/4704610 to your computer and use it in GitHub Desktop.
In response to: http://stackoverflow.com/questions/14676802/auto-complete-with-emacs-24-doesnt-work-with-java-c-or-c-modes/14677270#comment20521862_14677270
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Initialize packages. | |
(require 'package) | |
(dolist (source '(("melpa" . "http://melpa.milkbox.net/packages/") | |
("marmalade" . "http://marmalade-repo.org/packages/"))) | |
(add-to-list 'package-archives source)) | |
(package-initialize) | |
(unless package-archive-contents | |
(package-refresh-contents)) | |
(defun require-package (p) | |
(unless (package-installed-p p) | |
(package-install p)) | |
(require p)) | |
(require-package 'auto-complete) | |
(require-package 'yasnippet) | |
;; ------------------------------------------------------------------------------ | |
;; Themeing | |
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/") | |
(load-theme 'Nico t) | |
(set-face-attribute 'default nil :font "DejaVu Sans Mono-11") | |
;; Default windows size | |
(add-to-list 'default-frame-alist '(height . 24)) | |
(add-to-list 'default-frame-alist '(width . 80)) | |
(global-linum-mode t) | |
(setq-default inhibit-startup-screen t) | |
(setq-default initial-scratch-message nil) | |
(show-paren-mode 1) | |
(setq ring-bell-function 'ignore) | |
(setq-default c-basic-offset 4) | |
;; ido-mode | |
(setq ido-enable-flex-matching t) | |
(setq ido-everywhere t) | |
(ido-mode 1) | |
;; yes or no becomes y or n | |
(defalias 'yes-or-no-p 'y-or-n-p) | |
;;yasnippet | |
(yas-global-mode 1) | |
;; auto-complete | |
(require 'auto-complete-config) | |
(add-to-list 'ac-dictionary-directories "~/.emacs.d/elpa/auto-complete/dict") | |
(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)) | |
(ac-config-default) | |
(dolist (m '(c-mode c++-mode java-mode)) | |
(add-to-list 'ac-modes m)) | |
(global-auto-complete-mode t) |
Very cool. Thanks for the tips.
I'm not sure how you got this to work but (ac-config-default)
calls (set-default 'ac-sources...)
so if you call it after your set-default
it clobbers the value you just set.
Cool :)
Works great!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: this fetches yasnippet and auto-complete from the package repositories.