Skip to content

samdoshi/.emacs.d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Emacs Init as an Org file

Installation

  1. Install Cask
    brew install cask
        
  2. Clone
    cd ~
    git clone git@github.com:samdoshi/.emacs.d.git
        
  3. Run reset-cask.sh from your ~/.emacs.d directory
  4. Run emacs!

Upgrading packages

Either:

  • Run reset-cask.sh again, particularly if you have removed packages
  • Run cask upgrade

Todo

Useful links

Emacs as an Org file

Evil

Other

Initialise…

req-package

req-package extends use-package, each req-package macro will be run once req-package-finish is run (at the bottom of this file).

(add-to-list 'load-path (concat user-emacs-directory "init/"))
(add-to-list 'load-path (concat user-emacs-directory "spacemacs/"))
(require 'req-package)
(setq custom-file "~/.emacs.d/custom.el")
(load custom-file)

The basics

(req-package f)
(req-package s)
(req-package init-keybindings)
(req-package init-utils
  :require (s flyspell))
(req-package init-theme
  :require (solarized-theme evil-leader powerline projectile))
(req-package init-helm-deft
  :require (helm f)
  :commands init/helm-deft)
(req-package evil-evilified-state
  :require (evil evil-leader))
(req-package core-evilify-keymap
  :require (evil core-funcs))
(req-package init-eshell
  :require (eshell))
(req-package init-projectile
  :require (helm projectile))
(req-package init-hydra
  :require (hydra evil-numbers))

Evil

Evil

Make sure we set evil-want-C-u-scroll & others before evil is loaded.

(setq evil-want-C-u-scroll t
      evil-want-C-w-in-emacs-state t
      evil-want-fine-undo 'fine
      evil-echo-state nil)
(req-package evil
  :ensure evil
  :require (evil-leader undo-tree)
  :config
  (progn
    (add-hook 'evil-insert-state-entry-hook 'init/evil-enter-edit-hook)
    (add-hook 'evil-insert-state-exit-hook 'init/evil-exit-edit-hook)
    (add-hook 'evil-replace-state-entry-hook 'init/evil-enter-edit-hook)
    (add-hook 'evil-replace-state-exit-hook 'init/evil-exit-edit-hook)
    (add-hook 'evil-visual-state-entry-hook 'init/evil-enter-edit-hook)
    (add-hook 'evil-visual-state-exit-hook 'init/evil-exit-edit-hook)
    (add-hook 'evil-emacs-state-entry-hook 'init/evil-enter-edit-hook)
    (add-hook 'evil-emacs-state-exit-hook 'init/evil-exit-edit-hook)
    (define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state)
    (evil-mode 1)))

Evil leader

(req-package evil-leader
  :ensure evil-leader
  :require (helm init-keybindings init-utils)
  :config
  (progn
    (evil-leader/set-leader "<SPC>")
    (global-evil-leader-mode)
    (dolist (group '(("b"  . "buffer")
                     ("c"  . "compile")
                     ("e"  . "emacs")
                     ("f"  . "files")
                     ("g"  . "git")
                     ("h"  . "help")
                     ("P"  . "projectile")
                     ("m"  . "major-mode")
                     ("o"  . "org")
                     ("s"  . "smartparens")
                     ("t"  . "text")
                     ("tr" . "rainbow")
                     ("T"  . "theme")
                     ("Tf" . "fonts")
                     ("w"  . "window")))
      (init/evil-leader-group (car group) (cdr group)))
    (evil-leader/set-key
      "<SPC>" 'ace-jump-word-mode
      "ba"    'init/alternate-buffer
      "bb"    'helm-mini
      "bd"    'evil-delete-buffer
      "bk"    'kill-this-buffer
      "bK"    'kill-buffer
      "cc"    'init/kill-compilation-buffer
      "cf"    'helm-flycheck
      "cm"    'recompile
      "ee"    'init/edit-emacs-README.org
      "el"    'linum-mode
      "es"    'eshell
      "ff"    'helm-find-files
      "fn"    'neotree-toggle
      "fs"    'evil-write
      "fS"    'evil-write-all
      "gd"    'magit-diff-working-tree
      "gs"    'magit-status
      "g+"    'git-gutter:stage-hunk
      "g-"    'git-gutter:revert-hunk
      "hc"    'describe-char
      "hf"    'describe-function
      "hk"    'describe-key
      "hl"    'view-lossage
      "hm"    'describe-mode
      "hp"    'describe-package
      "ht"    'describe-theme
      "hv"    'describe-variable
      "i"     'helm-semantic-or-imenu
      "m'"    'org-edit-src-exit
      "oa"    'org-agenda
      "oc"    'org-capture
      "ot"    'org-todo-list
      "n"     'init/helm-deft
      "N"     'init/edit-Today.org
      "p"     'helm-projectile
      "Pp"    'projectile-switch-project
      "PP"    'projectile-switch-project
      "Ps"    'init/projectile-eshell
      "sb"    'sp-forward-barf-sexp
      "sB"    'sp-backward-barf-sexp
      "sc"    'sp-join-sexp
      "sC"    'sp-split-sexp
      "sd"    'sp-kill-sexp
      "sD"    'sp-backward-kill-sexp
      "sk"    'sp-backward-up-sexp
      "sj"    'sp-end-of-next-sexp
      "ss"    'sp-forward-slurp-sexp
      "sS"    'sp-backward-slurp-sexp
      "ta"    'init/hydra-numbers/evil-numbers/inc-at-pt
      "tc"    'evilnc-comment-or-uncomment-lines
      "td"    'osx-dictionary-search-pointer
      "tf"    'init/flyspell-mode
      "trb"   'rainbow-blocks-mode
      "trd"   'rainbow-delimiters-mode
      "ts"    'ispell
      "tx"    'init/hydra-numbers/evil-numbers/dec-at-pt
      "tS"    'helm-flyspell-correct
      "Td"    'init/solarized-dark-theme
      "Tfc"   'init/set-font-consolas
      "Tfm"   'init/set-font-menlo
      "Tfs"   'init/set-font-source-code-pro
      "Tl"    'init/solarized-light-theme
      "v"     'er/expand-region
      "wc"    'evil-window-delete
      "wg"    'golden-ratio-mode
      "wh"    'evil-window-left
      "wH"    'evil-window-move-far-left
      "wj"    'evil-window-down
      "wJ"    'evil-window-move-very-bottom
      "wk"    'evil-window-up
      "wK"    'evil-window-move-very-top
      "wl"    'evil-window-right
      "wL"    'evil-window-move-far-right
      "wr"    'evil-window-rotate-downwards
      "ws"    'init/split-window-and-focus
      "wv"    'init/vsplit-window-and-focus
      "ww"    'ace-window
      "x"     'helm-M-x
      ":"     'helm-M-x
      "C-g"   'keyboard-quit)))

Evil escape

;; (req-package evil-escape
;;   :require evil
;;   :diminish evil-escape-mode
;;   :init (setq-default evil-escape-key-sequence "kj")
;;   :config (evil-escape-mode))

Evil matchit

(req-package evil-matchit
  :require evil
  :config (global-evil-matchit-mode 1))

Evil nerd commenter

(req-package evil-nerd-commenter
  :commands (evilnc-comment-or-uncomment-lines))

Evil snipe

(req-package evil-snipe
  :diminish evil-snipe-local-mode
  :config
  (progn
    (evil-snipe-mode 1)
    (evil-snipe-override-mode 1)))

Major modes

Compilation

(req-package compile
  :require (init-utils)
  :init
  (progn
    (add-hook 'compilation-mode-hook 'init/small-font-buffer)))

Eshell

(req-package eshell
  :defer t
  :require (exec-path-from-shell init-utils)
  :init
  (progn
    (add-hook 'eshell-mode-hook 'init/small-font-buffer)))

Git

magit

(req-package magit
  :require (evil-evilified-state core-evilify-keymap)
  :commands (magit-status
             magit-diff
             magit-diff-working-tree
             magit-log
             magit-commit)
  :init
  (progn
    (setq magit-last-seen-setup-instructions "1.4.0")
    ;; seems to be necessary at the time of release
    (require 'git-rebase)
    ;; mode maps
    (spacemacs|evilify-map magit-mode-map)
    (spacemacs|evilify-map magit-status-mode-map
      :mode magit-status-mode
      :bindings
      (kbd "C-S-j") 'magit-section-forward
      (kbd "C-S-k") 'magit-section-backward
      (kbd "C-n") 'magit-section-forward
      (kbd "C-p") 'magit-section-backward)
    (spacemacs|evilify-map magit-refs-mode-map
      :mode magit-refs-mode
      :bindings
      (kbd "C-S-j") 'magit-section-forward
      (kbd "C-S-k") 'magit-section-backward
      (kbd "C-n") 'magit-section-forward
      (kbd "C-p") 'magit-section-backward)
    (spacemacs|evilify-map magit-blame-mode-map
      :mode magit-blame-mode
      :bindings
      (kbd "C-S-j") 'magit-section-forward
      (kbd "C-S-k") 'magit-section-backward
      (kbd "C-n") 'magit-section-forward
      (kbd "C-p") 'magit-section-backward)
    (spacemacs|evilify-map magit-diff-mode-map
      :mode magit-diff-mode
      :bindings
      (kbd "C-S-j") 'magit-section-forward
      (kbd "C-S-k") 'magit-section-backward
      (kbd "C-n") 'magit-section-forward
      (kbd "C-p") 'magit-section-backward)
    (spacemacs|evilify-map magit-log-read-revs-map
      :mode magit-log-read-revs
      :bindings
      (kbd "C-S-j") 'magit-section-forward
      (kbd "C-S-k") 'magit-section-backward
      (kbd "C-n") 'magit-section-forward
      (kbd "C-p") 'magit-section-backward)
    (spacemacs|evilify-map magit-log-mode-map
      :mode magit-log-mode
      :bindings
      (kbd "C-S-j") 'magit-section-forward
      (kbd "C-S-k") 'magit-section-backward
      (kbd "C-n") 'magit-section-forward
      (kbd "C-p") 'magit-section-backward)
    (spacemacs|evilify-map magit-log-select-mode-map
      :mode magit-log-select-mode
      :bindings
      (kbd "C-S-j") 'magit-section-forward
      (kbd "C-S-k") 'magit-section-backward
      (kbd "C-n") 'magit-section-forward
      (kbd "C-p") 'magit-section-backward)
    (spacemacs|evilify-map magit-cherry-mode-map
      :mode magit-cherry-mode
      :bindings
      (kbd "C-S-j") 'magit-section-forward
      (kbd "C-S-k") 'magit-section-backward
      (kbd "C-n") 'magit-section-forward
      (kbd "C-p") 'magit-section-backward)
    (spacemacs|evilify-map magit-reflog-mode-map
      :mode magit-reflog-mode
      :bindings
      (kbd "C-S-j") 'magit-section-forward
      (kbd "C-S-k") 'magit-section-backward
      (kbd "C-n") 'magit-section-forward
      (kbd "C-p") 'magit-section-backward)
    (spacemacs|evilify-map magit-process-mode-map
      :mode magit-process-mode
      :bindings
      (kbd "C-S-j") 'magit-section-forward
      (kbd "C-S-k") 'magit-section-backward
      (kbd "C-n") 'magit-section-forward
      (kbd "C-p") 'magit-section-backward)
    (spacemacs|evilify-map git-rebase-mode-map
      :mode git-rebase-mode
      :bindings
      (kbd "C-S-j") 'magit-section-forward
      (kbd "C-S-k") 'magit-section-backward
      (kbd "C-n") 'magit-section-forward
      (kbd "C-p") 'magit-section-backward
      "J" 'git-rebase-move-line-down
      "K" 'git-rebase-move-line-up
      "u" 'git-rebase-undo
      "y" 'git-rebase-insert)
    ;; default state for additional modes
    (dolist (mode '(magit-popup-mode
                    magit-popup-sequence-mode))
      (add-to-list 'evil-emacs-state-modes mode))
    (spacemacs/evilify-configure-default-state 'magit-revision-mode)
    ;; section maps
    (spacemacs|evilify-map magit-tag-section-map)
    (spacemacs|evilify-map magit-untracked-section-map)
    (spacemacs|evilify-map magit-branch-section-map)
    (spacemacs|evilify-map magit-remote-section-map)
    (spacemacs|evilify-map magit-file-section-map)
    (spacemacs|evilify-map magit-hunk-section-map)
    (spacemacs|evilify-map magit-unstaged-section-map)
    (spacemacs|evilify-map magit-staged-section-map)
    (spacemacs|evilify-map magit-commit-section-map)
    (spacemacs|evilify-map magit-module-commit-section-map)
    (spacemacs|evilify-map magit-unpulled-section-map)
    (spacemacs|evilify-map magit-unpushed-section-map)
    (spacemacs|evilify-map magit-stashes-section-map)
    (spacemacs|evilify-map magit-stash-section-map)))

Haskell

https://github.com/serras/emacs-haskell-tutorial/blob/master/tutorial.md ==ghc-mod== has problems, uncomment below when it’s fixed

(req-package haskell-mode
  :require (evil-leader ghc company company-ghc)
  :init
  (progn
    (defun init/haskell-load-and-bring ()
      (interactive)
      (haskell-process-load-or-reload)
      (haskell-interactive-bring))

    (defun init/haskell-test ()
      (interactive)
      (haskell-process-do-cabal "test"))

    (evil-leader/set-key-for-mode 'haskell-mode
      "cb"  'init/haskell-load-and-bring
      "cB"  'haskell-process-load-file
      "cm"  'haskell-process-cabal-build
      "ct"  'init/haskell-test)

    (setq haskell-tags-on-save t
          haskell-interactive-popup-errors nil
          haskell-process-type 'stack-ghci
          haskell-process-suggest-remove-import-lines nil
          haskell-process-suggest-hoogle-imports nil
          haskell-process-auto-import-loaded-modules t
          haskell-process-show-debug-tips nil
          haskell-process-log t)

    ;; make evil play nice with haskell-interactive-mode
    (evil-define-key 'insert haskell-interactive-mode-map
      (kbd "RET") 'haskell-interactive-mode-return)
    (evil-define-key 'normal haskell-interactive-mode-map
      (kbd "RET") 'haskell-interactive-mode-return)

    (add-to-list 'company-backends 'company-ghc))
  :config
  (progn
    (defun init/haskell-mode-hook ()
      (if (fboundp 'electric-indent-local-mode)
          (electric-indent-local-mode -1))
      (ghc-init)
      (turn-on-haskell-doc)
      (turn-on-eldoc-mode))
    (add-hook 'haskell-mode-hook 'init/haskell-mode-hook)
    ;; remove overlays from ghc-check.el if flycheck is enabled
    (set-face-attribute 'ghc-face-error nil :underline nil)
    (set-face-attribute 'ghc-face-warn nil :underline nil)))

Html

(req-package web-mode
  :require (flycheck)
  :defer t
  :mode
  (("\\.html\\'" . web-mode)
   ("\\.htm\\'"  . web-mode)
   ("\\.jsx\\'" . web-mode))
  :init
  (progn
    (flycheck-add-mode 'javascript-eslint 'web-mode)))

Javascript

(req-package js2-mode
  :defer t
  :mode
  (("\\.js\\'" . js2-mode))
  :init
  (progn
    (setq js2-strict-missing-semi-warning nil)))

(req-package json-mode
  :defer t)

(req-package tern
  :defer t
  :init
  (progn
    (add-hook 'js2-mode-hook 'tern-mode)
    (add-hook 'web-mode-hook 'tern-mode)))

(req-package company-tern
  :require (company)
  :defer t
  :init
  (progn
    (add-to-list 'company-backends 'company-tern)))

Lua

(req-package lua-mode)

Markdown

Markdown mode

(req-package markdown-mode)

Python

You need to pip install jedi service_factory yapf flake8

(req-package anaconda-mode
  :init
  (progn
    (add-hook 'python-mode-hook 'anaconda-mode)
    (add-hook 'python-mode-hook 'eldoc-mode)))

(req-package pyvenv
  :defer t
  :commands (pyvenv-activate pyvenv-deactivate)
  :init
  (progn
    (evil-leader/set-key-for-mode 'python-mode
      "md" 'pyvenv-deactivate
      "mw" 'pyvenv-workon)))

(req-package py-yapf
  :defer t
  :commands (py-yapf-buffer)
  :init
  (progn
    (evil-leader/set-key-for-mode 'python-mode
      "my" 'py-yapf-buffer)))

(req-package pip-requirements)

(req-package company-anaconda
  :require (company)
  :defer t
  :init
  (progn
    (add-to-list 'company-backends 'company-anaconda)))

Org

Org mode

(req-package org-install
  :ensure org
  :require (evil-leader)
  :init
  (progn
    (evil-leader/set-key-for-mode 'org-mode
      "ml"  'org-insert-link
      "mn"  'org-narrow-to-subtree
      "mo"  'org-open-at-point
      "mtr" 'org-table-recalculate
      "mtR" 'org-table-iterate
      "mw"  'widen
      "m'"  'org-edit-special)
    (setq org-directory "~/Dropbox/Notes"
          org-default-notes-file (concat org-directory "/Today.org")
          org-agenda-files (list (concat org-directory "/Today.org"))
          org-startup-indented t
          org-startup-folded "showall"
          org-src-tab-acts-natively t
          org-src-fontify-natively t
          org-src-window-setup 'current-window)))

Rust

Homepage

(req-package rust-mode
  :init
  (progn
    (setq-default rust-indent-method-chain t
                  rust-indent-offset 4)
    (add-hook 'rust-mode-hook (lambda ()
                                (setq-local compile-command "cargo build")))))
(req-package flycheck-rust
  :require (flycheck)
  :config
  (progn
      (add-hook 'flycheck-mode-hook #'flycheck-rust-setup)))

SCSS

(req-package scss-mode
  :defer t)

YAML

(req-package yaml-mode)

Minor modes

Ace jump

(req-package ace-jump-mode
  :commands (ace-jump-word-mode))

Ace window

(req-package ace-window
  :commands (ace-window)
  :init
  (progn
    (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))))

Adaptive wrap

(req-package adaptive-wrap
  :ensure adaptive-wrap
  :init
  (progn
    (add-hook 'visual-line-mode-hook 'adaptive-wrap-prefix-mode)))

Beacon

(req-package beacon
  :diminish ""
  :require (init-theme)
  :config
  (progn
    (setq beacon-color init/solarized-base01)
    (beacon-mode 1)))

Company

(req-package company
  :diminish ""
  :init
  (progn
    (setq company-idle-delay 0.1
          company-minimum-prefix-length 2
          company-require-match nil
          company-dabbrev-downcase nil
          company-selection-wrap-around t
          company-tooltip-flip-when-above t
          company-tooltip-align-annotations t))
  :config
  (progn
    (define-key company-active-map (kbd "TAB") 'company-complete-common-or-cycle)
    (define-key company-active-map [tab] 'company-complete-common-or-cycle)
    (define-key company-active-map (kbd "S-TAB") 'company-select-previous-or-abort)
    (define-key company-active-map [S-tab] 'company-select-previous-or-abort)
    (global-company-mode t)))

Expand region

Enable expand region in visual mode with an extra v

(req-package expand-region
  :defer t
  :commands er/expand-region
  :init
  (progn
    (setq expand-region-contract-fast-key "V"
          expand-region-reset-fast-key    "r")))

Flycheck

(req-package flycheck
  :ensure flycheck
  :init
  (progn
    (global-flycheck-mode t))
  :config
  (progn
    (setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc
                                               javascript-jshint
                                               json-jsonlist)
                  flycheck-c/c++-gcc-executable  "gcc-5")))
(req-package helm-flycheck
  :commands helm-flycheck
  :require flycheck)

Flyspell

(req-package flyspell
  :require (ispell))

(req-package helm-flyspell
  :require (flyspell helm)
  :defer t
  :commands (helm-flyspell-correct))

Git gutter fringe

(req-package git-gutter-fringe
  :diminish git-gutter-mode
  :config (global-git-gutter-mode))

Golden ratio

(req-package golden-ratio
  :defer t
  :diminish ""
  :config
  (progn
    (defun init/no-golden-ratio-for-buffers (bufname)
      "Disable golden-ratio if BUFNAME is the name of a visible buffer."
      (and (get-buffer bufname) (get-buffer-window bufname 'visible)))
    (defun init/no-golden-ratio ()
      "Disable golden-ratio for guide-key popwin buffer."
      (or (init/no-golden-ratio-for-buffers " *guide-key*")
          (init/no-golden-ratio-for-buffers " *popwin-dummy*")
          (init/no-golden-ratio-for-buffers " *NeoTree*")))
    (add-to-list 'golden-ratio-inhibit-functions
                 'init/no-golden-ratio)
    (setq golden-ratio-extra-commands
          (append golden-ratio-extra-commands
                  '(ace-window
                    evil-window-left
                    evil-window-right
                    evil-window-up
                    evil-window-down
                    evil-window-next)))))

Helm

(req-package helm
  :ensure helm
  :diminish helm-mode
  :config
  (progn
    (require 'helm-config)
    (require 'helm-files)
    (setq helm-split-window-in-side-p t
          helm-echo-input-in-header-line t
          helm-split-window-default-side 'above)
    (bind-key "C-j" 'helm-next-line helm-map)
    (bind-key "C-k" 'helm-previous-line helm-map)
    (bind-key "C-S-j" 'helm-next-source helm-map)
    (bind-key "C-S-k" 'helm-previous-source helm-map)
    (bind-key "C-l" 'helm-toggle-visible-mark helm-map)
    (bind-key "C-S-l" 'helm-toggle-all-marks helm-map)
    ;; for helm-find-files
    (bind-key "<tab>" 'helm-execute-persistent-action helm-find-files-map)
    ;; for find-file
    (bind-key "<tab>" 'helm-execute-persistent-action helm-read-file-map)
    (helm-mode 1)))

Ispell

(req-package ispell
  :init
  (progn
    (setq-default ispell-program-name "aspell")
    (setq ispell-dictionary "british")))

Linum

Line numbers in programming modes

(req-package linum
  :config
  (progn
    ;;(add-hook 'prog-mode-hook
    ;;          '(lambda () (linum-mode 1)))
    ;;(add-hook 'text-mode-hook
    ;;          '(lambda () (linum-mode 1)))
    ;;(add-hook 'haskell-cabal-mode-hook
    ;;          '(lambda () (linum-mode 1)))
    ;;(add-hook 'css-mode-hook
    ;;          '(lambda () (linum-mode 1)))
    (setq-default linum-format "%4d")))

(req-package hlinum
  :config
  (progn
    ;;(hlinum-activate)
    ))

Neo tree

(req-package neotree
  :init
  (progn
    (setq neo-window-width 32
          neo-smart-open t
          neo-banner-message nil
          neo-theme 'arrow)))

Olivetti

(req-package olivetti)

OSX Dictionary

(req-package osx-dictionary
  :defer t
  :commands (osx-dictionary-search-pointer osx-dictionary-search-input))

Pallet

Pallet is used to provide the (pallet-init) command used in reset-cask.sh.

(req-package pallet)

Popwin

(req-package popwin
  :ensure popwin
  :config
  (progn
    (popwin-mode 1)
    (setq helm-popwin
          '(("*Helm Find Files*" :height 20)
            ("^\*helm.+\*$" :regexp t :height 20)))))

Projectile

(req-package projectile
  :diminish ""
  :config
  (progn
    (projectile-global-mode)))

(req-package helm-projectile
  :require (projectile helm)
  :commands (helm-projectile)
  :config
  (progn
    (helm-projectile-on)))

Rainbow blocks

Probably want to customise the colours used by solarized for this mode.

(req-package rainbow-blocks
  :commands rainbow-blocks-mode
  :diminish "")

Rainbow delimiters

(req-package rainbow-delimiters
  :commands rainbow-delimiters-mode
  :diminish ""
  :init
  (progn
    (add-hook 'emacs-lisp-mode-hook 'rainbow-delimiters-mode)))

Rainbow mode

(req-package rainbow-mode
  :diminish rainbow-mode)

Smartparens

(req-package smartparens-config
  :ensure smartparens
  :diminish (smartparens-mode . "")
  :init
  (progn
    (add-hook 'prog-mode-hook 'smartparens-mode)
    (add-hook 'prog-mode-hook 'show-smartparens-mode))
  :config
  (progn
    ;; play nicely with evil
    (setq sp-show-pair-from-inside t
          sp-autoescape-string-quote nil)
    (defun init/smartparens-pair-newline-and-indent (&rest _ignored)
      ;; https://github.com/Fuco1/smartparens/issues/80
      (save-excursion
        (newline)
        (indent-according-to-mode))
      (indent-according-to-mode))
    (sp-pair "{" nil :post-handlers
             '(:add (init/smartparens-pair-newline-and-indent "RET")))
    (sp-pair "[" nil :post-handlers
             '(:add (init/smartparens-pair-newline-and-indent "RET")))))

Undo tree

(req-package undo-tree
  :ensure undo-tree
  :diminish ""
  :init
  (progn
    (global-undo-tree-mode)))

Which key

(req-package which-key
  :diminish which-key-mode
  :init
  (progn
    (setq which-key-idle-delay 0.3
          which-key-sort-order 'which-key-key-order-alpha))
  :config
  (progn
    (add-to-list 'which-key-description-replacement-alist '("init/\\(.+\\)" . "\\1"))
    (which-key-setup-side-window-right-bottom)
    (which-key-mode)))

Whitespace

(req-package whitespace
  :diminish global-whitespace-mode
  :init
  (setq whitespace-style
        '(face tabs newline trailing tab-mark space-before-tab space-after-tab))
  (global-whitespace-mode 1))

GUI

Theme

Use solarized

(req-package solarized-theme
  :init
  (progn
    (setq solarized-distinct-fringe-background t)
    (setq solarized-use-more-italic t)
    (setq solarized-scale-org-headlines nil)
    (setq solarized-use-variable-pitch nil)))

Powerline

(req-package powerline)

Other settings

Exec path from shell

Get the path from a shell on a Mac

(req-package exec-path-from-shell
  :init
  (progn
    (when (memq window-system '(mac ns))
      (exec-path-from-shell-initialize))))

Load packages

(req-package-finish)

Post package settings

Bells

(setq ring-bell-function
      (lambda ()
        (unless (memq this-command
                      '(isearch-abort
                        abort-recursive-edit
                        exit-minibuffer
                        keyboard-quit
                        evil-scroll-down
                        evil-scroll-up
                        mwheel-scroll
                        down
                        up
                        next-line
                        previous-line
                        backward-char
                        forward-char))
          (ding))))

Visual lines

(setq-default visual-line-fringe-indicators '(left-curly-arrow right-curly-arrow))
(add-hook 'text-mode-hook 'turn-on-visual-line-mode)
(add-hook 'prog-mode-hook 'turn-on-visual-line-mode)
(diminish 'visual-line-mode "")

Highlight lines

(global-hl-line-mode)

Empty lines

(toggle-indicate-empty-lines)

Tab behaviour

(setq-default indent-tabs-mode nil)
(electric-indent-mode 1)

Host settings

Per host settings

(setq initial-scratch-message (init/initial-scratch-message))
(set-face-attribute 'default nil :family "Menlo")
(set-face-attribute 'default nil :weight 'normal)
(set-face-attribute 'default nil :height 140)
(init/solarized-dark-theme)
(let ((host (init/hashed-host-slug))
      (desktop "24e0c4b6b602908fd5cc6be519f8d96b")
      (laptop "1808cc85340608cde18d5cab8b3be29d"))
  (message (concat "init/hashed-host-slug=" host))
  (when (equal host desktop)
    (progn
      (when window-system (set-frame-size (selected-frame) 100 60))
      (set-face-attribute 'default nil :height 170)))
  (when (equal host laptop)
    (progn
      (when window-system (set-frame-size (selected-frame) 120 46))
      (set-face-attribute 'default nil :height 130))))

# and a € on a Mac

Insert a # with Option-3 on a Mac

(defun insert-pound ()
  "Inserts a pound into the buffer"
  (interactive)
  (insert "#"))
(bind-key* "M-3" #'insert-pound)
(defun insert-euro ()
  "Inserts a euro into the buffer"
  (interactive)
  (insert ""))
(bind-key* "M-2" #'insert-euro)

Yes or no prompts

(fset 'yes-or-no-p 'y-or-n-p)

Backups and autosave files

Place them in the tmp directory

(setq backup-directory-alist
      `((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
      `((".*" ,temporary-file-directory t)))

Global auto-revert

(global-auto-revert-mode)

Other GUI settings

Disable toolbar and scrollbar

(when (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(when (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))

Only display the menu bar when on a GUI

(unless (display-graphic-p) (menu-bar-mode -1))

Be quiet

(setq inhibit-splash-screen t)
(setq inhibit-startup-echo-area-message t)
(setq inhibit-startup-message t)

Change buffer font sizes with Super-{-=0}

(setq text-scale-mode-step 1.1)
(bind-key "s-=" '(lambda () (interactive) (text-scale-increase 1)))
(bind-key "s--" '(lambda () (interactive) (text-scale-decrease 1)))
(bind-key "s-0" '(lambda () (interactive) (text-scale-set 0)))

Change frame font sizes with Super-Shift-{-=}

(bind-key "s-+" '(lambda () (interactive) (init/change-frame-font-height +10)))
(bind-key "s-_" '(lambda () (interactive) (init/change-frame-font-height -10)))

Go into full screen with Super-F

(bind-key "s-F" 'toggle-frame-fullscreen)

Move the position of underlines to the bottomline instead of the baseline

(setq x-underline-at-descent-line t)

Disable blinking cursors

(blink-cursor-mode 0)

About

My emacs config

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published