configfiles/emacs/.emacs

135 lines
4.4 KiB
Text
Raw Normal View History

2017-05-15 01:35:31 +02:00
(package-initialize)
2017-05-15 14:25:35 +02:00
(defun ensure-packages-installed (packages)
"Ensure packages are installed"
(mapcar
(lambda (package)
(if (package-installed-p package)
nil
(if (y-or-n-p (format "Package %s is missing. Install it? " package))
(package-install package)
package)))
packages))
2017-05-15 01:35:31 +02:00
(require 'package)
(push '("marmalade" . "http://marmalade-repo.org/packages/") package-archives)
(push '("melpa" . "http://melpa.milkbox.net/packages/") package-archives)
(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.
'(ansi-color-faces-vector
[default default default italic underline success warning error])
2017-05-16 19:24:48 +02:00
'(ansi-color-names-vector
["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"])
2017-05-15 01:35:31 +02:00
'(blink-cursor-mode nil)
2017-05-16 19:24:48 +02:00
'(custom-enabled-themes (quote (heroku)))
'(custom-safe-themes
(quote
("4f2ede02b3324c2f788f4e0bad77f7ebc1874eff7971d2a2c9b9724a50fb3f65" default)))
2017-05-15 01:35:31 +02:00
'(global-evil-surround-mode t)
'(inhibit-startup-screen t)
'(menu-bar-mode nil)
'(package-selected-packages
(quote
2017-05-16 08:12:04 +02:00
(yasnippet evil-surround org evil-magit magit makefile-runner evil)))
2017-05-15 01:35:31 +02:00
'(scroll-bar-mode nil)
'(tool-bar-mode nil))
(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.
'(default ((t (:inherit nil :stipple nil :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 113 :width normal :foundry "PfEd" :family "Inconsolata")))))
2017-05-15 14:25:35 +02:00
;; ensure repo cache is up1date
(or (file-exists-p package-user-dir)
(package-refresh-contents))
2017-05-16 19:24:48 +02:00
;; Install packages
(ensure-packages-installed '(org evil evil-surround magit evil-magit auto-complete yasnippet))
;; tabbing
(setq-default indent-tabs-mode t)
(setq-default tab-width 4)
2017-05-15 14:25:35 +02:00
2017-05-15 18:22:09 +02:00
;; Evil mode <3
2017-05-15 01:35:31 +02:00
(require 'evil)
(evil-mode t)
2017-05-15 14:25:35 +02:00
2017-05-15 18:22:09 +02:00
;; auto-complete
(require 'auto-complete)
(require 'auto-complete-config)
(ac-config-default)
2017-05-16 08:12:04 +02:00
;; Yasnippet
(require 'yasnippet)
(yas-global-mode 1)
2017-05-15 14:25:35 +02:00
;; Window movement
(global-set-key (kbd "C-x <up>") 'windmove-up)
(global-set-key (kbd "C-x <down>") 'windmove-down)
(global-set-key (kbd "C-x <left>") 'windmove-left)
(global-set-key (kbd "C-x <right>") 'windmove-right)
2017-05-15 18:22:09 +02:00
;; Magit
(global-set-key (kbd "C-x g") 'magit-status)
2017-05-15 14:25:35 +02:00
;; Window cycling
(defun cycle-window ()
"cycles windows"
(interactive)
(select-window (next-window)))
(global-set-key (kbd "<C-tab>") 'cycle-window)
2017-05-15 18:22:09 +02:00
;; Easy terminal
(defun term-split ()
"creates terminal window below"
(interactive)
2017-05-16 08:12:04 +02:00
(let ((window (split-window-below -7)))
2017-05-16 00:48:57 +02:00
(select-window window)
2017-05-16 08:12:04 +02:00
(term "/bin/zsh")))
;(set-window-dedicated-p window t)))
2017-05-15 18:22:09 +02:00
(global-set-key (kbd "C-x t") 'term-split)
;; Kill term buffer on exit
2017-05-16 00:48:57 +02:00
;(defun term-handle-exit--close-buffer (&rest args)
; (when (null (get-buffer-process (current-buffer)))
; (progn
; (let (window (get-buffer-window (current-buffer))
; (when (window-dedicated-p ))
; (kill-buffer (current-buffer))
; Fix...
; (advice-add 'term-handle-exit :after #'term-handle-exit--close-buffer)
; Latex german
(defun evil-is-insert () (string= evil-state "insert"))
(defun latex-german-umlauts ()
"Sets keys like ä to write \"a"
(message "Latex German Umlauts loaded.")
(local-set-key (kbd "ä") (lambda () (interactive) (when (evil-is-insert) (insert "\"a"))))
(local-set-key (kbd "ö") (lambda () (interactive) (when (evil-is-insert) (insert "\"o"))))
(local-set-key (kbd "ü") (lambda () (interactive) (when (evil-is-insert) (insert "\"u"))))
(local-set-key (kbd "Ä") (lambda () (interactive) (when (evil-is-insert) (insert "\"A"))))
(local-set-key (kbd "Ö") (lambda () (interactive) (when (evil-is-insert) (insert "\"O"))))
(local-set-key (kbd "Ü") (lambda () (interactive) (when (evil-is-insert) (insert "\"U"))))
(local-set-key (kbd "ß") (lambda () (interactive) (when (evil-is-insert) (insert "\"s")))))
(add-hook 'latex-mode-hook 'latex-german-umlauts)
2017-05-15 18:22:09 +02:00
;; Split windows horizontally preferred
(setq split-height-threshold 6)
(setq split-width-threshold 20)
2017-05-15 14:25:35 +02:00
;; Overlay windows
(add-to-list 'display-buffer-alist
'("*Apropos*" display-buffer-same-window))
(add-to-list 'display-buffer-alist
'("*Help*" display-buffer-same-window))