Emacs 24.1 New Features (released 2012-06)

By Xah Lee. Date: . Last updated: .

This page is a on-going list of tips and tricks about emacs 24. Emacs 24.1 is released on . For download locations for Windows, Mac, Linux, see: Where to Download Emacs for {Windows, Mac, Linux}.

Emacs Package System

New in emacs 24 is a package system. It lets you easily install and manage packages. This is probably the most significant feature in 24. See: Emacs: How to Install Packages Using ELPA, MELPA.


See: Emacs: Insert Parenthesis by Pair: electric-pair-mode

New Command: count-words

A frequently asked command is finally here: count-words. This command will count {lines, words, characters} of the current file. If there is a text selection, then it'll count in that region only.

For how to write simple version of wc in elisp, see: Emacs Lisp: Count Lines, Words, Chars.

Note: emacs's count-words does not give the same result as unix “wc”, and count-words is major mode dependent. (it depends on the major mode's syntax table to determine the delimiters for “word”)

New Command: rectangle-number-lines

rectangle-number-linesCtrl+x r N】 will insert a vertical column of numbers into a block of text, like this:

  1. x
  2. x
  3. x
  4. x

For detail, see: Emacs: Edit Column Text, Rectangle Commands.

occur-edit-mode: Edit Search Output in list matching lines

When using list-matching-lines (aka occur) or multi-occur, you can edit the output, so that the change will happen in the original file. In the output buffer, call occur-edit-modee】. Example:

  1. Open a file, then call occur or multi-occur.
  2. Switch cursor to the output pane.
  3. Call occur-edit-modee】.
  4. Edit. When done, call occur-cease-editCtrl+c Ctrl+c】.
  5. Your changes are made in original file(s) too. You still need to save the file(s).

Thanks to Darren ha for the tip on occur-edit-mode.

See also: interactive find/replace with dired-do-query-replace-regexpSearching for Text in Files (grep, find)

Linux/Emacs Copy/Paste Problem

in GNU Emacs, x-select-enable-clipboard is set to t now. For what it means, see: Emacs: Sync Copy/Paste Clipboards with Linux X11.

Support for Bidirectional Text

➢ for example: { Arabic, Persian (Iran), Hebrew (Israel)}. They flow from right to left.

Paste this paragraph in emacs “(كتاب ألف ليلة و ليلة)”. Then, hold down right arrow key, then when cursor moves into the Arabic text, it'll suddenly reverse direction.

Note, when a buffer's text is all Right To Left (R2L) or all Left To Right (L2R) script, then right-char always move to the right, and forward-char moves depending on context.

When a buffer's text contains mixed R2L/L2R text, then both visually change direction, VISUALLY. But logically, right-char still moves to the right only, LOGICALLY.

This is a fairly complex issue, i don't quite understand. Eli Zaretskii (a long time emacs dev) gave a detailed explanation in this thread: Source groups.google.com.

{beginning-of-defun, end-of-defun} in {C, C++} modes

There's some changes on how the cursor moves when you call {beginning-of-defunCtrl+Alt+↖ Home】, end-of-defunCtrl+Alt+↘ End】} in {C,C++} modes in emacs.

Now, it move the cursor just one level up of a nested block. Before, it moves several levels up to actual function/class definition, out of several nested blocks of code if necessary.

Here's a sample C++ template code you can test on.

namespace my_namespace {

  void func1() {

  void func2() {

  class MyClass {
    MyClass() {

    void method1() {

    void method2() {


Here's a video showing the difference. (Thanks a lot to David Capello.)

《C++ navigation in Emacs 23.4 vs Emacs 24.1》, by David Capello

Unicode 6 Support

Unicode 6 is now supported. For example, call ucs-insertCtrl+x 8 Enter ↵】 then “GRINNING CAT FACE WITH SMILING EYES”, then you get this char 😸.

Note: the char won't display in emacs. First, make sure your system has the font. Best is Symbola. 〔➤see font for Unicode 6〕 But even if you have Symbola installed, emacs won't show the char unless you actually switch to that font. Am not sure there's much one can do to fix this. (Question asked at Source groups.google.com)

Unicode {Space, Hyphen} Chars Display

Certain non-ASCII space and hyphen Unicode characters are displayed with a reddish color to distinguish them from similar ASCII ones. Emacs 24 added 2 more. The complete list of such chars are:

(Copy the above list and paste in emacs to see.) Call describe-variable on nobreak-char-display for detail.

To insert unicode, call ucs-insert. 〔➤see Emacs: Unicode Tutorial

Color Themes

To activate, call load-theme, then press Tab ↹ to show a list of available themes. 〔➤see Emacs: Set Color Theme

describe-char Shows Char Position

When calling describe-char, now it display the char's position in the first line.

Here's emacs 23 output:

        character: m (109, #o155, #x6d)
preferred charset: ascii (ASCII (ISO646 IRV))
       code point: 0x6D
           syntax: w    which means: word

Here's emacs 24 output:

             position: 9198 of 11337 (81%), column: 0
            character: m (displayed as m) (codepoint 109, #o155, #x6d)
    preferred charset: ascii (ASCII (ISO646 IRV))
code point in charset: 0x6D
               syntax: w        which means: word

Spell-Checking on Windows is 25 Times Faster!

Just discovered something incredible. For emacs on Windows, calling flyspell-buffer usually takes 5 seconds for a small file (➢ for example: 8k sized). In emacs 24, it is now less than a second!

Here's a exact timing, on a 80k HTML file:

the release notes (aka emacs NEWS) didn't mention anything about spell, but has the following:

** The default value of redisplay-dont-pause is now t
This makes Emacs feel more responsive to editing commands that arrive
at high rate, ➢ for example: if you lean on some key, because stopping redisplay
in the middle (when this variable is nil) forces more expensive
updates later on, and Emacs appears to be unable to keep up.

however, setting redisplay-dont-pause to t, didn't help in emacs 23.


calc keys

calc's keymapping has improved.

before, supposed you have set 【Alt+z】 for undo globally. But it won't work in calc. You have to use emacs's default. Now it does.

Bookmark File Location

The default location for bookmark changed. In emacs 23, it's at ~/.emacs.bmk. In emacs 24, it's at ~/.emacs.d/bookmarks.

You should move and rename your bookmark file to the new location.

The default location is controlled by the variable bookmark-default-file.

For the basics of bookmark, see: Using Emacs's Bookmark Feature.

Sort list-colors-display by Hue

You can call list-colors-display to list colors and their RGB hex values. But the result is not sorted. Now, you can sort it by hue. Much better. Put this in your emacs init file:

(setq list-colors-sort 'hsv )

See also: CSS3 HSL (Hue, Saturation, Lightness) Color Samples.

Docstring Link to Elisp Doc

Some function's inline doc now has a link to elisp manual. For example, call describe-variable on font-lock-defaults. Excerpt:

font-lock-defaults is a variable defined in `font-core.el'.


(See also Info node `(elisp)Font Lock Basics'.)


see also: Emacs Lisp: Inline Docstring Markup

Emacs Lisp Changes

copy-directory Change

in emacs 24, there's this major backward-incompatible change

** `copy-directory' now copies the source directory as a subdirectory
of the target directory, if the latter is an existing directory.  The
new optional arg COPY-CONTENTS, if non-nil, makes the function copy
the contents directly into a pre-existing target directory.

this means, all existing elisp scripts will break. (it broke mine)

basically, it's trying to follow the behavior of unix “cp” command. There are 2 problems:

here's a workaround:

(if (>= emacs-major-version 24)
           (if (file-exists-p toDir)
               (copy-directory fromDir (concat toDir "/../"))
             (copy-directory fromDir toDir) )
         (copy-directory fromDir toDir) )

warning, in emacs 24.3, copy-directory had incompatible change again.

Emacs 24 Common Lisp Package Name Change

Emacs 24 Common Lisp Package Name Change

Misc, to be Written

** New basic faces `error', `warning', `success' are available to highlight strings that indicate failure, caution or successful operation.

new scroll-up-line. Can't see how this effectively differs from scroll-up-command or scroll-up. They are all implemented on top of scroll-up, which is written in C code.

new commands: {scroll-up-line, scroll-up-command}. They are all implemented on top of the old scroll-up, which is written in C code.

Note that scroll-up does a page down, with key ⇟ Page ▽. But when given a argument of n, it scroll by n lines. Now, ⇟ Page ▽ is associated with scroll-up-command.

Other Sources on Emacs 24 Changes

For a official list of what's changed in emacs 24.1, call view-emacs-news. See also:

Like it? Buy Xah Emacs Tutorial. Thanks.