Tech - Getting started with my own .emacs.d

4 minute read

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.

This is how I got started - I created the following files under the .emacs.d directory in my home directory, so it looked like this:

 \-> .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.

Twitter Comments

@arnab_deka says:

@swaroopch did you try prelude or starter kit? I started with that and added customizations on my fork. Lotsa goodies in there.

@vivekbhat9 says:

@swaroopch all the best :) I tried emacs so many times but failed. Happy with VIM, I hope some day ll write A byte of emacs & I ll emacs den

@vivekbhat9 says:

@swaroopch i hope u got my thoughts :) will learn emacs when u will write A Byte of Emacs. Missed few words in last tweet ;)


[Tech] Eight programming lessons learned in 2013 says:

[…] again, I have to make a commitment to throw familiarity away. That is what pushes me to learn to customize Emacs despite already having spent years mastering Vim and spent so much time using PyCharm, […]

Syndrome says:

I'm almost ending my one year(really short) marriage to Vim. Emacs and elisp gets me more excited than Vimscript. As soon as I 'm fully weaned on Emacs, I'm moving. One thing that'll really miss is tabs. Emacs' split window just doesn't cut it. How do you survive without tabs?

swaroop says:

@Syndrome I can imagine the Elisp > Vimscript situation and I agree with that (although in future, Vim will have more Python integration). I do miss tabs, but I have just replaced with creating new frames (i.e. windows) by using `C-x 5 2`.

Tags: ,