(setq custom-file "~/.emacs.custom.el") (package-initialize) (add-to-list 'load-path "~/.emacs.local/") (load "~/.emacs.rc/rc.el") (load "~/.emacs.rc/misc-rc.el") ;;; Appearance (add-to-list 'default-frame-alist `(font . "Iosevka-16")) (tool-bar-mode 0) (menu-bar-mode 0) (scroll-bar-mode 0) (column-number-mode 1) (show-paren-mode 1) (rc/require-theme 'gruber-darker) ;; (rc/require-theme 'zenburn) ;; (load-theme 'adwaita t) (rc/require 'all-the-icons 'all-the-icons-dired) (eval-after-load 'zenburn (set-face-attribute 'line-number nil :inherit 'default)) (defun toggle-window-split () (interactive) (if (= (count-windows) 2) (let* ((this-win-buffer (window-buffer)) (next-win-buffer (window-buffer (next-window))) (this-win-edges (window-edges (selected-window))) (next-win-edges (window-edges (next-window))) (this-win-2nd (not (and (<= (car this-win-edges) (car next-win-edges)) (<= (cadr this-win-edges) (cadr next-win-edges))))) (splitter (if (= (car this-win-edges) (car (window-edges (next-window)))) 'split-window-horizontally 'split-window-vertically))) (delete-other-windows) (let ((first-win (selected-window))) (funcall splitter) (if this-win-2nd (other-window 1)) (set-window-buffer (selected-window) this-win-buffer) (set-window-buffer (next-window) next-win-buffer) (select-window first-win) (if this-win-2nd (other-window 1)))))) (global-set-key (kbd "C-t") 'toggle-window-split) ;;; ido (rc/require 'smex 'ido-completing-read+) (require 'ido-completing-read+) (ido-mode 1) (ido-everywhere 1) (ido-ubiquitous-mode 1) (setq ido-auto-merge-work-directories-length -1) (global-set-key (kbd "M-x") 'smex) (global-set-key (kbd "C-c C-c M-x") 'execute-extended-command) (setq compile-command "") ;;; comment (rc/require 'comment-dwim-2) (global-set-key (kbd "C-;") 'comment-dwim-2) ;;; c-mode (setq-default c-basic-offset 4 c-default-style '((java-mode . "java") (awk-mode . "awk") (other . "bsd"))) (add-hook 'c-mode-hook (lambda () (interactive) (c-toggle-comment-style -1))) ;;; Paredit (rc/require 'paredit) (defun rc/turn-on-paredit () (interactive) (paredit-mode 1)) (add-hook 'emacs-lisp-mode-hook 'rc/turn-on-paredit) (add-hook 'clojure-mode-hook 'rc/turn-on-paredit) (add-hook 'lisp-mode-hook 'rc/turn-on-paredit) (add-hook 'common-lisp-mode-hook 'rc/turn-on-paredit) (add-hook 'scheme-mode-hook 'rc/turn-on-paredit) (add-hook 'racket-mode-hook 'rc/turn-on-paredit) ;;; Emacs lisp (add-hook 'emacs-lisp-mode-hook '(lambda () (local-set-key (kbd "C-c C-j") (quote eval-print-last-sexp)))) (add-to-list 'auto-mode-alist '("Cask" . emacs-lisp-mode)) ;;; uxntal-mode (rc/require 'uxntal-mode) ;;; Haskell mode (rc/require 'haskell-mode) (setq haskell-process-type 'cabal-new-repl) (setq haskell-process-log t) (add-hook 'haskell-mode-hook 'haskell-indent-mode) (add-hook 'haskell-mode-hook 'interactive-haskell-mode) (add-hook 'haskell-mode-hook 'haskell-doc-mode) (require 'fasm-mode) (add-to-list 'auto-mode-alist '("\\.asm\\'" . fasm-mode)) (require 'simpc-mode) ;; (add-to-list 'auto-mode-alist '("\\.[hc]\\(pp\\)?\\'" . simpc-mode)) (setq path-to-ctags "/usr/bin/ctags") (defun create-tags (dir-name) "Create tags file." (interactive "Directory: ") (shell-command (format "%s -f TAGS -e -R %s" path-to-ctags (directory-file-name dir-name))) ) (global-set-key (kbd "M-;") 'xref-find-definitions) ;;; Whitespace mode (defun rc/set-up-whitespace-handling () (interactive) (whitespace-mode 0) (add-to-list 'write-file-functions 'delete-trailing-whitespace)) (add-hook 'tuareg-mode-hook 'rc/set-up-whitespace-handling) (add-hook 'c++-mode-hook 'rc/set-up-whitespace-handling) (add-hook 'c-mode-hook 'rc/set-up-whitespace-handling) (add-hook 'simpc-mode-hook 'rc/set-up-whitespace-handling) (add-hook 'emacs-lisp-mode 'rc/set-up-whitespace-handling) (add-hook 'java-mode-hook 'rc/set-up-whitespace-handling) (add-hook 'lua-mode-hook 'rc/set-up-whitespace-handling) (add-hook 'rust-mode-hook 'rc/set-up-whitespace-handling) (add-hook 'scala-mode-hook 'rc/set-up-whitespace-handling) (add-hook 'markdown-mode-hook 'rc/set-up-whitespace-handling) (add-hook 'haskell-mode-hook 'rc/set-up-whitespace-handling) (add-hook 'python-mode-hook 'rc/set-up-whitespace-handling) (add-hook 'erlang-mode-hook 'rc/set-up-whitespace-handling) (add-hook 'asm-mode-hook 'rc/set-up-whitespace-handling) (add-hook 'fasm-mode-hook 'rc/set-up-whitespace-handling) (add-hook 'go-mode-hook 'rc/set-up-whitespace-handling) (add-hook 'nim-mode-hook 'rc/set-up-whitespace-handling) (add-hook 'yaml-mode-hook 'rc/set-up-whitespace-handling) (add-hook 'porth-mode-hook 'rc/set-up-whitespace-handling) ;;; display-line-numbers-mode (when (version<= "26.0.50" emacs-version) (global-display-line-numbers-mode)) (setq display-line-numbers-type 'relative) ;;; magit ;; magit requres this lib, but it is not installed automatically on ;; Windows. (rc/require 'cl-lib) (rc/require 'magit) (setq magit-auto-revert-mode nil) (global-set-key (kbd "C-c m s") 'magit-status) (global-set-key (kbd "C-c m l") 'magit-log) ;;; multiple cursors (rc/require 'multiple-cursors) (global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines) (global-set-key (kbd "C-S-n") 'mc/mark-next-like-this) (global-set-key (kbd "C-S-p") 'mc/mark-previous-like-this) ;(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this) ;(global-set-key (kbd "C-\"") 'mc/skip-to-next-like-this) ;(global-set-key (kbd "C-:") 'mc/skip-to-previous-like-this) ;;; markdown (rc/require 'markdown-mode 'impatient-mode 'simple-httpd) (add-to-list 'auto-mode-alist '("\\.md\\'" . gfm-mode)) (setq markdown-command "pandoc -t html5") (setq httpd-port 7070) (setq httpd-host (system-name)) (defun github-markdown-filter (buffer) (princ (with-temp-buffer (let ((tmp (buffer-name))) (set-buffer buffer) (set-buffer (markdown tmp)) (format "