packages

Instant scratch buffer for current mode

When emacs launches it will typically show the *scratch* buffer, which is in lisp mode by default, and is useful for making rough notes and evaluating bits of lisp code.

You can chose the default mode of the scratch buffer by setting the variable initial-major-mode as described on emacs redux. So if you want it to be in text mode, use

(setq initial-major-mode 'text-mode)

Today I wanted a scratch buffer in org-mode for some rough work with a table. I could have switched to the scratch buffer and used M-x org-mode to switch the major mode of the scratch buffer, but I found a nicer solution. I installed the package scratch and added the following to my emacs config file:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; multiple scratch buffers                                               ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; uses package "scratch"
(autoload 'scratch "scratch" nil t)

With this package, if you use M-x scratch it will launch a scratch buffer for the current mode. So in my org-mode buffer, using this command gave me a scratch buffer called *org* where I could put my temporary org scribblings.

Advertisement

Install packages

Many of the tips I cover here will work with standard emacs, but sometimes we will need to have extra packages installed for additional functionality.

Installing packages in emacs is a bit like adding extensions to your browser – they add lots of extra functionality that can be very useful.

The easiest way to install packages is to use the command package-list-packages and them search for the package you want (using e.g. C-s) and then mark it for installation by pressing i and then install all marked packages by pressing x.

Packages are available from various sources, and to get the best selection you should add the following to your emacs config file to add the MELPA package repository, and then restart emacs:

;;Add MELPA repository
(add-to-list 'package-archives
             '("melpa" . "http://melpa.org/packages/") t)

You might also consider adding MELPA-stable and marmalade, but MELPA should be fine for most things.

We will need to install packages for some of the future tips I will cover, but in the mean time, have a look through the list of available packages and be impressed with the huge potential!