Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
1283 lines (1198 sloc) 38.9 KB

Trevoke’s emacs config

Configuration

About

<<babel-init>> Welcome to my emacs configuration. I tinker with this file a lot, so I need a quick way to get to it. I set a bookmark with C-x r m and I can get back here with C-x r b

Minor modes?

I could create here some empty minor modes based on how I think about a buffer, hook those to whatever major modes I care about, and then just hook to the minor mode everywhere else in my configuration

Personal information

(setq user-full-name "Aldric Giacomoni"
      user-mail-address "trevoke@gmail.com")

Additional paths

Themes

(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
;; (load-theme 'mejelly t)

Packages (without package manglement)

(add-to-list 'load-path "~/.emacs.d/packages")

Secrets

API keys, passwords, etc are kept in here. This file is .gitignored.

(load "~/.emacs.d/emacs.secrets" t)

Customizations from customization system

Keeping these separate makes life easier: they get modified when I load a theme and such, and I don’t need that kind of hassle when maintaining my actual configuration, you know? In addition, I do keep some somewhat computer-specific stuff in there, like the font, and it’s just easier to have this separated there.

(setq custom-file "~/.emacs-custom.el")
(load custom-file t) ;; t means no error if file does not exist

Package management

The package manager: use-package

I use =use-package=, because:

  1. it is integrated within emacs.
  2. it allows me to set up emacs on any OS I desire more easily than other options I’ve encountered so far
  3. it allows me to easily share / steal configuration snippets

The configuration for it is inside the init.el because I need to make sure org-mode is loaded before I use any org-mode functions… And parsing this org-mode file into code is an org-mode function.

A new package browser

(use-package paradox)

General emacs config (no external packages)

Yes/No => y/n

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

Visual choices

(setq inhibit-startup-screen t)
(setq initial-scratch-message nil)
(show-paren-mode t)
(setq show-paren-delay 0)
(global-hl-line-mode t)
(setq column-number-mode t)
(setq ring-bell-function 'ignore)
(setq visible-bell t)
(setq system-uses-terminfo nil)

This shows the file path in the GUI header

(setq-default frame-title-format
              '((:eval (if (buffer-file-name)
                           (abbreviate-file-name (buffer-file-name))
                         "%f"))))

Backups

Centralize emacs backups. This directory is gitignored.

(setq backup-directory-alist '(("." . "~/.emacs.d/backups")))

And I’m not super-worried about old backups and other such things, so I’ll just tell emacs to stop worrying about it.

(setq delete-old-versions -1)
(setq version-control t)
(setq vc-make-backup-files t)
(setq auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save-list/" t)))

History

Stolen from https://www.wisdomandwonder.com/wp-content/uploads/2014/03/C3F.html

(setq savehist-file "~/.emacs.d/savehist")
(savehist-mode 1)
(setq history-delete-duplicates t)
(setq savehist-save-minibuffer-history 1)
(setq savehist-additional-variables
      '(kill-ring
        search-ring
        regexp-search-ring))

Window config (Put OSX stuff somewhere else)

I don’t really care about any of the extra details - emacs helps me out enough in other ways.

(when window-system
  (tooltip-mode -1)
  (tool-bar-mode -1)
  (menu-bar-mode -1)
  (scroll-bar-mode -1))

Although of course if you’re on OSX, at least the menu bar can be enabled since the mighty OSX top bar won’t ever disappear. And I’ve also added other OSX-specific stuff here… For now.

(when (memq window-system '(mac ns))
  (setq mac-command-modifier 'super)
  (setq mac-option-modifier 'meta)
  (use-package exec-path-from-shell
    :config
    (exec-path-from-shell-initialize))
  (setq ns-use-srgb-colorspace t)
  (menu-bar-mode t))

UTF-8

;; Activate UTF-8 mode:
(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)

;; 2013-12-10 IRC #Emacs
(set-clipboard-coding-system 'utf-8)

;; http://www.masteringemacs.org/articles/2012/08/09/working-coding-systems-unicode-emacs/
;; in addition to the lines above:

(set-default-coding-systems 'utf-8)
;; backwards compatibility as default-buffer-file-coding-system
;; is deprecated in 23.2.
(if (boundp 'buffer-file-coding-system)
    (setq-default buffer-file-coding-system 'utf-8)
  (setq default-buffer-file-coding-system 'utf-8))
;; Treat clipboard input as UTF-8 string first; compound text next, etc.
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))

Buffer management

I like unique buffer names. Enter uniquify.

(require 'uniquify)
(setq
  uniquify-buffer-name-style 'post-forward
  uniquify-separator ":")

Also, ibuffer is nicer than plain-old buffer window

(global-set-key (kbd "C-x C-b") 'ibuffer-other-window)
(setq ibuffer-default-sorting-mode 'major-mode)

Scrolling

(setq scroll-step 1)
(setq scroll-conservatively 10000)
(setq auto-window-vscroll nil)
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;; one line at a time
(setq mouse-wheel-progressive-speed nil) ;; don't accelerate scrolling
(setq mouse-wheel-follow-mouse t) ;; scroll window under mouse

Frame management

Transparency

(use-package seethru :pin "melpa")

Window management

[#B] Window layout manager (eyebrowse)

Prefix key is C-c C-w

(use-package eyebrowse
  :init (setq eyebrowse-new-workspace t)
  :config (eyebrowse-mode))

Winner-mode (undo/redo window changes)

Remember: C-c <left> and C-c <right>

(winner-mode)

Windmove (move across windows with shift+arrow)

(windmove-default-keybindings)
(add-hook 'org-shiftup-final-hook 'windmove-up)
(add-hook 'org-shiftleft-final-hook 'windmove-left)
(add-hook 'org-shiftdown-final-hook 'windmove-down)
(add-hook 'org-shiftright-final-hook 'windmove-right)

Move to new window when splitting

Taken from http://www.reddit.com/r/emacs/comments/25v0eo/you_emacs_tips_and_tricks/chldury

(defun stag-vsplit-last-buffer (prefix)
  (interactive "p")
  (split-window-vertically)
  (other-window 1 nil)
  (unless prefix
          (switch-to-next-buffer)))

(defun stag-hsplit-last-buffer (prefix)
  (interactive "p")
  (split-window-horizontally)
  (other-window 1 nil)
  (unless prefix
    (switch-to-next-buffer)))

(global-set-key (kbd "C-x 2") 'stag-vsplit-last-buffer)
(global-set-key (kbd "C-x 3") 'stag-hsplit-last-buffer)

Interacting with emacs

Fonts and stuff

I found this function online somewhere, before I thought tracking code origin for this config file might matter. All it does is tell you what face is at point.

(defun stag-what-face (pos)
  (interactive "d")
  (let ((face (or (get-char-property pos 'read-face-name)
                  (get-char-property pos 'face))))
    (if face (message "Face: %s" face) (message "No face at %d" pos))))

evil-mode

Because sometimes, vim.

(use-package evil)

Folding code

(use-package origami
  :pin "melpa"
  :config (global-origami-mode))

Disable C-z to minimize

Suspend emacs? I’ll use C-x C-z.

(global-unset-key (kbd "C-z"))

Navigating text

avy is kinda badass.

(use-package avy
    :bind (("C-c j" . avy-goto-char-2)
           ("C-x j" . avy-po-mark)))

Discovering emacs through fuzzy matching

ivy

Apparently ivy is like ido but cooler, sooooooo

(use-package ivy
  :diminish ivy-mode
  :init
  (use-package flx)
  (use-package smex)
  :config
  (use-package swiper)
  (ivy-mode 1)
  ;; From http://oremacs.com/2016/01/06/ivy-flx/
  (setq ivy-re-builders-alist '((swiper . ivy--regex-plus)
                                (counsel-ag . ivy--regex-plus)
                                (ivy-switch-buffer . ivy--regex-plus)
                                (t . ivy--regex-fuzzy))
        ivy-initial-inputs-alist nil
        ivy-use-virtual-buffers t))

(use-package counsel
  :config
  (use-package smex)
  :bind (("C-x C-m" . counsel-M-x)
         ("C-x m" . counsel-descbinds)
         ;; ("C-h f" . counsel-describe-function)
         ;; ("C-h v" . counsel-describe-variable)
         ("C-y" . counsel-yank-pop)))

Extending emacs with engines

Completion

company-mode

(use-package company)

Snippets

Snippets; when you’ve tried ‘em, it’s hard to do without ‘em. I mean, keystrokes, who needs ‘em, right?

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

Project navigation

Projectile is pretty sweet.

(use-package projectile
  :diminish projectile-mode
  :init
  :config
  (use-package ivy)
  (projectile-global-mode)
  (setq projectile-completion-system 'ivy))

Searching

Anzu (about search results)

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

Silver searcher + Wgrep-ag

Sometimes after you’ve found a bunch of things, you want to edit.. Kind of a find-and-replace sort of deal, maybe?

I forget the basic keybindings all the time: After a search using ag, use C-c C-p to start editing the results buffer, and use C-c C-c to save the changes and C-c C-k to cancel.

(use-package ag
  :config
  (setq ag-reuse-buffers 't)
  (use-package wgrep-ag
    :init  (add-hook 'ag-mode-hook 'wgrep-ag-setup)
    :config (autoload 'wgrep-ag-setup "wgrep-ag")))

Version control

Git

Editing various git files

(use-package gitconfig-mode)

Walking through a file’s history

(use-package git-timemachine)

Magit

Magit is a pretty amazing interface to git.

(use-package magit
  :bind ("C-c g" . magit-status)
  :config (setq magit-last-seen-setup-instructions "1.4.0")
          (setq magit-completing-read-function 'ivy-completing-read)
          (setq magit-popup-use-prefix-argument 'default))
Magit + gitflow

With this configuration, using C-f in a status buffer will trigger the gitflow selectors.

(use-package magit-gitflow
  :config (add-hook 'magit-mode-hook 'turn-on-magit-gitflow))
Github pull requests

This will let us handle pull requests through Github.

keybehavior
# grefresh list of PRs
# ffetch commits for PR
# bcreate topic branch for PR
# mmerge PR on top of currently checked out branch
# ccreate new pull request
# oopen PR in browser
j qjump to PR section in magit-status
;; (use-package magit-gh-pulls
;;  :config (add-hook 'magit-mode-hook 'turn-on-magit-gh-pulls))

Programming

Indentation

Always spaces. Always.

(setq-default indent-tabs-mode nil)
(setq backward-delete-char-untabify-method 'untabify)

code tagging

This is the ggtags plugin, which uses GNU Global.

(use-package ggtags
  :config
  (setq tags-case-fold-search nil)
  :bind ("<f7>" . ggtags-create-tags))

Basic changes I want made to any code buffer

Makes it easy to type things like {} or [] or () and magically add an extra line between the two so you can type there

;; This function comes from http://stackoverflow.com/a/22109370/234025
(defun stag-enter-key-dwim ()
  "Inserts an extra newline between matching separators(?) and indents it, if it can, otherwise behaves like normal enter key"
  (interactive)
  (let ((break-open-pair (or (and (looking-back "{") (looking-at "}"))
                             (and (looking-back ">") (looking-at "<"))
                             (and (looking-back "(") (looking-at ")"))
                             (and (looking-back "\\[") (looking-at "\\]")))))
    (comment-indent-new-line)
    (when break-open-pair
      (save-excursion
        (comment-indent-new-line))
       (indent-for-tab-command))))

Here’s where I plug in every modification I want in a code buffer

(use-package smartparens)

(defun stag-code-modes-hook ()
  "A couple of changes I like to make to my code buffers"
;;    (projectile-mode)
    (linum-mode t)
    (smartparens-mode)
    (yas-minor-mode)
;;    (ggtags-mode)
    (add-hook 'before-save-hook 'whitespace-cleanup)
    (local-set-key "\C-m" 'stag-enter-key-dwim))

(add-hook 'prog-mode-hook 'stag-code-modes-hook)

Expand region

One of the features that makes IDEA’s editors awesome is the way you can expand selection. This plugin replicates the feature.

(use-package expand-region
  :bind (("C-c <up>" . er/expand-region)
         ("C-c <down>" . er/contract-region)))

Log files

Auto-tail, please.

(add-to-list 'auto-mode-alist '("\\.log\\'" . auto-revert-mode))

Cucumber

(use-package feature-mode)

C#

(defun stag-csharp-mode-hook ()
  (setq c-basic-offset 4))

(use-package csharp-mode
  :defer t
  :init
  (add-hook 'csharp-mode-hook 'stag-csharp-mode-hook))

Docker

(use-package docker-compose-mode)
(use-package docker-tramp)
(use-package dockerfile-mode)

emacs lisp

(use-package paredit
  :init
  (add-hook 'lisp-mode-hook 'paredit-mode)
  (add-hook 'emacs-lisp-mode-hook 'paredit-mode))

(add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
(add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode)
(add-hook 'ielm-mode-hook 'turn-on-eldoc-mode)

Elm

(use-package elm-mode)

Elixir

(use-package alchemist
  :diminish "alc"
  :config
  (use-package elixir-yasnippets)
  (use-package flymake-elixir
    :pin "melpa"
    :init (use-package flymake-easy)
          (add-hook 'elixir-mode-hook 'flymake-mode)))

CSS

(setq css-indent-offset 2)

(use-package rainbow-mode
  :pin "gnu"
  :init
  (add-hook 'scss-mode-hook 'rainbow-mode)
  (add-hook 'css-mode-hook 'rainbow-mode))

(use-package scss-mode
  :mode "\\.scss$"
  :init (add-hook 'scss-mode-hook 'flymake-mode))

Golang

Golang mode

Let’s run tests easily, shall we? And let’s have gofmt chew my code when I save the file.

(use-package go-mode
  :bind (:map go-mode-map
              ("C c r s" . go-test-current-file))
  :init
  (defun stag-go-mode ()
    (add-hook 'before-save-hook 'gofmt-before-save nil t)) ;; chew my code
  (add-hook 'go-mode-hook 'stag-go-mode)
  :config
  (use-package company-go
    :config (set (make-local-variable 'company-backends) '(company-go))))

Packages to be added

  • (use-package go-eldoc)
  • (use-package go-playground)
  • (use-package go-projectile)
  • (use-package gore-mode)
  • (use-package gorepl-mode)
  • (use-package gotest)

Haskell

(use-package intero :pin "melpa-stable")

HTML

Web-mode

Here are all the extensions where I want web-mode enabled

(use-package web-mode
  :mode "\\.mustache$" "\\.html$" "\\.erb$" "\\.jsx$" "\\.eex$" "\\.php$"
  :config
  (use-package company-web
    :config
    (add-to-list 'company-backends 'company-web-html)
    (add-to-list 'company-backends 'company-web-jade)
    (add-to-list 'company-backends 'company-web-slim))

  (flycheck-define-checker eslint-checker
    "A JSX syntax and style checker based on JSXHint."

    :command ("eslint" source)
    :error-patterns
    ((error line-start (1+ nonl) ": line " line ", col " column ", " (message) line-end))
    :modes (web-mode))

  (add-hook 'web-mode-hook
            (lambda ()
              (when (equal web-mode-content-type "jsx")
                ;; enable flycheck
                (flycheck-select-checker 'eslint-checker)
                (flycheck-mode))))

  ;; And I think all this should be indented with 2 spaces.
  (setq web-mode-markup-indent-offset 2)
  (setq web-mode-css-indent-offset 2)
  (setq web-mode-code-indent-offset 2)
  (setq web-mode-indent-style 2)

  ;; for better jsx syntax-highlighting in web-mode
  ;; - courtesy of Patrick @halbtuerke
  (defadvice web-mode-highlight-part (around tweak-jsx activate)
    (if (equal web-mode-content-type "jsx")
      (let ((web-mode-enable-part-face nil))
        ad-do-it)
      ad-do-it)))

(use-package emmet-mode
  :init
  (add-hook 'html-mode-hook 'emmet-mode)
  (add-hook 'web-mode-hook 'emmet-mode))

Javascript

Actual JS

js2-mode
(use-package js2-mode
  :mode "\\.js$"
  :init
  (add-hook 'js2-mode-hook 'stag-code-modes-hook)
  :config
  (setq js2-basic-offset 2)
  (setq js2-bounce-indent-p nil) ;; if I want to toggle indentation
  (setq js2-highlight-level 3))
tern-mode

https://truongtx.me/2014/04/20/emacs-javascript-completion-and-refactoring

(use-package tern
  :init (add-hook 'js2-mode-hook 'tern-mode)
  :config
  (use-package company-tern
  :config
  (add-to-list 'company-backends 'company-tern)
  (setq company-tern-meta-as-single-line t)))

(defun delete-tern-process ()
  (interactive)
  (delete-process "Tern"))
inferior mode (Pick one? Keep both?)
(use-package js-comint)
(use-package nodejs-repl)
snippets
(use-package react-snippets
  :pin "melpa")

json-mode

(use-package json-mode :mode "\\.babelrc$")
(use-package json-reformat)

Typescript

REPL
(use-package tide)
On-the-fly checking
(use-package tss
  :config
  (setq tss-popup-help-key "C-:")
  (setq tss-jump-to-definition-key "C->")
  (setq tss-implement-definition-key "C-c i")
  (tss-config-default))
Typescript major mode
(use-package typescript-mode :pin "melpa"
  :init
  (add-hook 'typescript-mode-hook 'flymake-mode))

Python

 (use-package elpy
   :config
   (add-hook 'python-mode-hook 'elpy-enable))
(use-package auto-virtualenv
  :pin "melpa"
  :config
  (add-hook 'python-mode-hook 'auto-virtualenv-set-virtualenv)
  (add-hook 'projectile-after-switch-project-hook  'auto-virtualenv-set-virtualenv))

Ruby

Enh-ruby-mode

There’s a few extra things I want started when I open a Ruby buffer

(defun stag-ruby-mode-hook ()
  (use-package ruby-refactor
    :diminish "rrf"
    :pin "melpa")
  (ruby-refactor-mode-launch)
  (inf-ruby-minor-mode)
  (modify-syntax-entry ?: ".") ;; Adds ":" to the word definition
  (rbenv-use-corresponding))

(use-package enh-ruby-mode
  :pin "melpa"
  :interpreter "ruby"
  :mode "\\.rb$" "Guardfile" "\\.rake$" "\\.pryrc$" "Rakefile" "Capfile" "Gemfile" "\\.ru$"
  :init
  (setq enh-ruby-bounce-deep-indent t)
  (add-hook 'enh-ruby-mode-hook 'stag-code-modes-hook)
  (add-hook 'enh-ruby-mode-hook 'stag-ruby-mode-hook))

Project management

rbenv
(use-package rbenv)
Bundler
(use-package bundler)
Project navigation

And I like projectile-rails to handle rails projects.

(use-package projectile-rails
  :init
   (add-hook 'projectile-mode-hook 'projectile-rails-on))

Inferior Ruby

And I like pry better than irb, so have inf-ruby use pry.

(use-package inf-ruby
  :config
  (setq inf-ruby-default-implementation "pry")
  (use-package company-inf-ruby
    :pin "melpa"
    :config
    (add-to-list 'company-backends 'company-inf-ruby)))

Snippets

I use yasnippets, and I’ve downloaded a collection of snippets from here: https://github.com/bmaland/yasnippet-ruby-mode

Testing

rspec
(use-package rspec-mode)

packages to be added

  • (use-package bundler)
  • (use-package goto-gem)
  • (use-package haml-mode)
  • (use-package slim-mode)
  • (use-package minitest)
  • (use-package rbenv)
  • (use-package robe)
  • (use-package ruby-hash-syntax)
  • (use-package ruby-refactor)
  • (use-package yaml-mode)

Rust

(use-package rust-mode
  :pin "melpa"
  :init
  (add-hook 'rust-mode-hook 'stag-code-modes-hook)
  (add-hook 'rust-mode-hook 'flycheck-mode)
  (add-hook 'rust-mode-hook 'flymake-mode)
  :config
  (use-package flycheck-rust :pin "melpa")
  (use-package flymake-rust :pin "melpa")
  (use-package cargo))

Scala

Ensime is our key to IDE-like features

(defun stag-scala-enable-eldoc ()
  (setq-local eldoc-documentation-function
              (lambda ()
                (when (ensime-connected-p)
                  (ensime-print-type-at-point))))
  (eldoc-mode +1))
(use-package scala-mode)
(use-package sbt-mode)
(use-package play-routes-mode)
(use-package ensime
  :config
  (add-hook 'scala-mode-hook 'ensime-scala-mode-hook)
  (add-hook 'ensime-mode-hook 'stag-scala-enable-eldoc))

SQL

Vertica

;;(use-package vertica :pin "melpa")

sqlup

auto-upcase SQL keywords as I type, please.

(use-package sqlup-mode
  :init
  (add-hook 'sql-mode-hook 'sqlup-mode)
  (add-hook 'sql-interactive-mode-hook 'sqlup-mode))

tintin

I maintain a tintin++ config, so this is at least convenient.

(use-package tintin-mode :pin "marmalade")

Org-mode

org-mode itself is in the init.el file. here’s additional config for it. I’ve been having some issues exporting, so I’m actively loading libraries here.

(load-library "org-macro")
(load-library "ob-exp")
(load-library "org")
(load-library "org-compat")
(load-library "ox")

;; (use-package ox-pandoc)

Generic org-mode configuration

(setq org-src-fontify-natively t)
(add-to-list 'auto-mode-alist '(".org.txt$" . org-mode))

(setq org-directory "~/Google Drive/notes")
(setq org-default-notes-file (concat org-directory "/notes.org.txt"))
(define-key global-map "\C-cc" 'org-capture)

(setq org-capture-templates
      '(
        ("j" "Journal Entry"
         entry (file+datetree "~/journal.org")
         "* %U\n%?"
         :empty-lines 1)
        ("t" "Todo"
         entry (file+headline "~/todo.org" "Tasks")
         "* TODO %?\n  %i\n  %a")
        ))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)

(setq org-startup-indented t)
(setq org-log-done 'time)

(setq org-todo-keywords '( "TODO(t)" "WAIT(w)" "|" "DONE" "CANCELED(c)"))
(setq org-tag-alist '(("@home" . ?h) ("@work" . ?w) ("family") ("weiqi") ("ruby") ("lisp") ("emacs")))

(setq org-mobile-directory "~/Dropbox/orgnotes")
(setq org-mobile-inbox-for-pull "~/Google Drive/notes/from-mobile.org")

Org bullets

(use-package org-bullets
  :init (add-hook 'org-mode-hook 'org-bullets-mode))

Left mouse-click to org-cycle

What? My hands aren’t ALWAYS on the keyboard. This is currently disabled.

;; (defun stag-click-to-cycle-org-visibility ()
;;   (local-set-key [mouse-1] 'org-cycle))
;; (add-hook 'org-mode-hook 'stag-click-to-cycle-org-visibility)

Olivetti

(use-package olivetti
  :init
  (add-hook 'org-mode-hook 'turn-on-olivetti-mode)
  :config
  (setq olivetti-body-width 80))

Markdown

(use-package markdown-mode
  :init
  (add-hook 'markdown-mode-hook 'turn-on-orgtbl))

Github-Flavored Markdown (requires backend config?)

(require 'ox-md)

My orgtbl-to-gfm conversion (obsoleted by above?)

It’s quite nice to use an orgtbl, but GFM is weird. This converts to a GFM table. use C-c C-c to generate / update GFM table.

;;; orgtbl-to-gfm conversion function
;; Usage Example:
;;
;; <!-- BEGIN RECEIVE ORGTBL ${1:YOUR_TABLE_NAME} -->
;; <!-- END RECEIVE ORGTBL $1 -->
;;
;; <!--
;; #+ORGTBL: SEND $1 orgtbl-to-gfm
;; | $0 |
;; -->

(defun orgtbl-to-gfm (table params)
  "Convert the Orgtbl mode TABLE to GitHub Flavored Markdown."
  (let* ((alignment (mapconcat (lambda (x) (if x "|--:" "|---"))
                               org-table-last-alignment ""))
         (params2
          (list
           :splice t
           :hline (concat alignment "|")
           :lstart "| " :lend " |" :sep " | ")))
           (orgtbl-to-generic table (org-combine-plists params2 params))))

(defun stag-insert-org-to-gfm-table (table-name)
  (interactive "*sEnter table name: ")
  (insert "<!---
#+ORGTBL: SEND " table-name " orgtbl-to-gfm

-->
<!--- BEGIN RECEIVE ORGTBL " table-name " -->
<!--- END RECEIVE ORGTBL " table-name " -->")
  (previous-line)
  (previous-line)
  (previous-line))

  (global-set-key (kbd "C-c t") 'stag-insert-org-to-gfm-table)

Blogging

(use-package org-page
  :config
  (setq op/repository-directory "~/src/projects/trevoke.github.io")
  (setq op/personal-github-link "https://github.com/trevoke")
  (setq op/site-domain "http://blog.trevoke.net/")
  (setq op/site-main-title "Seven Steps")
  (setq op/site-sub-title "Words... words, they're all we have to go on! — Rosencrantz and Guildenstern are dead"))

;; (use-package blog-admin
;;   :init
;;   (setq blog-admin-backend-path "~/src/projects/trevoke.github.io")
;;   (setq blog-admin-backend-type 'org-page)
;;   (setq blog-admin-backend-new-post-in-drafts t)
;;   (setq blog-admin-backend-new-post-with-same-name-dir t)
;;   (setq blog-admin-backend-org-page-drafts "_drafts")) ;; directory to save draft
;;        (add-hook 'blog-admin-backend-after-new-post-hook 'find-file))

REPLs

Generic shell things

(use-package shell-command
  :pin "melpa"
  :init (add-hook 'shell-mode-hook 'shell-command-completion-mode))
(use-package xterm-color
  :config
  (add-hook 'comint-preoutput-filter-functions 'xterm-color-filter)
  (setq comint-output-filter-functions (remove 'ansi-color-process-output comint-output-filter-functions))
  (setq font-lock-unfontify-region-function 'xterm-color-unfontify-region))

Bash

(setq explicit-bash-args '("--noediting" "--login" "-i"))
(require 'em-smart)

(use-package bash-completion :config (bash-completion-setup))

;; (defadvice ansi-term (after advise-ansi-term-coding-system)
;;     (set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix))
;; (ad-activate 'ansi-term)

Eshell

(defun eshell/clear ()
  "Clear the eshell buffer."
  (let ((inhibit-read-only t))
    (erase-buffer)
    (eshell-send-input)))

(use-package eshell-did-you-mean
  :config
  (eshell-did-you-mean-setup))

Fish

(use-package fish-mode)

Slime

(use-package slime
  :config
  ;; (load (expand-file-name "~/quicklisp/slime-helper.el"))
  ;; ;; Replace "sbcl" with the path to your implementation
  ;; (setq inferior-lisp-program "clisp")
  )

Writing (specs, docs, blogs…)

Interacting with text

More fine-grained word-by-word navigation

(use-package syntax-subword :config (syntax-subword-mode))

Use visual-line-mode

(remove-hook 'text-mode-hook #'turn-on-auto-fill)
(add-hook 'text-mode-hook 'turn-on-visual-line-mode)

Redefine kill-region and backward-kill-word

I used Bash for a long time. This allows me to keep using Ctrl-w to delete a word backward.

(global-set-key (kbd "C-w") 'backward-kill-word)
(global-set-key (kbd "C-x C-k") 'kill-region)

Move down real line by real line (do I kill this?)

(setq line-move-visual nil)

Sentences end with a single space

(setq sentence-end-double-space nil)

Inserting new lines before/after current one

(defun stag-insert-line-below ()
  "Insert and auto-indent line below cursor, like in vim."
  (interactive)
  (move-end-of-line 1)
  (open-line 1)
  (next-line)
  (indent-for-tab-command))

(defun stag-insert-line-above ()
  "Insert and auto-indent line above cursor, like in vim."
  (interactive)
  (previous-line)
  (move-end-of-line 1)
  (stag-insert-line-below))

(global-set-key (kbd "C-o") 'stag-insert-line-below)
(global-set-key (kbd "C-M-o") 'stag-insert-line-above)

Symbols

(use-package xah-math-input
  :pin "melpa"
  :init
  (add-hook 'text-mode-hook 'xah-math-input-mode)
  (add-hook 'org-mode-hook 'xah-math-input-mode))

TeX

  (require 'flymake)

  (defun flymake-get-tex-args (file-name)
    (list "pdflatex"
          (list "-file-line-error" "-draftmode" "-interaction=nonstopmode" file-name)))


(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq TeX-save-query nil)

(add-hook 'LaTeX-mode-hook 'flymake-mode)

(setq ispell-program-name "aspell") ; could be ispell as well, depending on your preferences
(setq ispell-dictionary "english") ; this can obviously be set to any language your spell-checking program supports

(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(add-hook 'LaTeX-mode-hook 'flyspell-buffer)

(defun stag-turn-on-outline-minor-mode ()
(outline-minor-mode 1))

(add-hook 'LaTeX-mode-hook 'stag-turn-on-outline-minor-mode)
(add-hook 'latex-mode-hook 'stag-turn-on-outline-minor-mode)
(setq outline-minor-mode-prefix "\C-c \C-o") ; Or something else

Presentations

Screencasts

Camcorder is a tool to record screencasts, in GIF or other formats

(use-package camcorder)

Slides [ioslide]

revealjs

;;  (use-package ox-ioslide)
  (use-package ox-reveal
    :pin "melpa"
    :config
    (use-package htmlize)
    (setq org-reveal-root "file:///Users/aldric/src/vendor/reveal.js-3.5.0"))

Email

Add BBDB

Sending email

(setq mail-user-agent 'message-user-agent)

(setq smtpmail-stream-type 'ssl
      smtpmail-smtp-server "smtp.gmail.com"
      smtpmail-smtp-service 465)

smtpmail-multi

(use-package smtpmail-multi
  :pin "melpa"
  :config
  (setq smtpmail-multi-accounts
        (quote
         ((stride . ("aldric@stridenyc.com"
                     "smtp.gmail.com"
                     587
                     "aldric@stridenyc.com"
                     starttls
                     nil nil nil))
          (home . ("trevoke@gmail.com"
                   "smtp.gmail.com"
                   587
                   "trevoke@gmail.com"
                   starttls
                   nil nil nil)))))

  (setq smtpmail-multi-associations
        (quote
         (("trevoke@gmail.com" home)
          ("aldric@stridenyc.com" stride))))

  (setq smtpmail-multi-default-account (quote home))

  (setq message-send-mail-function 'smtpmail-multi-send-it)

  (setq smtpmail-debug-info t)
  (setq smtpmail-debug-verbose t))

Sending/Reading/Encrypting email

(use-package notmuch
  :config
  (defun stag-email-hook ()
    (epa-mail-mode)
    (orgstruct++-mode))

  (add-hook 'notmuch-message-mode-hook 'stag-email-hook))

Communication

ERC

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

Circe

(use-package circe)

Confluence

(use-package confluence :pin "melpa"
  :init
  (setq confluence-url "https://confluence.tapad.com/rpc/xmlrpc"))

Miscellanous

Color themes

(use-package moe-theme :pin "melpa" :disabled t)
(use-package sourcerer-theme :pin "melpa" :disabled t)
(use-package oceanic-theme :pin "melpa" :disabled t)
(use-package material-theme :disabled t)

80-column limit

(use-package fill-column-indicator
  :config
  (setq fci-rule-column 80)
  (add-hook 'prog-mode-hook 'fci-mode))

Interface customization

Smart mode line

(use-package smart-mode-line
  :config
  (setq sml/theme 'dark)
  (sml/setup))

Default text scale

This handy little package increases the size of the font in the whole frame.

(use-package default-text-scale
  :bind (("C-x C-=" . default-text-scale-increase)
         ("C-x C--" . default-text-scale-decrease)))

Calendar, dates, times

(setq calendar-week-start-day 1) ;; Monday

Diary

(setq diary-file "~/Google Drive/diary")

(setq view-diary-entries-initially t
      mark-diary-entries-in-calendar t
      number-of-diary-entries 7)
(add-hook 'diary-display-hook 'diary-fancy-display)
(add-hook 'today-visible-calendar-hook 'calendar-mark-today)

calfw, the calendar framework

;; (use-package calfw
;;   :config
;;   (require 'calfw-cal)
;;   (require 'calfw-ical)
;;   (require 'calfw-org)

;;   (setq cfw:fchar-junction ?╋
;;         cfw:fchar-vertical-line ?┃
;;         cfw:fchar-horizontal-line ?━
;;         cfw:fchar-left-junction ?┣
;;         cfw:fchar-right-junction ?┫
;;         cfw:fchar-top-junction ?┯
;;         cfw:fchar-top-left-corner ?┏
;;         cfw:fchar-top-right-corner ?┓))
calfw-gcal

Here is a sample function where you could put your Google Calendar information (mostly so I remember how to create the secret file on a new computer).

(use-package calfw-gcal) (defun stag-calendar () (interactive) (cfw:open-calendar-buffer :contents-sources (list (cfw:org-create-source “Green”) (cfw:cal-create-source “Orange”) (cfw:ical-create-source “gcal” “gcal-ics-link” “Blue”) )))

File system browsing

Dired

dired-jump is awesome (C-x C-j in any buffer)

(require 'dired-x)
;; Changed my mind. I prefer seeing just the files:
 (add-hook 'dired-mode-hook 'dired-hide-details-mode)

;; Auto-refresh silently
 (setq global-auto-revert-non-file-buffers t)
 (setq auto-revert-verbose nil)

This will make org-mode behave kinda like a two-pane file manager: with two direds open, you can copy/rename and the default target will be the other pane. Using split-window-vertically from the first dired might be required to make this work.

(setq dired-dwim-target t)

OSX.. Windows.. sigh.

(setq ls-lisp-use-insert-directory-program nil)
(require 'ls-lisp)

It’s also nice to have dired with M-< and M-> take you to first and last file

(require 'dired)
(defun dired-back-to-top ()
  (interactive)
  (beginning-of-buffer)
  (next-line 2))

(define-key dired-mode-map
  (vector 'remap 'beginning-of-buffer) 'dired-back-to-top)

(defun dired-jump-to-bottom ()
  (interactive)
  (end-of-buffer)
  (next-line -1))

(define-key dired-mode-map
  (vector 'remap 'end-of-buffer) 'dired-jump-to-bottom)

Tramp

hadoop with tramp, please. C-x C-f /hdfs:username@hadoop-server:/path/to/dir/or/file

(use-package tramp-hdfs :pin "melpa")

Editing Tintin++ config files

;; (use-package tintin-mode)