Puremacs
Package management
Here I set up basic package control. I add melpa, melpa-stable and org to my sources and then initialize the package.
(require 'package) (add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/")) (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/")) (add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/")) (setq package-enable-at-startup nil) (package-initialize)
I use use-package for my package management. It makes it very simple to automatically install packages on a new system. It also allows packages to fail while still loading the remainder of your config file.
(unless (package-installed-p 'use-package) (package-refresh-contents) (package-install 'use-package)) (require 'use-package) (setq use-package-always-ensure t)
Essential Settings
Essential settings contains mostly quality of life changes. I disable the welcome
screen as well as the welcome message in the minibuffer. I also disable the tool bar,
scroll bar and menu bar. Matching parens are shown when highlighted. The scratch
buffer is blank by default. I also set yes-or-no-p
so that I only have to press y
stead of typing yes<RET>
when prompted. Use spaces instead of tabs. If I try and
input text with a visual selection it replaces the visual selection. Personally I'm
partial to Inconsolata (I like Fira as well) here I check if the font group is
installed before setting the font to stop any errors.
(setq inhibit-splash-screen t inhibit-startup-message t inhibit-startup-echo-area-message "wolfe") (tool-bar-mode -1) (scroll-bar-mode -1) (menu-bar-mode -1) (show-paren-mode t) (setq initial-scratch-message "") (fset 'yes-or-no-p 'y-or-n-p) (setq-default indent-tabs-mode nil) (delete-selection-mode 1) (when (member "Inconsolata" (font-family-list)) (add-to-list 'default-frame-alist '(font . "Inconsolata-13" )) (set-face-attribute 'default t :font "Inconsolata-13"))
Currently I'm using doom themes (I usually swap between doom-one and doom-molokai depending on how I'm feeling that day). I'm also a fan of sublime themes's Spolsky. If you're planning to swap this theme out for your own make sure to remove the accompanying neotree theme enabled lower down in Neotree.
;; Theme (use-package doom-themes :config (load-theme 'doom-one t))
Org Settings
I'm still getting into org mode so my settings are very basic. I enable entities so
I can type \
followed by something like alpha
and get the UTF-8 char α. I also
set src font natively so that I can have syntax highlighting in source blocks. I
also do some fontify stuff to make my theme look better (as suggested on the doom
theme's github).
(setq org-pretty-entities t org-src-fontify-natively t org-fontify-whole-heading-line t org-fontify-done-headline t org-fontify-quote-and-verse-blocks t)
Org Bullets
Org bullets allows for nicely formatted bullets instead of asteriks' in org mode.
;; Better looking org headers (use-package org-bullets :config (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
Packages
Ido
ido is my go-to minibuffer completion. It makes it super easy to navigate around the minibuffer. I bind tab to cycle through the matches and I have fuzzy matching on as well. I use ido-ubiquitous so that I can use ido everywhere possible. Finally I have ido-complete-space-or-hyphen which intelligently inserts a space or hyphen based on completion candidates.
(use-package ido :init (defun my-ido-keys () "Add keybindings for ido" (define-key ido-completion-map [tab] 'ido-next-match)) (add-hook 'ido-setup-hook #'my-ido-keys) :config (setq ido-enable-flex-matching t) (setq ido-everywhere t) (ido-mode 1)) (use-package ido-ubiquitous :config (ido-ubiquitous-mode 1)) (use-package ido-complete-space-or-hyphen)
Smex
Smex uses ido for M-x
. I like this for all the same reasons I like ido. Easy command
completion.
(use-package smex :config (global-set-key (kbd "M-x") 'smex) (global-set-key (kbd "M-X") 'smex-major-mode-commands) (global-set-key (kbd "C-c C-c M-x") 'execute-extended-command))
Expand Region
Expand reigon allows selection by syntastic region. So if I had an expression like this:
(setq some-var "a string o|f chars")
with mu cusor where the |
is. Pressing C-=
enables the mode and selects the word of
. Then if I press +
it would select the
contents in the quotes. Pressing +
again would then select everything inside the
quotes and the quotes themselves and so on. Pressing -
at will do the opposite and
shrink the select region.
(use-package expand-region :config (global-set-key (kbd "C-=") 'er/expand-region))
Magit
Magit is a fantastic git porcelen inside of emacs. It allows you to do all of the things you could do from the git command line from within emacs. It has mneumonic keybindings and displays all the information very nicely.
(use-package magit :config (global-set-key "\C-x\g" 'magit-status))
Ace Jump Mode
Ace jump mode allows for easy movement around the buffer. It allows you to specify a character or the first word of a character. It then dims the buffer and replaces the specified chars with a red letter. You can then press one of the letters to jump to the corresponding character.
(use-package ace-jump-mode :config (define-key global-map (kbd "C-c C-SPC") 'ace-jump-mode))
Spaceline
Spaceline is a modeline replacement that makes the modeline slightly more appealing to the eye. It also has built in compatability with a large range of additional packages.
(use-package spaceline-config :ensure spaceline :pin melpa-stable :config (spaceline-emacs-theme))
Neotree
Neotree is a file tree display which is similar to the ones found in other popular text editors and IDEs (such as Sublime, Atom, Eclipse or nerdTREE if you use vim). It allows you to neatly view your file structure at the side of your screen.
(use-package neotree :config (global-set-key [f8] 'neotree-toggle))
This comes with my colorscheme so I set ensure
to nil
so it doesn't go looking on
melpa. The file icons all come from the all the icons fonts (it doesn't actually use all
the icons itself.
(use-package doom-neotree :ensure nil :config (setq doom-neotree-enable-file-icons t))
Company Mode
Company is an autocompletion framwork that supports user written backends. This means that the number of languages company (and supporting packages) encompass is very impressive.
I have set the delay that company waits before completing to 0 and I also have it configured so that company begins completing after you type a single character. I also set the completion list to wrap around so you can cycle through all of the completion candidates. I've bound tab to move to the next completion candidate.
The custom faces inherit the colors from your loaded theme and match the company drop down. This allows me to change themes without worrying that company will look terrible.
(use-package company :init (global-company-mode) :config (setq company-idle-delay 0) (setq company-minimum-prefix-length 1) (setq company-selection-wrap-around t) (define-key company-active-map [tab] 'company-select-next) (require 'color) (let ((bg (face-attribute 'default :background))) (custom-set-faces `(company-tooltip ((t (:inherit default :background ,(color-lighten-name bg 2))))) `(company-scrollbar-bg ((t (:background ,(color-lighten-name bg 10))))) `(company-scrollbar-fg ((t (:background ,(color-lighten-name bg 5))))) `(company-tooltip-selection ((t (:inherit font-lock-function-name-face)))) `(company-tooltip-common ((t (:inherit font-lock-constant-face)))))))
Company Quickhelp
Company quickhelp mimics the functionality of autocomplete and displays the documentation of the currently highlighted completion (after a brief delay). This is quite handy as it makes it easy to check the arguments or return type of the function.
(use-package company-quickhelp :config (company-quickhelp-mode 1))
Backup Options
The default options for filebackups and autosave are terrible and leave files scattered
all across your file system. First I make all backups copy the files which stops any
shinanigans with links. I also set the backup directory. Then I check if ~/.bak.emacs/
and ~/.bak.emacs/backup/
exit if they don't I create them. Then I set my auto save
location to ~/.bak.emacs/auto/
and set it so that the files are are all saved in auto
with a flat structure rather rather than folder trees.
(setq backup-by-copying t) (setq backup-directory-alist '((".*" . "~/.bak.emacs/backup/"))) (if (eq nil (file-exists-p "~/.bak.emacs/")) (make-directory "~/.bak.emacs/")) (if (eq nil (file-exists-p "~/.bak.emacs/auto")) (make-directory "~/.bak.emacs/auto")) (setq auto-save-file-name-transforms '((".*" "~/.bak.emacs/auto/" t)))