Skip to content

Instantly share code, notes, and snippets.

@dmitriid
Last active February 9, 2016 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmitriid/4078311 to your computer and use it in GitHub Desktop.
Save dmitriid/4078311 to your computer and use it in GitHub Desktop.
My init.el
;;==============================================================================
;; additional packages
;;==============================================================================
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(add-to-list 'package-archives
'("marmalade" .
"http://marmalade-repo.org/packages/"))
(package-initialize)
;;==============================================================================
;; packages required for settings below
;;==============================================================================
;; M-x package-install
;; revive
;; zenburn-theme
;; rainbow-delimiters
;; whole-line-or-region
;; fill-column-indicator
;; volatile-highlights
;; browse-kill-ring
;; ag
;; magit
;; undo-tree
;; jabber
;; column-marker
;; rainbow-delimiter-mode
;; alchemist
;; helm
;;==============================================================================
;; company mode
;;==============================================================================
(require 'company)
(add-hook 'after-init-hook 'global-company-mode)
;;==============================================================================
;; frame/window management customizations
;;==============================================================================
(windmove-default-keybindings 'super)
;;==============================================================================
;; Status line customizations
;;==============================================================================
(setq column-number-mode t)
(setq line-number-mode t)
;;==============================================================================
;; Tabs vs. spaces!
;;==============================================================================
(setq-default indent-tabs-mode nil)
(setq standard-indent 2)
(global-whitespace-mode t)
(setq default-tab-width 2)
;;==============================================================================
;; Editor width
;;==============================================================================
(setq-default fill-column 80)
;;-----------------------------------------------------------------------------
;; Right column indicator
;;-----------------------------------------------------------------------------
(require 'fill-column-indicator)
(setq fci-rule-width 1)
(setq fci-rule-column 81)
(setq fci-rule-color "#383838")
(define-globalized-minor-mode global-fci-mode fci-mode (lambda () (fci-mode 1)))
(global-fci-mode 1)
;;-----------------------------------------------------------------------------
;; Right column marker, see erlang-mode hook below
;;-----------------------------------------------------------------------------
(require 'column-marker)
;;==============================================================================
;; backup, versioning, reverting
;;==============================================================================
(require 'revive)
(define-key ctl-x-map "S" 'save-current-configuration)
(define-key ctl-x-map "F" 'resume)
(define-key ctl-x-map "K" 'wipe)
(setq make-backup-files t)
(setq version-control t)
(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))
(setq delete-old-versions t)
(setq emacs-stuff-dir "~/.emacs-stuff/")
;;-----------------------------------------------------------------------------
;; saveplace remembers your location in a file when saving files
;;-----------------------------------------------------------------------------
(setq save-place-file (concat emacs-stuff-dir "saveplace"))
;;-----------------------------------------------------------------------------
;; activate it for all buffers
;;-----------------------------------------------------------------------------
(setq-default save-place t)
(require 'saveplace)
;;-----------------------------------------------------------------------------
;; revert buffers automatically when underlying files are changed externally
;;-----------------------------------------------------------------------------
(global-auto-revert-mode t)
;;-----------------------------------------------------------------------------
;; savehist keeps track of some history
;;-----------------------------------------------------------------------------
(setq savehist-additional-variables
;; search entries
'(search ring regexp-search-ring)
;; save every minute
savehist-autosave-interval 60
;; keep the home clean
savehist-file (concat emacs-stuff-dir "savehist"))
(savehist-mode t)
;;-----------------------------------------------------------------------------
;; suggested by kvakvs
;;-----------------------------------------------------------------------------
(defun revert-all-buffers ()
"Refreshes all open buffers from their respective files"
(interactive)
(let* ((list (buffer-list))
(buffer (car list)))
(while buffer
(when (and (buffer-file-name buffer)
(not (buffer-modified-p buffer)))
(set-buffer buffer)
(revert-buffer t t t))
(setq list (cdr list))
(setq buffer (car list))))
(message "Refreshed open files"))
;;==============================================================================
;; helm
;;==============================================================================
(require 'helm-config)
(global-set-key (kbd "M-x") 'helm-M-x)
(setq helm-M-x-fuzzy-match t)
(setq helm-recentf t)
(setq helm-buffers-list t)
(setq helm-candidate-number-limit 100)
(helm-autoresize-mode 1)
(global-set-key (kbd "C-x C-f") 'helm-find-files)
;;==============================================================================
;; theming and other visual niceties
;;==============================================================================
(load-theme 'zenburn t)
(set-face-attribute 'default nil :font "Monaco" :height 100)
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
(rainbow-delimiters-mode t)
;;-----------------------------------------------------------------------------
;; window chrome
;;-----------------------------------------------------------------------------
(scroll-bar-mode 0) ;; removes unnecessary scrollbars
;;-----------------------------------------------------------------------------
;; meaningful names for buffers with the same name
;;-----------------------------------------------------------------------------
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
(setq uniquify-separator "/")
(setq uniquify-after-kill-buffer-p t) ; rename after killing uniquified
(setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers
;;-----------------------------------------------------------------------------
;; the toolbar is just a waste of valuable screen estate
;; in a tty tool-bar-mode does not properly auto-load, and is
;; already disabled anyway
;;-----------------------------------------------------------------------------
(when (fboundp 'tool-bar-mode)
(tool-bar-mode -1))
;;-----------------------------------------------------------------------------
;; the blinking cursor is nothing, but an annoyance
;;-----------------------------------------------------------------------------
(blink-cursor-mode -1)
;;-----------------------------------------------------------------------------
;; disable startup screen
;;-----------------------------------------------------------------------------
(setq inhibit-startup-screen t)
;;-----------------------------------------------------------------------------
;; nice scrolling
;;-----------------------------------------------------------------------------
(setq scroll-margin 0
scroll-conservatively 100000
scroll-preserve-screen-position 1)
;;-----------------------------------------------------------------------------
;; more useful frame title, that show either a file or a
;; buffer name (if the buffer isn't visiting a file)
;;-----------------------------------------------------------------------------
(setq frame-title-format
'("" (:eval (if (buffer-file-name)
(abbreviate-file-name (buffer-file-name))
"%b"))))
;;==============================================================================
;; editing assistance
;;==============================================================================
(whole-line-or-region-mode t)
;;-----------------------------------------------------------------------------
;; delete the selection with a keypress
;;-----------------------------------------------------------------------------
(delete-selection-mode t)
;;-----------------------------------------------------------------------------
;; show-paren-mode: subtle highlighting of matching parens (global-mode)
;;-----------------------------------------------------------------------------
(show-paren-mode +1)
(setq show-paren-style 'parenthesis)
(require 'paren)
(set-face-background 'show-paren-match-face "#5A7CC2")
(set-face-foreground 'show-paren-match-face (face-foreground 'default))
(set-face-attribute 'show-paren-match-face nil :weight 'extra-bold)
;;-----------------------------------------------------------------------------
;; highlight the current line
;;-----------------------------------------------------------------------------
(global-hl-line-mode +1)
(require 'volatile-highlights)
(volatile-highlights-mode t)
;;-----------------------------------------------------------------------------
;; Kill ring
;;-----------------------------------------------------------------------------
(require 'browse-kill-ring)
(browse-kill-ring-default-keybindings)
;;-----------------------------------------------------------------------------
;; Undo tree
;;-----------------------------------------------------------------------------
(require 'undo-tree)
(global-undo-tree-mode)
;;==============================================================================
;; search
;;==============================================================================
;;-----------------------------------------------------------------------------
;; Silver Searcher
;;-----------------------------------------------------------------------------
(require 'ag)
(global-set-key (kbd "<f5>") 'ag-project-at-point)
;;==============================================================================
;; magit
;;==============================================================================
(global-set-key (kbd "<f6>") 'magit-status)
;;==============================================================================
;; Jabber
;;==============================================================================
(require 'jabber)
(define-key jabber-chat-mode-map [C-return] 'newline)
(define-key jabber-chat-mode-map (kbd "RET") 'jabber-chat-buffer-send)
(add-hook 'jabber-chat-mode-hook 'goto-address)
;;==============================================================================
;; nxml-mode
;;==============================================================================
;;-----------------------------------------------------------------------------
;; this lets nxml mode fold regions for any xml entity
;;-----------------------------------------------------------------------------
(add-to-list 'hs-special-modes-alist
'(nxml-mode
"<!--\\|<[^/>]*[^/]>" ;; regexp for start block
"-->\\|</[^/>]*[^/]>" ;; regexp for end block
"<!--" ;; regexp for comment start. (need this??)
sgml-skip-tag-forward
nil))
;;==============================================================================
;; Erlang
;;==============================================================================
(add-to-list 'load-path "/Users/dmitrii.dimandt/git/klarna/OTP/install/R14B03/lib/erlang/lib/tools-2.6.6.4/emacs")
(setq erlang-root-dir "/Users/dmitrii.dimandt/git/klarna/OTP/install/R14B03/")
(setq exec-path (cons "/Users/dmitrii.dimandt/git/klarna/OTP/install/R14B03/" exec-path))
(require 'erlang-start)
(add-to-list 'load-path "/Users/dmitrii.dimandt/Projects/edts/")
(require 'edts-start)
(setq erlang-indent-level 2)
;;-----------------------------------------------------------------------------
;; Suggested by defacedvr
;;-----------------------------------------------------------------------------
(defun my-erlang-mode-hook ()
(lambda()
(local-set-key [return] 'newline-and-indent)
)
)
;;(add-hook 'erlang-mode-hook 'my-erlang-mode-hook)
(add-hook 'erlang-mode-hook 'fci-mode)
(add-hook 'edts-mode-hook 'my-erlang-mode-hook)
(setq edts-projects
'(((name . "kred-emacs")
(node-sname . "kred-emacs")
(root . "~/git/klarna/dev")
(otp-path . "~/git/klarna/OTP/install/R14B03")
(lib-dirs . ("lib" "test")))))
(global-set-key (kbd "s-r") 'edts-ahs-edit-current-function)
;;-----------------------------------------------------------------------------
;; 80-column rule!
;;-----------------------------------------------------------------------------
(add-hook 'prog-mode-hook (lambda () (interactive) (column-marker-1 80)))
;;==============================================================================
;; Elixir
;;==============================================================================
(require 'alchemist)
(setq alchemist-mix-command "/usr/local/bin/mix")
(setq alchemist-iex-program-name "/usr/local/bin/iex")
(setq alchemist-execute-command "/usr/local/bin/elixir")
(setq alchemist-compile-command "/usr/local/bin/elixirc")
;;==============================================================================
;; Miscellaneous
;;==============================================================================
;;-----------------------------------------------------------------------------
;; enable y/n answers
;;-----------------------------------------------------------------------------
(fset 'yes-or-no-p 'y-or-n-p)
;;-----------------------------------------------------------------------------
;; Force Emacs to use the same PATH as the shell
;; http://stackoverflow.com/questions/6411121/how-to-make-emacs-to-use-my-bashrc-file
;;-----------------------------------------------------------------------------
(defun set-exec-path-from-shell-PATH ()
(let ((path-from-shell (replace-regexp-in-string
"[ \t\n]*$"
""
(shell-command-to-string "$SHELL --login -i -c 'echo $PATH'"))))
(setenv "PATH" path-from-shell)
(setq eshell-path-env path-from-shell) ; for eshell users
(setq exec-path (split-string path-from-shell path-separator))))
(if window-system (set-exec-path-from-shell-PATH))
;;==============================================================================
;; Custom variables set through menus/configuration dialogs etc.
;;==============================================================================
(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.
'(jabber-account-list (quote (("dmitrii@dmitriid.com"))))
'(jabber-alert-presence-hooks nil)
'(jabber-auto-reconnect t)
'(jabber-muc-autojoin (quote ("erlang@conference.jabber.ru" "erlang-talks@conference.jabber.ru")))
'(safe-local-variable-values (quote ((allout-layout . t))))
'(whitespace-line-column 80)
'(whitespace-style (quote (face tabs spaces trailing space-before-tab newline indentation empty space-after-tab space-mark tab-mark newline-mark))))
;;==============================================================================
;; Fira Code
;; https://github.com/tonsky/FiraCode/wiki/Setting-up-Emacs
;;==============================================================================
(when (window-system)
(set-default-font "Fira Code"))
(let ((alist '((33 . ".\\(?:\\(?:==\\)\\|[!=]\\)")
(35 . ".\\(?:[(?[_{]\\)")
(38 . ".\\(?:\\(?:&&\\)\\|&\\)")
(42 . ".\\(?:\\(?:\\*\\*\\)\\|[*/]\\)")
(43 . ".\\(?:\\(?:\\+\\+\\)\\|\\+\\)")
(45 . ".\\(?:\\(?:-[>-]\\|<<\\|>>\\)\\|[<>}~-]\\)")
(46 . ".\\(?:\\(?:\\.[.<]\\)\\|[.=]\\)")
(47 . ".\\(?:\\(?:\\*\\*\\|//\\|==\\)\\|[*/=>]\\)")
(58 . ".\\(?:[:=]\\)")
(59 . ".\\(?:;\\)")
(60 . ".\\(?:\\(?:!--\\)\\|\\(?:\\$>\\|\\*>\\|\\+>\\|--\\|<[<=-]\\|=[<=>]\\||>\\)\\|[/<=>|-]\\)")
(61 . ".\\(?:\\(?:/=\\|:=\\|<<\\|=[=>]\\|>>\\)\\|[<=>~]\\)")
(62 . ".\\(?:\\(?:=>\\|>[=>-]\\)\\|[=>-]\\)")
(63 . ".\\(?:[:=?]\\)")
(92 . ".\\(?:\\(?:\\\\\\\\\\)\\|\\\\\\)")
(94 . ".\\(?:=\\)")
(123 . ".\\(?:-\\)")
(124 . ".\\(?:\\(?:|[=|]\\)\\|[=>|]\\)")
(126 . ".\\(?:[=@~-]\\)")
)
))
(dolist (char-regexp alist)
(set-char-table-range composition-function-table (car char-regexp)
`([,(cdr char-regexp) 0 font-shape-gstring]))))
(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.
'(column-marker-1 ((t (:background "#FF0000"))))
'(highlight ((t (:background "#383838"))))
'(idle-highlight ((t (:background "gray40"))))
'(isearch ((t (:background "red" :foreground "#f0dfaf"))))
'(jabber-activity-face ((t (:foreground "#dca3a3" :weight normal))))
'(jabber-chat-prompt-foreign ((t (:foreground "#dca3a3" :weight normal))))
'(jabber-chat-prompt-system ((t (:foreground "green" :weight normal))))
'(lazy-highlight ((t (:background "#dfaf8f" :foreground "#2b2b2b"))))
'(linum ((t (:inherit (shadow default) :background "#3f3f3f" :foreground "gray10"))))
'(match ((t (:background "#2b2b2b" :foreground "#dfaf8f" :weight bold))))
'(mode-line ((t (:background "gray12" :foreground "#8fb28f" :box (:line-width -1 :style released-button)))))
'(secondary-selection ((t (:background "#5f5f5f"))))
'(whitespace-line ((t nil)))
'(whitespace-newline ((t (:background "gray23" :foreground "#4f4f4f" :weight normal))))
'(whitespace-space ((t (:background "gray23" :foreground "#4f4f4f"))))
'(whitespace-tab ((t (:background "#cc9393" :foreground "#cc9393"))))
'(whitespace-trailing ((t (:background "red" :foreground "#cc9393" :weight bold)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment