After I set up a basic development environment on my Samsung XE303C12 Chromebook (details in this previous post), I wanted to customize my Emacs installation to better fit my workflow (Ruby on Rails web development, in particular). Here’s the list of things I did:
- Set up MELPA
- Installed a theme (flatland-black)
- Added a mode (web-mode)
I use MELPA (in addition to ELPA) to manage my Emacs packages. I really don’t have an opinion on the MELPA vs. Marmalade debate: once upon a time I used MELPA and it’s worked for me, so I haven’t put any more thought into it. For the base installation of Emacs installed via apt-get, I couldn’t find any of the common initialization files: no .emacs, no .emacs.d/init.el, and no site-start.el. I made a .emacs file in my home directory and added the following, cribbed from , to enable MELPA packages:
(require 'package) ;; You might already have this line (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) (when (< emacs-major-version 24) ;; For important compatibility libraries like cl-lib (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))) (package-initialize) ;; You might already have this line
A New Theme
After getting MELPA working, I wanted to install a new Emacs theme. I like light-on-dark themes and syntax highlighting for editing code and text, so I wanted a theme that offered those things. I’ve used flatland-black in the past, so I decided to go with that again this time. I suppose if I ever switch to Sublime Text I’ll be in good shape, as this is a port of one of its themes for Emacs. I installed the theme from within Emacs via:
M-x package-install RET flatland-theme
Where M indicates the meta-key (alt, typically) and RET indicates you press enter/return and it’ll prompt you for input; in this case, it wants the package name you’d like to install.
I then edited my .emacs file to have the theme load on startup by adding the following to the end (after the MELPA block we added earlier):
(load-theme 'flatland-black t)
package-list-package opens a mini-buffer with a list of all the packages available in the repositories told Emacs it can look in. Then, I paged down to web-mode, selected it, switched to the newly opened mini-buffer that shows some details about it, and chose install. I opened a .erb file and used M-x web-mode RET to ensure that the mode loaded correctly.
After I was sure that the mode worked, I edited my .emacs file so that web-mode would automatically be started when I opened embedded Ruby (and some additional) files; The following is cribbed from :
(require 'web-mode) (add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode)) (add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode)) (add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode)) (add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode)) (add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode)) (add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode)) (add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))