Skip to content

luka-n/emacs-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Emacs

Table of Contents

Applications

Full-blown stand-alone applications inside Emacs.

ERC

Don’t spam channels with joins/parts.

(setq erc-hide-list '("JOIN" "PART" "QUIT"))

Of course give server buffers proper names…

(setq erc-rename-buffers t)

Highlight nicknames with unique colors.

(use-package erc-hl-nicks)

Notifications

Will configure proper notifications some day, for now this is just channel tracking.

Channel tracking is enabled by default. Let’s just ignore some noise.

(setq erc-track-exclude-server-buffer t
      erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE"
                                "324" "329" "332" "333" "353" "477")
      erc-track-shorten-start 3
      erc-track-visibility 'selected-visible)

Reconnecting

Auto reconnect is quite troublesome. It would be great if ERC could watch for network status changes, disconnect when the network goes down, and reconnect once it comes back up. Could be done through NetworkManager’s D-Bus interface.

(setq erc-server-auto-reconnect nil)

ZNC

Integrate with ZNC.

(use-package znc
  :init
  (setq znc-detatch-on-kill nil))

Gnus

Actual account configuration should be in scratch.el.

Archive nothing, it’s on the server.

(setq gnus-message-archive-group nil)

Group by topic.

(add-hook 'gnus-group-mode-hook 'gnus-topic-mode)

Add BBDB for contact management.

(use-package bbdb
  :config
  (bbdb-initialize 'gnus 'message)
  (bbdb-mua-auto-update-init 'gnus 'message))

Org

Agenda

(setq org-agenda-files `(,org-directory))

Appearance

(use-package org-indent
  :diminish org-indent-mode
  :init
  (setq org-startup-indented t))

Capture

(setq org-default-notes-file
      (expand-file-name "notes.org" org-directory))

Code Blocks

(setq org-src-fontify-natively t
      org-src-tab-acts-natively t)

Table of Contents

(use-package toc-org
  :hook
  (org-mode . toc-org-enable))

Better Defaults

Better defaults for core Emacs things.

Like shorter yes-or-no prompts.

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

And don’t leave backup files lying around, I have no use for them.

(setq auto-save-default nil)            ; #* files
(setq make-backup-files nil)            ; *~ files

Use regexp search by default.

(define-key global-map (kbd "C-r") 'isearch-backward-regexp)
(define-key global-map (kbd "C-s") 'isearch-forward-regexp)

Some more unrelated settings–

(setq echo-keystrokes 0.1
      inhibit-startup-screen t
      initial-major-mode 'emacs-lisp-mode
      scroll-conservatively 100
      uniquify-buffer-name-style 'forward
      mouse-yank-at-point t)

Buffer Management

Use Ibuffer.

(define-key global-map (kbd "C-x C-b") 'ibuffer)

Scratch Buffers

Easily jump to scratch buffer for current major mode.

(use-package scratch)

Display / Interface

Frames

Include current buffer name in frame title.

(setq frame-title-format
      (concat "%b" " - " (invocation-name) "@" (system-name)))

Line Numbers

(use-package linum-mode
  :hook prog-mode)

Mode Line

Show also the column number besides the line number in mode line.

(setq column-number-mode t)

Pretty pretty spaceline.

(use-package spaceline
  :config
  (require 'spaceline-config)
  (spaceline-spacemacs-theme)
  (spaceline-toggle-buffer-encoding-abbrev-off)
  (spaceline-toggle-buffer-size-off)
  (spaceline-toggle-hud-off))

Use anzu to show search status.

(use-package anzu
  :diminish anzu-mode
  :bind
  (("M-%" . 'anzu-query-replace)
   ("C-M-%" . 'anzu-query-replace-regexp))
  :config
  (global-anzu-mode))

Selection

(use-package helm
  :diminish helm-mode
  :bind
  (("C-h a" . 'helm-apropos)
   ("C-x C-f" . 'helm-find-files)
   ("C-x C-m" . 'helm-M-x)
   ("C-x b" . 'helm-mini)
   ("M-x" . 'helm-M-x)
   ("M-y" . 'helm-show-kill-ring)
   :map helm-map
   ("<tab>" . 'helm-execute-persistent-action)
   ("C-i" . 'helm-execute-persistent-action)
   ("C-z" . 'helm-select-action))
  :init
  (setq helm-split-window-default-side 'same)
  :config
  (require 'helm-config)
  (helm-mode))

Also throw in helm-descbinds:

(use-package helm-descbinds
  :config
  (helm-descbinds-mode))

Theme

(use-package cyberpunk-theme
  :config
  (load-theme 'cyberpunk t))

Toolbars

No, please, and thank you.

(menu-bar-mode -1)
(scroll-bar-mode -1)
(tool-bar-mode -1)

Windows

Nicely allow for undoing window configuration changes.

(winner-mode)

Faster window switching.

(define-key global-map (kbd "<C-tab>") 'other-window)

Try to establish with Emacs an understanding, that windows must not be disturbed?

(setq display-buffer-base-action '(display-buffer-same-window))

That goes for you too, Org Mode!

(setq org-src-window-setup 'current-window)

Zooming

I just want a global zoom, why so difficult?

(use-package default-text-scale
  :init
  (setq default-text-scale-amount 10)
  :bind
  (("C-+" . 'default-text-scale-increase)
   ("C--" . 'default-text-scale-decrease)
   ("C-0" . 'default-text-scale-reset))
  :config
  (default-text-scale-mode))

Need to define our own reset function–

(defvar default-text-scale-default-height 90)

(defun default-text-scale-reset ()
  (interactive)
  (default-text-scale-increment
    (- default-text-scale-default-height
       (face-attribute 'default :height))))

Editing

Auto Pair

(electric-pair-mode)

Completion

(use-package company
  :diminish company-mode
  :init
  (setq company-idle-delay 0.1
        company-minimum-prefix-length 2
        company-selection-wrap-around t)
  :config
  (global-company-mode))
(use-package helm-company
  :after company
  :bind
  (:map company-mode-map
   ("C-:" . 'helm-company)
   :map company-active-map
   ("C-:" . 'helm-company)))

Filling

(add-hook 'prog-mode-hook (lambda () (setq fill-column 80)))
(add-hook 'text-mode-hook (lambda () (setq fill-column 72)))

Highlighting

Always highlight matching parens.

(show-paren-mode)

Highlight current line.

(use-package hl-line
  :hook
  ((prog-mode text-mode) . hl-line-mode))

Also highlight surrounding parentheses.

(use-package highlight-parentheses
  :diminish highlight-parentheses-mode
  :hook
  ((emacs-lisp-mode lisp-mode) . highlight-parentheses-mode)
  :init
  (setq hl-paren-colors '("#2aa198"
                          "#b58900"
                          "#268bd2"
                          "#6c71c4"
                          "#859900"
                          "#b58900"
                          "#268bd2"
                          "#6c71c4"
                          "#859900")))

Highlight regions affected by undo, yank, kill, and some others.

(use-package volatile-highlights
  :diminish volatile-highlights-mode
  :custom-face
  (vhl/default-face ((t (:background "#077f07"))))
  :config
  (volatile-highlights-mode))

Indentation

(setq standard-indent 2)
(setq-default indent-tabs-mode nil)

Try to be smart about file local indentation styles.

(use-package dtrt-indent
  :diminish dtrt-indent-mode
  :config
  (dtrt-indent-global-mode))

Movement

Recognize subwords.

(use-package subword
  :diminish subword-mode
  :config
  (global-subword-mode))

Jumping

(use-package ace-jump-mode
  :init
  (setq ace-jump-mode-scope 'window)
  :bind
  (("C-c SPC" . ace-jump-mode)))

Define a special Ace Jump command to jump to parens.

(defun ace-jump-parentheses ()
  (interactive)
  (ace-jump-char-mode ?\())

(define-key emacs-lisp-mode-map (kbd "C-c SPC") 'ace-jump-parentheses)
(define-key lisp-mode-map (kbd "C-c SPC") 'ace-jump-parentheses)

Multiple Cursors

(use-package multiple-cursors
  :bind
  (("C-S-c C-S-c" . 'mc/edit-lines)
   ("C->" . 'mc/mark-next-like-this)
   ("C-<" . 'mc/mark-previous-like-this)
   ("C-c C-<" . 'mc/mark-all-like-this)))

Selection

(use-package expand-region
  :bind
  (("C-=" . 'er/expand-region)))

Structured Editing

(use-package paredit
  :diminish paredit-mode
  :hook ((emacs-lisp-mode lisp-mode) . paredit-mode))

Templates

(use-package yasnippet
  :diminish yas-minor-mode
  :config
  (yas-global-mode))

Undo

(use-package undo-tree
  :diminish undo-tree-mode
  :config
  (global-undo-tree-mode))

Whitespace

(use-package whitespace
  :diminish whitespace-mode
  :init
  (setq whitespace-line-column 80       ; use fill-column
        whitespace-style
        '(face trailing lines-tail empty tabs tab-mark))
  :hook
  (prog-mode . whitespace-mode)
  :custom-face
  (whitespace-trailing ((t (:background "#f00")))))

File Management

Dired

Let’s not litter dired buffers everywhere; reuse current buffer.

(use-package dired-single
  :after dired
  :config
  (define-key dired-mode-map [return] 'dired-single-buffer)
  (define-key dired-mode-map [mouse-1] 'dired-single-buffer-mouse)
  (define-key dired-mode-map "^"
    (function
     (lambda () (interactive) (dired-single-buffer "..")))))

Git Status and More Colors

Might have issues cleaning up its locks. See–

emacsorphanage/dired-k#45

(use-package dired-k
  :init
  (add-hook 'dired-after-readin-hook #'dired-k-no-revert)
  (add-hook 'dired-initial-position-hook 'dired-k)
  :config
  (define-key dired-mode-map (kbd "g") 'dired-k))

Inline Subtree Navigation

(use-package dired-subtree
  :init
  (define-key dired-mode-map (kbd "TAB") 'dired-subtree-toggle))

TRAMP

(setq tramp-default-method "ssh")

Keys

Completion

Popup possible completions for incomplete key commands.

(use-package which-key
  :diminish which-key-mode
  :config
  (which-key-mode))

Languages / Major Modes

C/C++

Function Arguments

(use-package c-eldoc
  :diminish eldoc-mode
  :hook
  ((c-mode c++-mode) . c-turn-on-eldoc-mode))

CoffeeScript

(use-package coffee-mode
  :init
  (setq coffee-tab-width 2))

Common Lisp

Function Arguments

(use-package eldoc
  :diminish eldoc-mode
  :hook
  (lisp-mode . eldoc-mode))

SLIME

(use-package slime
  :init
  (setq inferior-lisp-program "/usr/bin/sbcl")
  :bind
  (:map slime-prefix-map
   ("M-h" . 'slime-documentation-lookup))
  :config
  (add-to-list 'slime-contribs 'slime-fancy)
  (slime-setup))

(use-package slime-company
  :after slime
  :config
  (add-to-list 'slime-contribs 'slime-company)
  (slime-setup))

Dockerfile

(use-package dockerfile-mode)

Emacs Lisp

Common Lisp Compatibility

Make emacs-lisp-mode behave more like we’re used to from lisp-mode.

(define-key emacs-lisp-mode-map (kbd "C-c C-c") 'eval-defun)
(define-key emacs-lisp-mode-map (kbd "C-c C-k") 'eval-buffer)

Along with SLIME navigation.

(use-package elisp-slime-nav
  :diminish elisp-slime-nav-mode
  :hook
  (emacs-lisp-mode . elisp-slime-nav-mode))

Function Arguments

(use-package eldoc
  :diminish eldoc-mode
  :hook
  (emacs-lisp-mode . eldoc-mode))

Gherkin

(use-package feature-mode)

HAML

(use-package haml-mode)

HTML

(use-package web-mode
  :init
  (setq web-mode-block-padding 2
        web-mode-script-padding 2
        web-mode-style-padding 2)
  :mode
  ("\\.[agj]sp\\'"
   "\\.as[cp]x\\'"
   "\\.djhtml\\'"
   "\\.erb\\'"
   "\\.html?\\'"
   "\\.mustache\\'"
   "\\.phtml\\'"
   "\\.tpl\\.php\\'"))

JavaScript

(use-package js2-mode
  :init
  (setq js2-strict-missing-semi-warning nil
        js2-strict-trailing-comma-warning nil)
  :interpreter "node"
  :mode "\\.js\\'")

JSX

Use rjsx-mode for this, for now. Works better than js2-jsx-mode.

(use-package rjsx-mode :mode "\\.jsx\\'")

JSON

(use-package json-mode)

Lua

(use-package lua-mode
  :interpreter "lua"
  :mode "\\.lua\\'")

Perl

(defalias 'perl-mode 'cperl-mode)

Ruby

(use-package ruby-mode
  :mode
  ("Capfile\\'"
   "Gemfile\\'"
   "Guardfile\\'"
   "Rakefile\\'"
   "\\.rake\\'"
   "config\\.ru\\'"))

Bundler

(use-package bundler)

Rails

(use-package projectile-rails
  :diminish projectile-rails-mode
  :config
  (projectile-rails-global-mode))

Robe

(use-package robe
  :diminish robe-mode
  :hook
  (ruby-mode . robe-mode)
  :config
  (with-eval-after-load 'company
    (add-to-list 'company-backends 'company-robe)))

RSpec Mode

(use-package rspec-mode
  :config
  (rspec-install-snippets))

Rubocop

(use-package rubocop
  :hook (ruby-mode . rubocop-mode))

Shell

(setq sh-basic-offset 2)
(setq sh-indentation 2)

Slim

(use-package slim-mode)

YAML

(use-package yaml-mode
  :mode "\\.yml\\'")

Project Management

(use-package projectile
  :bind-keymap
  ("C-c p" . projectile-command-map)
  :config
  (projectile-mode))

Definitely use with Helm.

(use-package helm-projectile
  :config
  (helm-projectile-on))

Session Management

Remember things.

(savehist-mode)
(toggle-save-place-globally)

Syntax Checking

(use-package flycheck
  :diminish flycheck-mode
  :init
  (setq flycheck-indication-mode nil)
  :config
  (global-flycheck-mode))

Version Control

History Browsing

(use-package git-timemachine)

Line Status Indicator

(use-package git-gutter-fringe
  :diminish git-gutter-mode
  :config
  (global-git-gutter-mode)
  (fringe-helper-define 'git-gutter-fr:added nil
    ".XXXXXX."
    "XX....XX"
    "X......X"
    "X......X"
    "XXXXXXXX"
    "XXXXXXXX"
    "X......X"
    "X......X")
  (fringe-helper-define 'git-gutter-fr:deleted nil
    "XXXXXX.."
    "XX....X."
    "XX.....X"
    "XX.....X"
    "XX.....X"
    "XX.....X"
    "XX....X."
    "XXXXXX..")
  (fringe-helper-define 'git-gutter-fr:modified nil
    "XXXXXXXX"
    "X..XX..X"
    "X..XX..X"
    "X..XX..X"
    "X..XX..X"
    "X..XX..X"
    "X..XX..X"
    "X..XX..X"))

Magit

(use-package magit
  :config
  (define-key magit-mode-map [C-tab] nil))

Open In Browser

(use-package git-link
  :init
  (setq git-link-open-in-browser t))

About

23:1 Emacs is my editor; I shall not want.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published