Skip to content

Instantly share code, notes, and snippets.

@hreeder
Created April 17, 2015 17:46
Show Gist options
  • Save hreeder/0756634353fb7c876135 to your computer and use it in GitHub Desktop.
Save hreeder/0756634353fb7c876135 to your computer and use it in GitHub Desktop.
;;; emacs --- My Emacs Config
;;; Commentary:
;;; Mostly aquired from https://www.youtube.com/watch?v=0cZ7szFuz18
;;; Code:
(require 'package)
(package-initialize)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/"))
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/") t)
(add-to-list 'package-archives
'("org" . "http://orgmode.org/elpa/") t)
(package-refresh-contents)
(require 'neotree)
(defun install-if-needed (package)
(unless (package-installed-p package)
(package-install package)))
(setq to-install
'(python-mode
magit
yasnippet
jedi
auto-complete
autopair
find-file-in-repository
flycheck
web-mode
org))
(mapc 'install-if-needed to-install)
(require 'magit)
(global-set-key "\C-xg" 'magit-status)
(require 'auto-complete)
(require 'autopair)
(require 'yasnippet)
(require 'flycheck)
(global-flycheck-mode t)
(global-set-key [f7] 'find-file-in-repository)
(global-set-key [f8] 'neotree-toggle)
(setq
ac-auto-start 2
ac-override-local-map nil
ac-use-menu-map t
ac-candidate-limit 20)
(require 'python-mode)
(add-to-list 'auto-mode-alist '("\\.py$" . python-mode))
(setq py-electric-colon-active t)
(add-hook 'python-mode-hook 'autopair-mode)
(add-hook 'python-mode-hook 'yas-minor-mode)
(require 'jedi)
(add-hook 'python-mode-hook
(lambda ()
(jedi:setup)
(jedi:ac-setup)
(local-set-key "\C-cd" 'jedi:show-doc)
(local-set-key (kbd "M-SPC") 'jedi:complete)
(local-set-key (kbd "M-.") 'jedi:goto-definition)))
(defun flymake-python-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 "epylint2" (list local-file))))
(defun flymake-activate ()
"Activates flymake when real buffer and you have write access."
(if (and
(buffer-file-name)
(file-writable-p buffer-file-name))
(progn
(flymake-mode t)
(local-set-key (kbd "C-c n") 'flymake-goto-prev-error)
(local-set-key (kbd "C-c p") 'flymake-goto-prev-error))))
(defun ca-flymake-show-help ()
(when (get-char-property (point) 'flymake-overlay)
(let ((help (get-char-property (point) 'help-echo)))
(if help (message "%s" help)))))
(add-hook 'post-command-hook 'ca-flymake-show-help)
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-python-init))
(add-hook 'python-mode-hook 'flymake-activate)
(add-hook 'python-mode-hook 'auto-complete-mode)
(ido-mode t)
(windmove-default-keybindings 'shift)
(show-paren-mode t)
(setq visible-bell nil)
(setq magit-last-seen-setup-instructions "1.4.0")
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(setq web-mode-enable-engine-detection t)
;;; .emacs ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment