Emacs 23 Features

perm url with updates: http://xahlee.org/emacs/emacs23_features.html

The following version lacks images.

New Features in Emacs 23

Xah Lee, 2009-07

This page is a list of major new features in emacs 23, released in 2009-07-30. It also includes practical tips about using the new feature. This page only list the most important or practical changes. It may miss features or changes you find important.

Editing Text


Text selection is highlighted by default.

The command fill-paragraph (“Alt+q”) now automatically applies to the whole text selection if there is one.

Also, now you can hold down the Shift key then press arrows key to select text.

However, by default, pressing delete key will not delete the selected text. If you want this, put the following in your emacs init file:

(delete-selection-mode 1) ; make typing override text selection


Press down arrow key moves the cursor by a screen line. In emacs 22, pressing down arrow moves the cursor by newline as determined by line breaks.

Typing “Alt+x visual-line-mode” toggles the behavior. Or, use the menu “Options‣Line Wrapping in this Buffer‣Word Wrap (Visual Line Mode)”.

To toggle globally, type “Alt+x global-visual-line-mode”. To set it on or off permanently, use:

(global-visual-line-mode 1) ; 1 for on, 0 for off.

(info "(emacs)Visual Line Mode")


Now you can show line numbers on the margin, a common feature in other editors.

emacs line numbers

Emacs with linum-mode on.

To toggle it in current buffer, type “Alt+x linum-mode”. To toggle globally, type “Alt+x global-linum-mode”. To set it permanetnly, put:

(global-linum-mode 1) ; always show line numbers

Wildcard in Keyword Completion

Minibuffer's Command completion support wildcard char “*”, and also support substring matching in some situations.

For example, if you start to open a file, and emacs prompts you for file name in the minibuffer, you can type “*report” then “Tab”, and emacs will suggest all file names that has the word “report” in it. You can use more than one wildcard at different places.

Completion with wildcard works in minibuffer prompt whenever it makes sense. For example, when you call switch-to-buffer (C-x b), execute-extended-command (M-x), describe-function (C-h f), etc.

Note: this new completion feature applies in minibuffer only. When you are in a programing mode and pressing M-TAB for completing function names, wildcard does not apply, nor substring matching.

(info "(emacs)Completion")

In emacs 22, you can turn on partial-completion-mode or ido-mode for similar features. For some detail, see emacswiki Source.

View Whitespaces

whitespace-mode is a mode that lets you view whitespace chars such as spaces and tabs. Calling the command toggles it.

This is handy when you need to trim your whitespaces. Once you turn it on, you can call delete-trailing-whitespace, delete-blank-lines, delete-whitespace-rectangle. Or, you can use query-replace (M-%), query-replace-regexp (C-M-%), to replace white spaces. To insert a tab char, press “Ctrl+q Tab”. To type a newline char, type “Ctrl+q Ctrl+j”.

New Font Engine

The font engine has been rewritten. Now it support the operating system's fonts, and also supports anti-aliasing, on Windows, Mac, Linux.

To choose font, use menu “Options‣Set Default Font...”. Use “Options‣Save Options” to save for future sessions.

(Font rendering with Fontconfig and Xft. (Keith Packard))

emacs23 font selection dialog

The font selection dialogue in Emacs 23 on Windows. Emacs now uses operating system's fonts.

emacs22 vs emacs23 font

Font rendering in Emacs 22 and Emacs 23. The top is emacs 22 compiled normally with X11 support, running in Mac OS X's X11. The bottom is emacs 23 compiled “--with-ns”, for Mac OS X.


Characters are now represented by Unicode encoding internally. Thanks to Kenichi Handa.

You can see a effect of the change by typing “Ctrl+u Ctrl+x =” (or “Alt+x universal-argument Alt+x what-cursor-position”).

Result display of typing “Ctrl+u Ctrl+x =” on char “★” in Emacs 22.

  character: ★ (299365, #o1110545, #x49165, U+2605)
    charset: mule-unicode-2500-33ff
      (Unicode characters of the range U+2500..U+33FF.)
 code point: #x22 #x65
     syntax: w  which means: word
buffer code: #x9C #xF2 #xA2 #xE5
  file code: #xE2 #x98 #x85 (encoded by coding system mule-utf-8-unix)
    display: by this font (glyph code)
     -apple-monaco-medium-r-normal--12-120-72-72-m-120-iso10646-1 (#x2605)
Result display of typing “Ctrl+u Ctrl+x =” on char “★” in Emacs 23

        character: ★ (9733, #o23005, #x2605)
preferred charset: unicode (Unicode (ISO10646))
       code point: 0x2605
           syntax: _  which means: symbol
         category: .:Base, c:Chinese, h:Korean, j:Japanese
      buffer code: #xE2 #x98 #x85
        file code: #xE2 #x98 #x85 (encoded by coding system utf-8-unix)
          display: by this font (glyph code)
    uniscribe:-outline-BatangChe-normal-normal-normal-mono-13-*-*-*-c-*-gb2312.1980*-* (#xB18)

Character code properties: customize what to show
  name: BLACK STAR
  general-category: So (Symbol, Other)

Compare the lines “buffer code:” and “file code:” above. In emacs 23, the they are identical. Emacs 23 also includes a char's unicode name.

Emacs's new character engine does not effect daily emacs use much but is critical through out emacs. New in emacs 23 is support for languages, encodings, input systems that was not there before. See: list-input-methods, list-coding-systems, list-character-sets, list-charset-chars.

Byte compiled elisp files (byte-compile-file) that contains non-ascii chars now will not be compatible with emacs 22. This means elisp files byte compiled in emacs 23 cannot run in emacs 22. However, emacs 22 byte compiled files still runs in emacs 23. You should byte compile your emacs 22's “.elc” files if you don't plan to use emacs 22 anymore, because it saves a decoding process and loads faster.

Emacs autosave files will use utf-8 instead of emacs's emacs-mule encoding. This means, you can view those #autosave# files that has non-ascii chars without seeing gibberish.

The ucs-insert command now has the shortcut “Ctrl+x 8 Enter”, and it also support wildcard completion on unicode char names. For example, suppose you are looking for a unicode char that represent a star. Type “Alt+x ucs-insert”, then type “*star” then Tab, then emacs will list all unicode char names that has a star in it.

(info "(emacs)International")

Emacs Server/Client

Emacs can be run as a server/client. This allows you to start a emacs in remote machine, and have multiple terminal emacs instances connected to it, without the delay or resource in starting another emacs instance. You can of course still start multiple emacs instances as before.

Thanks to Károly Lőrentey, Dan Nicolescu.

To launch a emacs server, type “emacs --daemon” in shell. Or, within emacs, type “Alt+x server-start”.

To start a emacs client, type “emacsclient” in shell.

You can set your environment variable “EDITOR” to “emacsclient”. Multiple clients can connects to the same server. You can also start more than one emacs server, and have client specify which server to connect to.

(info "(emacs)Emacs Server")


nxml-mode by James Clark

This is a superb mode for working with XML documents. It validates your XML as you type.

(info "(nxml-mode)Top")

View System Processes

“proced” by Roland Winkler, for managing OS processes, similar to dired is managing files.

Start it by “Alt+x proced”

emacs23 proced

Emacs 23's proced mode, showing running processes.

You can click on the column at the top to sort by that. In the mode, type “Ctrl+h m” (describe-mode) to see its inline doc, as usual.

You use it pretty much like dired. Type “m” to mark the process, type “u” to unmark, type “x” to send a signal to the process, and type Tab to see what signal you can send.

Be sure to check the menu “Proced” while you are in proced mode.

Note that this feature does not work on Mac OS X out of the box.

Other New Modes


ruby-mode by Yukihiro Matsumoto & Nobuyoshi Nakada.


doc-view-mode by Tassilo Horn. This allows you to view PDF documents within emacs, as well as PostScript and DVI files.

This feature does not work on Windows or Mac OS X out of the box.

(info "(emacs)Document View")

Interface To GNU Privacy Guard

EasyPG Assistant (epa) is interface to GNU Privacy Guard (gpg).

The tools can be invoked in the menu “Tools‣Encryption/Decryption”. To see what command are available, type “Alt+x epa-” then “Tab”.

(info "(epa)Top")

Deleting Files to OS's Trash

Deleting files in emacs can now be set so that they move to the OS's trash.

(setq delete-by-moving-to-trash t) ; deleting files goes to OS's trash can

However, when this is on, your system trash will be filled with emacs temp files, such as those “#autosave#” files, “backup~” files, multiple emacs temp files named like “.emacs.desktop”, “emacs00164”, “server”, etc.

remember mode

“remember” by John Wiegley. Lets you write down notes quickly. Not sure what's the deal here, or what's the diff just writing to a file.

To start, type “M-x remember”. Then type your notes. When done, type “Ctrl+c Ctrl+c”, then it should save the data to “~/.notes” and close the buffer.

(info "(remember)Top")

Linux Specific Features

Support D-BUS. This feature allows emacs to provide and receive services from other apps.

Support Xesam spec for desktop search. If you have the proper tools installed, you can invoke search by the command xesam-search.


Thanks to all the Emacs developers.

“Emacs 23.1 released” (2009-07-29) by Chong Yidong, on emacs-dev mailing list. http://lists.gnu.org/archive/html/emacs-devel/2009-07/msg01526.html

Official Emacs release notes: http://www.gnu.org/software/emacs/NEWS.23.1

Interview with emacs maintainer Chong Yidong and Stefan Monnier, 2009-08-03: Source.


Difference between Emacs's “(setenv PATH ...)” and “(setq exec-path ...)”

perm url with update: http://xahlee.org/emacs/emacs_env_var_paths.html

Difference between Emacs's “(setenv PATH ...)” and “(setq exec-path ...)”

Xah Lee, 2009-08-04

This page explains the mechanisms of setting environment variables in emacs, especially if you have problems in Windows emacs of getting aspell or other unix utils to run.

Spent some time to study the diff between (setenv "PATH" ...) vs (setq exec-path ...).

Their docs are here:

In summary:

“setenv” is for setting OS env vars within emacs environment. (That is, it doesn't change the OS's env var, it just changes the env var as seen within emacs.)

Unixes and Windows both have env vars. Env vars are global info available to processes (apps). A process is free to use the info in env var. Some env var are important as they contain system info such as Windows WINDIR that contains OS path, and PATH in both Windows and unixes that specify program paths. Many are config items such as HOME dir in unix and Windows, and “locale” in unixes. When a process launchs, it inherits (have access) to all the env vars where the process is launched.

Emacs uses the system's env var just like other apps, but more importantly, emacs functions as a shell due to its various interfaces to OS's shells.

When using a shell (e.g. bash, tcsh, scsh, cmd.exe, PowerShell), typically there's a init file to allow users to sets its own extra env vars when the shell starts. So, when emacs is used as a shell, it also has this ability, and this is done with emacs commands “setenv” and “getenv” used in emacs's init file “.emacs”. (setenv and getenv are actually wrappers that manipulate emacs's process-environment var.)

Emacs's “exec-path” var is actually the var emacs uses to locate external programs. Here's a quote: “Emacs initializes exec-path when it starts up, based on the value of the environment variable PATH.”.

So, the system's PATH env var and emacs exec-path needs not to be the same, and ideally their values probably shouldn't be identical if one is a control freak, since they serve different purposes.

The value for exec-path is important to emacs in locating programs, while the PATH system env var is more important in using emacs as a shell.

So, judging from all i know, getting aspell to work in emacs means exec-path should contain the path to aspell. Since emacs set exec-path to system's PATH env var when it starts, thus setting aspell path in OS's PATH env var should work too.

As of today (2009-08-04), my emacs has this setup:

(when (string-equal system-type "windows-nt")
    ;; am using cygwin
    (setenv "PATH"
             "/usr/local/bin" ":"
             "/usr/bin" ":"
             "/bin" ":"
             "/usr/X11R6/bin" ":"
             "/cygdrive/c/Windows/Program Files (x86)/PHP/" ":"

             "/cygdrive/c/Windows/system32" ":"
             "/cygdrive/c/Windows" ":"
             "/cygdrive/c/Windows/System32/Wbem" ":"
    (setq exec-path
            "C:/Program Files (x86)/Emacs/emacs/bin/"
            "C:/Program Files (x86)/PHP/"

This is still far from ideal.

For example, the path syntax used are different. Some uses “/” while others uses “\”, and some contains the drive name while others doesn't. Some with lower case drive letter, while other doesn't. Also, some uses cygwin's path mapping.

Note that you can't simply change them to use one consistent syntax without knowing the details. For exmaple, if you simply replace those “/cygdrive/c/” paths with “C:/”, cygwin bash in emacs will chock.

I still need to do some study on the various paths to have a some sort of more universal setup, so that i should be able to invoke cygwin or Windows commands in all of emacs interactive shells: shell, cmd-shell, powershell... as of now, am not sure that's even desirable... i guess i needs to understand more about how these shells relates to each other technically outside of emacs first...

The path separator issue of / vs \ and their automatic conversion in different shells has also been a pain... In cygwin bash, cmd.exe, PowerShell, they all let you type either forward slash or backward slash for path separators while you work in the shell, and the drive letter can be omitted too. However, when you write scripts or set paths, you can't arbitrarily use / or \ (even if properly quoted in string), the rule for the omission of drive letter is also complex. Further, cygwin has some rather esoteric mechanisms to map drives (e.g. in cygwin bash, “/cygdrive/c” maps to “C:\”) ...

See this article Path (computing)

tidbits: HIV world map, USA China

Collection of tools for: How To Create Your Own Keybinding In Microsoft Windows (computing)

HIV World Map

From Wikipedia: Group of Two

Sino-American or U.S.-China relations refers to international relations between the United States of America and the People's Republic of China (PRC). Most analysts have characterized present Sino-American relations as complex and multi-faceted, with the United States and the People's Republic of China being neither allies nor enemies. Generally, the American government and military establishment do not regard the Chinese as an adversary, but as a competitor in some areas and a partner in others. At the same time, it is acknowledged that the nature of Sino-American relations will be a major factor in determining the fate of the world in the 21st century.

The U.S. has the world's largest economy. China's economy is the third largest and will soon overtake Japan's to become the second largest. The two countries are the two largest consumers of motor vehicles and oil[1]. They are the largest emitters of greenhouse gases and thus have a disproportionate impact on climate change.[2]

Damn YouTube, always taking off videos. Here's a update to the song: White Rabbit. Jefferson Airplane live. Great video!

Great dance music: This Is My Dj