5.4 KiB
Emacs Configuration
- Set up UI
- Set up package repositories
- Theming
- Ivy
- Counsel
- Set Variables
- Org-mode
- Useful functions
- Load
custom.el
Set up UI
Remove all those UI elements. They do not look good and waste space.
(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1)
(tooltip-mode -1)
(fringe-mode -1)
Set up package repositories
Require package support
State that we will need package support and define a macro for adding package repos to the archives
(require 'package)
(defmacro append-to-list (target suffix)
"Append SUFFIX to TARGET in place."
`(setq ,target (append ,target ,suffix)))
Add package repos
(append-to-list package-archives
'(("melpa" . "http://melpa.org/packages/")
("melpa-stable" . "http://stable.melpa.org/packages/")
("org-elpa" . "https://orgmode.org/elpa/")))
Ensure use-package command is present
(package-initialize)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package)
(setq
use-package-always-ensure t
use-package-verbose t)
Theming
Main Theme
(use-package solarized-theme
:config
(load-theme 'solarized-light t)
(let ((line (face-attribute 'mode-line :underline)))
(set-face-attribute 'mode-line nil :overline line)
(set-face-attribute 'mode-line-inactive nil :overline line)
(set-face-attribute 'mode-line-inactive nil :underline line)
(set-face-attribute 'mode-line nil :box nil)
(set-face-attribute 'mode-line-inactive nil :box nil)
(set-face-attribute 'mode-line-inactive nil :background "#f9f2d9")))
Modeline
(use-package moody
:config
(setq x-underline-at-descent-line t)
(moody-replace-mode-line-buffer-identification)
(moody-replace-vc-mode))
Minions Menu
Add a menu to the modeline to access all minor modes.
(use-package minions
:config (minions-mode 1))
Font
(set-face-attribute 'default nil
:family "Hack"
:height 110
:weight 'normal
:width 'normal)
Ivy
Use Ivy to make minibuf promts better. Adds the ability to sort and filter.
Use Ivy
(use-package ivy
:ensure t
:init
(ivy-mode 1)
(unbind-key "S-SPC" ivy-minibuffer-map)
(setq ivy-height 30
ivy-use-virtual-buffers t
ivy-use-selectable-prompt t)
(defun swiper-at-point ()
(interactive)
(swiper (thing-at-point 'word)))
:bind (("C-x b" . ivy-switch-buffer)
("C-c C-r" . ivy-resume)
("C-c s" . swiper-at-point)
("C-s" . swiper))
:diminish)
;; ivy-rich makes Ivy look a little bit more like Helm.
(use-package ivy-rich
:after counsel
:custom
(ivy-virtual-abbreviate 'full
ivy-rich-switch-buffer-align-virtual-buffer t
ivy-rich-path-style 'abbrev)
:init
(ivy-rich-mode))
(use-package ivy-hydra)
Smex
Sort commands by recency in ivy windows
(use-package smex)
Counsel
(use-package counsel
:ensure t
:after ivy
:init
(counsel-mode 1)
:bind (("C-c ;" . counsel-M-x)
("C-c U" . counsel-unicode-char)
("C-c i" . counsel-imenu)
("C-x f" . counsel-find-file)
("C-c y" . counsel-yank-pop)
("C-c r" . counsel-recentf)
:map ivy-minibuffer-map
("C-r" . counsel-minibuffer-history))
:diminish)
Set Variables
Default encoding
(prefer-coding-system 'utf-8)
File loading
When loading files, prefer newer versions, if available
(setq load-prefer-newer t)
Org-mode
Templates
Babel
Here we set custom templates to be used for structure expansion.
These are used when we type "<" folowed by the shortcut for a template and hit "TAB".
e.g. "<s TAB" expands to #+BEGIN_SRC ?\n\n#+END_SRC
emacs-lisp
Shortcut for creating emacs-lisp code blocks. This is used extensively in this very file.
(add-to-list 'org-structure-template-alist '("el" "#+BEGIN_SRC emacs-lisp\n?\n#+END_SRC"))
Useful functions
Reformat a whole buffer
Reindet the whole buffer with F12
(defun indent-buffer ()
(interactive)
(save-excursion
(indent-region (point-min) (point-max) nil)))
(global-set-key [f12] 'indent-buffer)
Load custom.el
Load a custom file from the emacs home dir. This file is specific to the maschine emacs runs on. It conatins customizations and file locations that are maschine dependend.
(setq custom-file "~/.emacs.d/custom.el")
(load custom-file 'noerror)