Skip to content

Instantly share code, notes, and snippets.

@voldyman
Last active August 29, 2015 14:16
Show Gist options
  • Save voldyman/a287089901e4ba48b454 to your computer and use it in GitHub Desktop.
Save voldyman/a287089901e4ba48b454 to your computer and use it in GitHub Desktop.
Better .emacs file
;; No Splash Screen
(setq inhibit-splash-screen t)
;; Indentation
(setq-default indent-tabs-mode nil)
(setq indent-tab-mode nil)
(setq-default tab-width 4)
(setq c-basic-indent 2)
(global-set-key (kbd "RET") 'newline-and-indent)
;; init package system
(package-initialize)
;; Enable ido mode
(ido-mode t)
(setq ido-enable-flex-matching t)
;; delete selected text
(delete-selection-mode t)
;; use ido vertical
(ido-vertical-mode t)
;; Enable utf-8 in term mode
(set-terminal-coding-system 'utf-8-unix)
;; Enable ido mode
(ido-mode t)
(setq ido-enable-flex-matching t)
;; delete selected text
(delete-selection-mode t)
;; use ido vertical
(ido-vertical-mode t)
;; y/n is easier than yes/no
(fset 'yes-or-no-p 'y-or-n-p)
;; utf8 FTW!!
(prefer-coding-system 'utf-8)
;; highlight TODO|FIXME|BUG in comments
(add-hook 'c-mode-common-hook
(lambda ()
(font-lock-add-keywords nil
'(("\\<\\(FIXME\\|TODO\\|BUG\\):" 1 font-lock-warning-face t)))))
;; Lines and columns
(global-linum-mode 1)
(setq linum-format "%4d\u2502")
(column-number-mode 1)
;; Enabel recent files and disable backup and autosave file
(recentf-mode 1)
(setq make-backup-files nil)
(setq auto-save-default nil)
(show-paren-mode 1)
(size-indication-mode 1)
(load-theme 'sanityinc-tomorrow-eighties t)
;; Deactivate menu-bar, tool-bar and scroll-bar
;;(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
;; Fix all indentation (I love this so much)
(defun fix-indentation ()
"indent whole buffer"
(interactive)
(delete-trailing-whitespace)
(indent-region (point-min) (point-max) nil)
(untabify (point-min) (point-max)))
(defun copy-to-clipboard ()
(interactive)
(if (display-graphic-p)
(progn
(message "Yanked region to x-clipboard!")
(call-interactively 'clipboard-kill-ring-save)
)
(if (region-active-p)
(progn
(shell-command-on-region (region-beginning) (region-end) "xsel -i -b")
(message "Yanked region to clipboard!")
(deactivate-mark))
(message "No region active; can't yank to clipboard!"))))
(defun paste-from-clipboard ()
(interactive)
(if (display-graphic-p)
(progn
(clipboard-yank)
(message "graphics active"))
(insert (shell-command-to-string "xsel -o -b"))))
;; copy/paste from clipboard in emacs -nw
(global-set-key [f8] 'copy-to-clipboard)
(global-set-key [f9] 'paste-from-clipboard)
;; Some shortcuts
(global-set-key (kbd "<f12>") 'delete-trailing-whitespace)
(global-set-key (kbd "<f10>") 'fix-indentation)
;; Add ELPA package repository
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")))
;; go mode additions
(add-hook 'go-mode-hook 'go-eldoc-setup)
(setq gofmt-command "goimports")
(require 'go-mode)
(add-hook 'before-save-hook 'gofmt-before-save)
;; setup go-autocomplete
(requrie 'auto-complete)
(require 'go-autocomplete)
(require 'auto-complete-config)
(ac-config-default)
;; unique names
(require 'uniquify)
(setq uniquify-buffer-name-style 'post-forward)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes (quote ("628278136f88aa1a151bb2d6c8a86bf2b7631fbea5f0f76cba2a0079cd910f7d" default))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;; the system should also have
;; goimports go get -u github.com/bradfitz/goimports
;; gocode go get -u github.com/nsf/gocode
;; Add ELPA package repository
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")))
(defvar required-packages
'(auto-complete
go-mode go-autocomplete go-eldoc
color-theme-sanityinc-tomorrow-colors color-theme
markdown-mode popup tango-2-theme
cider idomenu
nav
vala-mode
web-mode
browser-kill-ring
anzu ;; show number of search matches
ido-vertical-mode
paredit
undo-tree-mode))
;; Installs missing packages
(defun install-missing-packages ()
"Installs required packages that are missing"
(interactive)
(mapc (lambda (package)
(unless (package-installed-p package)
(package-install package)))
required-packages)
(message "Installed all missing packages!"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment