Skip to content

Instantly share code, notes, and snippets.

Created October 2, 2012 23:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3823974 to your computer and use it in GitHub Desktop.
Save anonymous/3823974 to your computer and use it in GitHub Desktop.
My language support file
;; Intellisense (Auto-completion) config
;; Language support
;; Packages:
;; - auto-complete
;; - yasnippet
;; - matlab-mode
;;; Auto-Complete Config
;; Install from package manager.
;; (add-to-list 'load-path "~/emacs/plugins/auto-complete")
;;Supposedly makes nicer autocomplete rendering
;; (require 'pos-tip)
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/dict")
;;(global-auto-complete-mode t)
(ac-config-default)
;;Needed for compatibility with flyspell
(ac-flyspell-workaround)
(setq ac-auto-start 3)
(setq ac-auto-show-menu t)
(setq ac-quick-help-delay .3)
(ac-set-trigger-key "TAB")
;; Make \C-n and \C-p work in autocompletion menu
(setq ac-use-menu-map t)
(define-key ac-menu-map "\C-n" 'ac-next)
(define-key ac-menu-map "\C-p" 'ac-previous)
;; (require 'auto-complete)
;; (require 'auto-complete-config)
;; (add-to-list 'ac-dictionary-directories
;; "~/emacs/plugins/auto-complete/ac-dict")
;; (ac-config-default)
; CEDET Config
;;;;;;;;;;;;;;;;;;;;;;;;; TODO: Turn this into a hook based on
;major-mode. Cedet takes time. Basically each language hook will
;choose whether or not it needs cedet to be on.
;; CEDET is in prelude already, but it doesn't seem to work.. ?
(load-file "~/emacs/plugins/cedet/common/cedet.el")
;; Enable the Project management system
;; (global-ede-mode 1)
;; Enable prototype help and smart completion
;; - used with matlab
(semantic-load-enable-code-helpers)
;; Don't need this if using another template manager; in this case, YASnippet
;;(global-srecode-minor-mode 1) ; Enable template insertion menu
;; (require 'semantic-ia)
;;for c coding
;; Includes C libraries for use with semantic
;; (require 'semantic-gcc)
;; For any other source paths I might want to include and associated major-mode
;; These apply to my own modules say, if I wanted to include their docs too.
;;(semantic-add-system-include "~/path/to/source" 'c-mode)
;; Allows semantic functions to be available on demand
;; (defun my-cedet-hook ()
;; (local-set-key [(control return)] 'semantic-ia-complete-symbol)
;; (local-set-key "\C-c?" 'semantic-ia-complete-symbol-menu)
;; (local-set-key "\C-c>" 'semantic-complete-analyze-inline)
;; (local-set-key "\C-cp" 'semantic-analyze-proto-impl-toggle))
;; (add-hook 'c-mode-common-hook 'my-cedet-hook)
;; Adding support for semantic inside of autocomplete
(defun my-ac-c-mode ()
(setq ac-sources (append ac-sources '(ac-source-semantic))))
(add-hook 'c-mode-hook 'my-ac-c-mode)
;; Matlab support
(add-to-list 'load-path "~/emacs/plugins/matlab-emacs")
(load-library "matlab-load")
(matlab-cedet-setup)
(add-hook 'matlab-mode
(lambda ()
(auto-complete-mode 1)
))
;; Flymake
;; Customize how flymake displays the errors
'(flymake-errline ((((class color)) (:underline "OrangeRed"))))
'(flymake-warnline ((((class color)) (:underline "yellow"))))
(defun my-flymake-show-next-error ()
(interactive)
(flymake-goto-next-error)
(flymake-display-err-menu-for-current-line))
;; TODO: Create this function!
;; (defun flymake-makefile ()
;; "Creates default makefile with syntax checking command."
;; )
;; Flymake C hook
(add-hook 'c-mode-common-hook
(lambda ()
;; This is to prevent flymake from crying every time I
;; open a C file that isn't in a project. Set manually on demand.
;; Call makefile function here.
(flymake-mode 0)
(global-set-key "\C-c\C-v" 'my-flymake-show-next-error)))
;; Flymake Java hook
(add-hook 'java-mode
(lambda ()
;; Call makefile function here
(flymake-mode 0)
)
)
;; Java-support
(add-to-list 'load-path "~/emacs/plugins/ajc-java-complete/")
(require 'ajc-java-complete-config)
(add-hook 'java-mode-hook 'ajc-java-complete-mode)
(add-hook 'find-file-hook 'ajc-4-jsp-find-file-hook)
;;; YaSnippet Config
(require 'yasnippet)
(yas/global-mode 1)
;; Develop and keep personal snippets under ~/.emacs.d/snippets
(setq yas/root-directory "~/.emacs.d/snippets")
;; Load the snippets
(yas/load-directory yas/root-directory)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Yasnippet and autocomplete marriage
;; (defun ac-yasnippet-candidate-1 (table)
;; (let ((hashtab (yas/snippet-table-hash table))
;; (parent (yas/snippet-table-parents table))
;; candidates)
;; (maphash (lambda (key value)
;; (push key candidates))
;; hashtab)
;; (setq candidates (all-completions ac-prefix (nreverse candidates)))
;; (if parent
;; (setq candidates
;; (append candidates (ac-yasnippet-candidate-1 parent))))
;; candidates))
;; (defun ac-yasnippet-candidate ()
;; (let ((table (yas/snippet-table major-mode)))
;; (if table
;; (ac-yasnippet-candidate-1 table))))
;; (defface ac-yasnippet-candidate-face
;; '((t (:background "sandybrown" :foreground "black")))
;; "Face for yasnippet candidate.")
;; (defface ac-yasnippet-selection-face
;; '((t (:background "coral3" :foreground "white")))
;; "Face for the yasnippet selected candidate.")
;; (defvar ac-source-yasnippet
;; '((candidates . ac-yasnippet-candidate)
;; (action . yas/expand)
;; (limit . 3)
;; (candidate-face . ac-yasnippet-candidate-face)
;; (selection-face . ac-yasnippet-selection-face))
;; "Source for Yasnippet.")
;; (provide 'auto-complete-yasnippet)
;; end yasnippet and autocomplete marriage
;; LANGUAGE SUPPORT
;;;;;;;;;;;;;;;;;;;
;; C Preferences
(setq-default c-basic-offset 4)
;; Objective-C support
(add-to-list 'auto-mode-alist
'("\\.mm\\'" . (lambda ()
(objc-mode)
)))
;; Proof General (Coq-Mode)
;;(load "~/emacs/plugins/ProofGeneral-4.1/generic/proof-site.el")
;; (add-hook 'coq-mode-hook
;; (lambda ()
;; (proof-three-window-toggle t)
;; ))
;; Haskell-Mode
(load "~/emacs/plugins/haskell-mode/haskell-site-file")
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
;;(add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
;;(add-hook 'haskell-mode-hook 'turn-on-haskell-simple-indent)
;; Python
;; Most taken from http://www.saltycrane.com/blog/2010/05/my-emacs-python-environment/
(setq default-indent-tabs-mode nil) ;; use only spaces and no tabs
(setq default-tab-width 4)
;; TODO Only load these when entering python-mode
;;(add-to-list 'load-path "~/emacs/plugins/pymacs")
;;(require 'pymacs)
;;(autoload 'pymacs-apply "pymacs")
;;(autoload 'pymacs-call "pymacs")
;;(autoload 'pymacs-eval "pymacs" nil t)
;;(autoload 'pymacs-exec "pymacs" nil t)
;;(autoload 'pymacs-load "pymacs" nil t)
;; these two lines are for custom python code within the pymacs directory
;;(eval-after-load "pymacs"
;; '(add-to-list 'pymacs-load-path YOUR-PYMACS-DIRECTORY"))
;;(pymacs-load "ropemacs" "rope-") ;; use rope and ropemacs
;;(setq ropemacs-enable-autoimport t)
;; Pyflake: Need to figure this out properly; works with aquamacs not emacs
;; (require 'flymake)
;; (add-to-list 'load-path "~/emacs/plugins/flymake-cursor")
;; (add-hook 'find-file-hook 'flymake-find-file-hook)
;; (when (load "flymake" t)
;; (defun flymake-pyflakes-init ()
;; (let* ((temp-file (flymake-init-create-temp-buffer-copy
;; 'flymake-create-temp-inplace))
;; (local-file (file-relative-name
;; temp-file
;; (file-name-directory buffer-file-name))))
;; (list "pycheckers" (list local-file))))
;; (add-to-list 'flymake-allowed-file-name-masks
;; '("\\.py\\'" flymake-pyflakes-init)))
;; (load-library "flymake-cursor")
;; (global-set-key [f10] 'flymake-goto-prev-error)
;; (global-set-key [f11] 'flymake-goto-next-error)
;;end pyflake
;; HTML, Django: works, except for a deprecated call to emacs lib.
;; This should be a hook as well
;; (load "~/emacs/plugins/nxhtml/autostart.el")
;; (setq mumamo-background-colors nil)
;; (add-to-list 'auto-mode-alist '("\\.html$" . django-html-mumamo-mode))
;; Deprecated call is added to non-obsolete vars to supress the
;; warning. This will have to do until an update or more time spent on this.
(when (and (equal emacs-major-version 23)
(equal emacs-minor-version 3))
(eval-after-load "bytecomp"
'(add-to-list 'byte-compile-not-obsolete-vars
'font-lock-beginning-of-syntax-function))
;; tramp-compat.el clobbers this variable!
(eval-after-load "tramp-compat"
'(add-to-list 'byte-compile-not-obsolete-vars
'font-lock-beginning-of-syntax-function)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment