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

215 lines
8.7 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
2017-08-26 01:04:38 +02:00
;; Created: 17 Aug 2017
2017-08-17 21:37:33 +02:00
;;
;;; 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 the necessary paths.
(add-to-list 'load-path "~/.emacs.d/themes/")
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")
;; Load the dark theme by default.
(load-theme 'havoc-dark 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")
;; *********************************************************************** ;;
;; ;;
2017-08-25 23:37:01 +02:00
;; MODULES ;;
;; ;;
;; ----------------------------------------------------------------------- ;;
;; ;;
2017-08-24 23:41:18 +02:00
;; ;;
;; 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
;; --------------------------------------------------------------------------
2017-08-25 23:37:01 +02:00
;; Initialise and setup `package'.
;; --------------------------------------------------------------------------
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize)
2017-08-25 23:37:01 +02:00
;; --------------------------------------------------------------------------
;; Load `init-packages'.
;; --------------------------------------------------------------------------
2017-08-24 22:41:24 +02:00
2017-08-25 23:37:01 +02:00
(add-to-list 'load-path "~/.emacs.d/init-packages")
(require 'init-packages)
2017-08-24 22:41:24 +02:00
2017-08-25 23:37:01 +02:00
;; --------------------------------------------------------------------------
;; Load modules.
;; --------------------------------------------------------------------------
2017-08-24 22:41:24 +02:00
2017-08-27 21:13:04 +02:00
(init-packages/init '(editing
emacs
helm
2017-08-25 23:37:01 +02:00
version-control
workflow))
2017-08-24 22:41:24 +02:00
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 23:37:01 +02:00
;; ----------------------------------------------------------------------- ;;
;; ;;
;; END MODULES ;;
;; ;;
2017-08-24 23:41:18 +02:00
;; *********************************************************************** ;;
2017-08-25 00:08:47 +02:00
2017-08-24 23:41:18 +02:00
;; --------------------------------------------------------------------------
;; Load any custom variables.
;; --------------------------------------------------------------------------
(load custom-file 'noerror)
2017-08-24 23:41:18 +02:00
2017-08-18 23:30:43 +02:00
;; --------------------------------------------------------------------------
;; Programming style.
2017-08-18 23:30:43 +02:00
;; --------------------------------------------------------------------------
(setq-default c-default-style "linux") ;; Default C style
2017-08-24 22:41:07 +02:00
;; --------------------------------------------------------------------------
;; Convenience functions.
;; --------------------------------------------------------------------------
(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)))
(defun refresh-non-face-colours ()
"Restart modes that use colours not set with face variables.
This has to be called whenever the active theme changes to
refresh these colours."
(when (and (fboundp 'fci-mode)
(fci-mode))
(fci-mode 1))
(when (and (fboundp 'highlight-parentheses-mode)
(highlight-parentheses-mode))
(highlight-parentheses-mode 1)))
2017-08-24 22:41:07 +02:00
;; --------------------------------------------------------------------------
;; Convenience keyboard shortcuts.
;; --------------------------------------------------------------------------
;; Kill current buffer without prompting.
(global-set-key (kbd "C-x k") 'kill-default-buffer)
;; Kill other window (cyclic order).
(global-set-key (kbd "C-x C-q") 'quit-other-window)
;; Change active window. More convenient than "C-x o".
(global-set-key (kbd "M-o") 'other-window)
;; Setup key-bindings for switching between themes.
(global-set-key (kbd "C-x t l") '(lambda () (interactive)
(load-theme 'havoc-light t)
(refresh-non-face-colours)))
(global-set-key (kbd "C-x t d") '(lambda () (interactive)
(load-theme 'havoc-dark t)
(refresh-non-face-colours)))
;; --------------------------------------------------------------------------
;; Aliases.
;; --------------------------------------------------------------------------
;; y or n is enough.
(defalias 'yes-or-no-p 'y-or-n-p)
;; Always use ibuffer.
(defalias 'list-buffers 'ibuffer)
2017-08-18 23:31:11 +02:00
;; --------------------------------------------------------------------------
;; 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.