Skip to content

Baby Steps With Emacs

One at a time


Having recently perused org-mode, I figured I’d give it a shot for a bit to see how I do.

Get a List of Recently Edited Files

On startup it’s handy to recall a recent file, as anything you’re editing you’re likely to have edited recently. There’s a config snippet for that:

(recentf-mode 1)
(setq recentf-max-menu-items 25)
(setq recentf-max-saved-items 25)
(global-set-key "\C-x\ \C-r" 'recentf-open-files)

The emacs wiki has the above snippet and much more.

Emacs and Byobu – Shortcuts and Colours

I am a heavy user of byobu, having used screen for years for remote connections. Unfortunately, screen and emacs kinda step on each other’s keybindings:

Emacs uses ‘C-a’ for ‘beginning-of-line’. It is also the command key for GNU Screen, which causes a problem of “muscle memory impedance matching.”

I could probably live without ‘go to beginning of line’. But there’s another issue: that of colour. Turnspike notes:

It seems that byobu‘s defaults don’t play nice with emacs, eating important key sequences such as <C-h> and breaking color schemes. Adding the following line to ~/.byobu/.tmux.conf fixed the issue:

set -g default-terminal "screen-256color"

along with a link to the byobu bug report on Launchpad.

Now, I’m torn. In org-mode, both colour schemes look good! See:

Both look nice

Or, to be fancy, we can use Jetpack’s image compare for a nifty drag and drop compare:

The non-screen based emacs has a better colour contrast, but at the cost of the top-level headline being quite hard to read against a dark background. Let’s add some more headlines and see how they look:

and the ‘image compare’ version:

I think I’m leaning more towards the former!

Org Mode Bindings Don’t Work in Terminal

This is an annoying one- the org mode manual talks about helpful keybindings for working with various structures like headlines. Unfortunately, many of them, like M-LEFT (org-do-promote) / M-RIGHT (org-do-demote) just don’t seem to work.

A comprehensive search (ie googling “emacs org mode m-left org-do-promote not working”) brought me to this SO answer:

In addition to the keys in my question, S-TAB, S-Left, S-Right, S-Up and S-Down were not working over ssh and PuTTY. Using certain keys on a TTY connection (ssh, screen, PuTTY) is a known issue. Alternative keys are included in org-mode as detailed here. (ed: link dead)

The updated link appears to be ‘Using Org on a TTY‘, and an edit to the old QA has been submitted 🙂

Quickly Add Today’s Date

C-c . for (org-time-stamp). This prompts for a date with the calendar view, which I’m not sure how it works- the blue-on-black text is kinda hard to make out!

Fortunately there is a manual entry for that: the date/time prompt. So you can use relative times like “+2d” for “two days from now”, or even ‘+2tue’ for ‘the second Tuesday from now’ (neat!); and the calendar can be moved with S-<arrow>, > and <, and C / M-v.

Close / Kill a Buffer

C-x k – this probably came up in the tutorial, but I had forgotten. Useful when an org-agenda is hanging around!* There’s also  M-x clean-buffer-list`, which kills buffers unmodified ‘for a long time’.

* Actually, agenda view can be closed with it’s default bindings, q or k. <_< >_>

SCHEDULED confusion

Finding out about scheduling from the otherwise decent Org mode manual reveals a paucity of explanation. The two main references are:

Fortunately there is another reference: an org tutorial on habits.

Oh. also: it’s all-caps like other properties- for some reason I thought it wasn’t necessary to capitalise it despite knowing about the ‘properties are capitalised’ rule.

Stage / commit a file

C-c v v invokes vc-next-action, which out of the box for me git add-ed and subsequently git commit-ed the file. Given I work exclusively with git, checking out Magit (wiki) seems like a good idea!

Run a shell command (in the terminal version)

M-! runs a shell command. Note that because of terminal eating / registering alt/meta differently (see above), I had to use <Esc>-! instead.


1 thought on “Baby Steps With Emacs”

  1. Pingback: Toddler Steps With Emacs – Rob's Blog

Tell us what's on your mind