Xah Emacs Blog Archive 2009-12 to 2010-05

Emacs: isearch Current Word (essay and practical tips)

A new version of ErgoEmacs Keybinding is out. Version 5.3.3, released on 2010-05-27. Major new features are:

Full detail is in the version history file in the package.

Download at: ErgoEmacs Keybinding.

Emacs Spell Checker Problems. (criticism; short essay)

Discovered a great tip to copy current line, or cut. See: Emacs: How to Copy/Cut Current Line

camelCase and Code Formatting (opinion; essay)

Sometimes you want to delete the file of the current buffer. How do you do it? Here's a simple command Emacs: Delete Current File.

Emacs: Hard Wrap Lines, fill-paragraph, unfill-paragraph.

A short elisp tutorial: Emacs Lisp list-matching-lines.

tutorial: Emacs: Newline Representations ^M ^J ^L.

Which Emacs to Download? (This page is a guide on what emacs distributions are there, which one you should use, for Windows or Mac.)

Emacs: List/Delete/Highlight Matching Lines, Sort/Reverse Lines

Emacs: Shortcut to Delete Whole Line.

Basic tutorial: Emacs Lisp Functions Optional Parameters.

Another little emacs tip. The tip is about how to edit files that requires admin privilege.

Often, you want to edit a file that requires admin privilege. So, either you start another emacs instance as root, or, modify the file's permission first with sudo then edit then modify it back. Both solutions are painful.

Starting another emacs instance is slower, and you also need to navigate to the dir path. Edit permission bits is error prone and dangerous. You have to carefully remember what was the original perm bits.

When i was a full time unix sys admin, i usually always keep a instance of emacs as root, with different colored background. But this is also not a optimal solution. Often i need to login to several remote machines. Starting another instance as root is too much manual overhead, and may ends up too many terminal windows.

Here's one short tip from the web:

; from newsgroup gnu.emacs.help, by Richard Riley, 2009-08-02
(defun open-current-file-as-admin ()
  "Open the current buffer as unix root.
This command works on unixes only."
  (when buffer-file-name
     (concat "/sudo:root@localhost:"

PS the above works in unixes only (including Linuxes and Mac OS X). How does one do on Windows? If you know, please post! Concrete solution that you actually use is preferred.

Little tips about calculating dates.

I needed to find the date of 2010-04-17 minus 200 days. How do you do it in emacs?

Start calendar mode by tying 【Alt+x cale Enter ↵】. In calendar mode, the left arrow moves you back. But it also takes a universal argument of n to go back n days. So, type 【Ctrl+u 200 】 will put you 200 days back.

When your cursor is in the calender pane, there are these new menus: Scroll, Goto, Holidays, Diary, Sun/Moon. Check them out! I've been using emacs for 12 years, but never realized this!

PS thanks to people on comp.emacs, in particular Jason Rumney.

Emacs Templates with YASnippet.

Best Unicode Fonts for Programer. (tutorial; tips)

Emacs: M-x customize Tutorial

Some of my emacs lisp tutorial have been translated to Chinese and Japanese.

Thanks people.

Organize Your “.emacs” in 5 Minutes.

Emacs: Insert Random Number/Hex/String

Elisp: Region, Active Region (tutorial)

Count Words, Count Chars, Count Region (Emacs Lisp tutorial)

Emacs: Writing Outline, org-mode Tutorial

Ever want to quickly show the current file's location in dired? [see Emacs: How to Stop Yasnippet auto-indent]

Why Emacs Is So Useful. (essay)

Microsoft Windows: Swap Caps Lock, Alt, Control Keys.

A new version of AutoHotkey Mode For Emacs is out. This version fixes a defect where if the source code contains “"C:\"”, then everything after is badly syntax colored.

A new report: Emacs's Command Frequency. This report is a major update from the one in 2007, with data size that's 20 times larger. It took some 16+ hours to do this report, most time is spent on thinking and re-writing the Python script that generates the report. (i thought it was just gonna be some 2 hours)

A new release of ErgoEmacs is out, at version 1.7. (Thanks to David Capello)

If your are running Microsoft Vista, and you use emacs to edit files in the C:\Program Files\ or c:\Program Files (x86)\ dir, and without admin privilege, Windows will automatically create them in $HOME\AppData\Local\VirtualStore\. This may be very confusing, because dired will show a certain file you have in the program dir, but it doesn't exist when you use shell to look for it. For detail, see: Windows Vista VirtualStore Problem.

“Zen-Coding”, A Abbrev Expansion Template System For HTML.

Elisp: Doc String Markup (tutorial)

Emacs: Bookmark Tutorial (tutorial)

A new package: AutoHotkey Mode (xahk-mode.el) For Emacs. Took me about 8 hours to write, everything, including the web page, doc, this announcement etc, all. (i was expecting to be some 20 hours.)

Ever want to uncolor the current region? [see Emacs: How to Stop Yasnippet auto-indent]

Emacs AutoHotkey Mode Problems.

Added a code snippet on Elisp Examples: symbol properties, set frame, font, fold, shell call. The code shows you how to write a function that cycle thru states when called repeatedly, and also explains the concepts of lisp's “symbol property”, setting font in a frame.

On Dec 26 2009, 8:50 pm, Ccming wrote:

I very like the default style of PHP lanuage on Notepad++, hope I can use them on GNU Emacs.


i don't recommend it because emacs's font style for programing lang keyword types are used across all langs. For example, function is blue, strings is a bit orange, coments are red, etc., for all langs. Also, emacs's font face coloring are designed so it's also usable when in 8-color terminal.

anyway, to do what you want, do Alt+x customize-group, then give “font-lock-faces”. There, you can use the mouse to select and change.

you can see a sample of how emacs coloring are for different languages here: Syntax Coloring with Google-Code-Prettify.

When you use a hook, it is best to define it as a function, then add that to hook, instead of using a lambda. Let me explain… (archived at: Emacs Tips Collection.)

Starting a Dedicated Emacs Blog

Am starting this emacs blog. Often, i have random tips or notes i want to write down. Too small to be part of tutorial, but still useful even to myself later. This blog also serve as news update for my emacs tutorial. I have a main blog Periodic Dosage of Xah Lee but that is not focused on emacs topic. Many people are interested in my emacs news but not others. So, this emacs blog will help.

What follows are emacs related stuff from my main blog in the past 4 months. I put them here to start with, and also gives some sense of the topics in this blog.