Skip to content

Instantly share code, notes, and snippets.

@ahoka ahoka/.emacs.el
Last active Mar 13, 2017

Embed
What would you like to do?
;;
;; .emacs file for c, c++, python development
;; Adam Hoka, 2016
;;
(require 'package)
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")))
(package-initialize)
;; install use package
;;
(when (not (package-installed-p 'use-package))
(progn
(package-refresh-contents)
(package-install 'use-package)))
(require 'use-package)
;; configure emacs defaults
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(setq backup-inhibited t)
(when (not window-system)
(menu-bar-mode -1))
(when (window-system)
(setq mouse-yank-at-point t))
(setq inhibit-splash-screen t)
(setq c-default-style "ellemtel")
(setq backup-inhibited t)
(setq-default indent-tabs-mode nil)
(show-paren-mode 1)
(load-theme 'wombat)
(require 'uniquify)
(global-set-key (kbd "C-x C-b") 'ibuffer)
(autoload 'ibuffer "ibuffer" "List buffers." t)
(global-set-key "\M-/" 'hippie-expand)
(semantic-mode 1)
(global-semantic-stickyfunc-mode)
(add-to-list 'auto-mode-alist '("\\.gmk\\'" . makefile-mode))
(when (window-system)
(use-package powerline
:ensure powerline
:config (powerline-default-theme)))
(use-package cmake-mode
:ensure cmake-mode)
(if (window-system)
(use-package git-gutter-fringe
:ensure git-gutter-fringe
:config (global-git-gutter-mode))
(use-package git-gutter
:ensure git-gutter
:config (global-git-gutter-mode)))
(use-package sr-speedbar
:ensure sr-speedbar
:config (setq speedbar-use-images nil)
(make-face 'speedbar-face)
(set-face-font 'speedbar-face "Monaco-8")
(setq speedbar-mode-hook '(lambda () (buffer-face-set 'speedbar-face)))
(tool-bar-add-item "diropen" 'sr-speedbar-toggle
'sr-speedbar-toggle-fun
:help "Toggle speed bar"))
(use-package gist
:ensure gist)
(use-package jedi
:ensure jedi
:config (add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:complete-on-dot t)
(setq python-environment-virtualenv
(append python-environment-virtualenv
'("--python" "/usr/bin/python3"))))
(use-package flycheck
:ensure flycheck
:ensure flycheck-pos-tip
:config (global-flycheck-mode 1)
;(add-hook 'flycheck-mode-hook '(flycheck-pos-tip-mode))
(setq flycheck-python-pylint-executable "pylint3")
(add-hook 'c++-mode-hook (lambda () (setq flycheck-gcc-language-standard "c++14")))
(add-hook 'c++-mode-hook (lambda () (setq flycheck-clang-language-standard "c++14"))))
(use-package emmet-mode
:ensure emmet-mode
:config (add-hook 'sgml-mode-hook 'emmet-mode)
(add-hook 'xml-mode-hook 'emmet-mode))
(use-package comment-dwim-2
:ensure comment-dwim-2
:config (global-set-key (kbd "M-;") 'comment-dwim-2))
(defun c-include-guard ()
"Insert C header include guards."
(interactive)
(let (original-point macro-name)
(set 'original-point (point))
(set 'macro-name
(upcase
(replace-regexp-in-string
"\\."
"_"
(file-name-nondirectory
buffer-file-name))))
(goto-char (point-min))
(insert
(concat "#ifndef " macro-name "\n#define " macro-name "\n\n"))
(set 'original-point (- (+ (point) original-point) 1))
(goto-char (point-max))
(insert "\n#endif\n")
(goto-char original-point)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.