This repository has been archived on 2022-11-18. You can view files and clone it, but cannot push or open issues or pull requests.
emacs/init.el

182 lines
7.5 KiB
EmacsLisp
Raw Normal View History

2017-08-17 21:37:33 +02:00
;;; init.el --- Emacs Initialization File
;;
;; Copyright (c) 2017 Wojciech Kozlowski
;;
;; Author: Wojciech Kozlowski <wojciech.kozlowski@vivaldi.net>
;; URL: https://gitlab.wojciechkozlowski.eu/config/emacs.d
;;
;;; License: GPLv3
2017-08-17 21:38:30 +02:00
;; ----------------------------------------------------------------------------
;; Run init without garbage collection.
;; ----------------------------------------------------------------------------
(let ((gc-cons-threshold most-positive-fixnum))
2017-08-17 21:39:43 +02:00
;; --------------------------------------------------------------------------
;; Visual configuration.
;; --------------------------------------------------------------------------
2017-08-17 23:41:32 +02:00
;; Font ---------------------------------------------------------------------
2017-08-19 04:03:34 +02:00
(let* ((font-name "Source Code Pro")
(font-size 10)
(font-spec (concat font-name "-" (int-to-string font-size))))
(set-frame-font font-spec nil t)
(add-to-list 'default-frame-alist `(font . ,font-spec))
(set-face-attribute 'italic nil ;; Emacs does not set italic face
:family (concat font-name "-Italic")))
2017-08-17 23:41:32 +02:00
2017-08-17 21:39:43 +02:00
;; Fullscreen ---------------------------------------------------------------
(toggle-frame-maximized)
2017-08-17 21:39:43 +02:00
(add-to-list 'default-frame-alist '(fullscreen . maximized))
;; Visual clutter -----------------------------------------------------------
(scroll-bar-mode -1)
(tool-bar-mode -1)
(menu-bar-mode -1)
(blink-cursor-mode -1)
2017-08-17 21:39:43 +02:00
;; Scrolling ----------------------------------------------------------------
(setq-default scroll-preserve-screen-position 1)
;; Line number --------------------------------------------------------------
(setq-default linum-format "%4d \u2502") ;; Line number format
2017-08-17 23:41:32 +02:00
(add-hook 'prog-mode-hook 'linum-mode) ;; Only in programming modes
;; Theme --------------------------------------------------------------------
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")
(load-theme 'havoc t) ;; Load personal theme
2017-08-17 23:41:32 +02:00
2017-08-24 23:41:18 +02:00
;; --------------------------------------------------------------------------
;; Change file in which custom variable changes are saved.
;; --------------------------------------------------------------------------
(setq custom-file "~/.emacs.d/custom.el")
;; *********************************************************************** ;;
;; ;;
;; ;;
;; Visual configuration must come before this point so that the frame can ;;
2017-08-25 00:20:38 +02:00
;; be set up before any time consuming package management. ;;
2017-08-24 23:41:18 +02:00
;; ;;
;; ;;
;; *********************************************************************** ;;
2017-08-25 00:08:47 +02:00
;; --------------------------------------------------------------------------
;; Package configuration.
;; --------------------------------------------------------------------------
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize)
2017-08-25 00:08:47 +02:00
(load "~/.emacs.d/init-packages/init-packages.el")
(init-packages-init '(use-package
magit
rainbow-delimiters
highlight-parentheses))
2017-08-24 22:41:24 +02:00
2017-08-25 00:08:47 +02:00
(use-package magit)
2017-08-24 22:41:24 +02:00
2017-08-25 00:08:47 +02:00
(use-package rainbow-delimiters)
2017-08-24 22:41:24 +02:00
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
2017-08-25 00:08:47 +02:00
(use-package highlight-parentheses)
2017-08-24 22:41:24 +02:00
(add-hook 'prog-mode-hook 'show-paren-mode)
2017-08-25 00:08:47 +02:00
(add-hook 'prog-mode-hook 'highlight-parentheses-mode)
2017-08-24 22:41:24 +02:00
(setq hl-paren-colors '("#86dc2f"
"IndianRed1"
"IndianRed3"
"IndianRed4"))
2017-08-24 23:41:18 +02:00
;; *********************************************************************** ;;
;; ;;
;; ;;
;; Any further non-package specific configuration should be set below this ;;
;; point so that it does not get overridden by package configuration. ;;
;; ;;
;; ;;
;; *********************************************************************** ;;
2017-08-25 00:08:47 +02:00
2017-08-24 23:41:18 +02:00
;; --------------------------------------------------------------------------
;; Load any custom variables.
;; --------------------------------------------------------------------------
(when (file-exists-p custom-file)
(load custom-file))
2017-08-18 23:30:43 +02:00
;; --------------------------------------------------------------------------
;; Formatting
;; --------------------------------------------------------------------------
(setq-default tab-width 8) ;; Tab width
(setq-default indent-tabs-mode nil) ;; No tabs
(setq-default fill-column 79) ;; Line width
(setq-default whitespace-line-column fill-column) ;; For whitespace mode
(setq-default c-default-style "linux") ;; Default C style
2017-08-24 22:41:07 +02:00
;; --------------------------------------------------------------------------
;; Convenience functions.
;; --------------------------------------------------------------------------
2017-08-18 23:30:43 +02:00
(defun toggle-indent-tabs-mode ()
"Toggle a indent-tabs-mode between a defined and undefined state."
(interactive)
(setq indent-tabs-mode (not indent-tabs-mode))
(setq-default indent-tabs-mode indent-tabs-mode))
2017-08-24 22:41:07 +02:00
(defun quit-other-window ()
"Quit the next window in cyclic order"
(interactive)
(quit-window t (next-window (selected-window))))
2017-08-18 23:31:11 +02:00
(defun kill-default-buffer ()
"Kill the currently active buffer with no confirmation."
(interactive)
(let (kill-buffer-query-functions) (kill-buffer)))
2017-08-24 22:41:07 +02:00
;; --------------------------------------------------------------------------
;; Convenience keyboard shortcuts.
;; --------------------------------------------------------------------------
2017-08-18 23:31:11 +02:00
(global-set-key (kbd "C-x k") 'kill-default-buffer) ;; Kill current buffer
2017-08-24 22:41:07 +02:00
(global-set-key (kbd "C-x C-q") 'quit-other-window) ;; Kill other window
2017-08-18 23:31:11 +02:00
(global-set-key (kbd "C-c w") 'whitespace-mode) ;; Toggle whitespace mode
(global-set-key (kbd "C-x k") 'kill-default-buffer) ;; Kill current buffer
(global-set-key (kbd "M-o") 'other-window) ;; Change window
(global-set-key (kbd "M-s M-o") 'occur) ;; Occur
;; --------------------------------------------------------------------------
;; Configure garbage collection.
;;
;; Based on advice from:
;; http://bling.github.io/blog/2016/01/18/why-are-you-changing-gc-cons-threshold/
;; --------------------------------------------------------------------------
2017-08-24 23:41:18 +02:00
(defun minibuffer-gc-setup-hook ()
(setq gc-cons-threshold most-positive-fixnum))
2017-08-24 23:41:18 +02:00
(defun minibuffer-gc-exit-hook ()
(setq gc-cons-threshold 800000))
2017-08-24 23:41:18 +02:00
(add-hook 'minibuffer-setup-hook #'minibuffer-gc-setup-hook)
(add-hook 'minibuffer-exit-hook #'minibuffer-gc-exit-hook)
2017-08-17 21:39:43 +02:00
;; --------------------------------------------------------------------------
;; Increase recursion limits.
;; --------------------------------------------------------------------------
(setq-default max-specpdl-size 20000) ;; ~15x original value
(setq-default max-lisp-eval-depth 24000) ;; 30x orignal value
2017-08-24 22:41:07 +02:00
) ;; Reset garbage collection settings.