Tech – Getting started with my own .emacs.d

Ever since I got back into using OrgMode full-time, I’ve been using Emacs every single minute of using a computer. In fact, these days, I can’t even function without Emacs and OrgMode.

Naturally, it follows, that just like the days when I dived deep into Vim, I’m diving into Emacs these days.

I got interested in Emacs again because of BG’s dotemacs, but to truly become familiar, I had to create my own configuration files. It was a great way to learn Emacs Lisp. I have breezed through the initial chapters of the Emacs Lisp Manual and after getting introduced to Clojure recently, Lisp and functional programming doesn’t seem that alien any more.

I bumped into Cask and Pallet last week (probably via Emacs-Reddit) and that gave me impetus to kickstart my own .emacs.d over the weekend.

 \-> .emacs.d
      \-> Cask
      \-> init.el

Contents of the file :


if [[ ! -e ~/.cask ]]
    echo "Cloning Cask repo"
    git clone ~/.cask

if [[ $(grep "cask/bin" ~/.bash_profile) == "" ]]
    echo "Adding \$HOME/.cask/bin to \$PATH in ~/.bash_profile"
    echo '' >> ~/.bash_profile
    echo "# Added by ~/.emacs.d/" >> ~/.bash_profile
    echo "export PATH=\$HOME/.cask/bin:\$PATH" >> ~/.bash_profile

export PATH=$HOME/.cask/bin:$PATH

cd ~/.emacs.d
cask install

# For Python / ELPY
# Prerequisite: Install Python as per:
pip install --upgrade elpy flake8 rope jedi ipython

Contents of the file Cask initially was (I’ve added more packages now, but this is the minimal list of packages that I would use, although ELPY is optional if you don’t use Python):

(source "gnu" "")
(source "melpa" "")
(source "marmalade" "")
(source "org" "")

(depends-on "ack-and-a-half")
(depends-on "cask")
(depends-on "elpy")
(depends-on "exec-path-from-shell")
(depends-on "flx-ido")
(depends-on "magit")
(depends-on "pallet")
(depends-on "projectile")
(depends-on "yasnippet")
(depends-on "zenburn-theme")

A minimal init.el looks like:

;; /This/ file (~init.el~) that you are reading
;; should be in this folder
(add-to-list 'load-path "~/.emacs.d/")

;; Package Manager
;; See ~Cask~ file for its configuration
(require 'cask "~/.cask/cask.el")

;; Keeps ~Cask~ file in sync with the packages
;; that you install/uninstall via ~M-x list-packages~
(require 'pallet)

;; Root directory
(setq root-dir (file-name-directory
                (or (buffer-file-name) load-file-name)))

;; Theme
(load-theme 'zenburn t)
(set-cursor-color "firebrick")

;; Font
(set-frame-font "Fira Mono OT-14" nil t)

;; Don't show startup screen
(setq inhibit-startup-screen t)

;; Show keystrokes
(setq echo-keystrokes 0.02)

;; Path
(require 'exec-path-from-shell)
(when (memq window-system '(mac ns))

;; Git
(require 'magit)
(eval-after-load 'magit
  (progn '(global-set-key (kbd "C-x g") 'magit-status)))

;; flx-ido completion system, recommended by Projectile
(require 'flx-ido)
(flx-ido-mode 1)
;; change it if you have a fast processor.
(setq flx-ido-threshhold 1000)

;; Project management
(require 'ack-and-a-half)
(require 'projectile)

;; Snippets
(require 'yasnippet)
(yas-load-directory (concat root-dir "snippets"))
(yas-global-mode 1)

;; Python editing
(require 'elpy)

And that’s it, a full-fledged Emacs setup is ready.

The best part is to play around with M-x list-packages and browse around and decide which packages you want to try out and use, when you install a package, it automatically gets added to your Cask file (that’s what Pallet does), so you can convert this .emacs.d folder into a Git repository and sync anywhere and have the same configuration available on multiple machines.

So far, I have resisted many things like evil-mode and started really enjoying using packages such as org-pomodoro and ace-jump-mode.

Getting back to Emacs after a decade has been so much fun.

Published by swaroop