Xah Emacs Blog

Buy Xah Emacs Tutorial. Master emacs benefits for life.

Tips & Tricks for emacs and emacs lisp.

Emacs: List Buffers. emacs basics. Minor update.

racket lisp language, and emacs racket-mode, is superb.

Racket: Using Emacs racket-mode

Emacs Lisp: Replace Invisible Unicode Chars

it's been a month! New version of tutorial is out.

Buy, recommend, Thanks! Buy Xah Emacs Tutorial.

Updated version will be sent out tomorrow.

search and highlight text in emacs

several updates.

Emacs: isearch Current Word. This is the most useful. It replaces isearch 50% of time.

Emacs: Search & Highlight Words (minor update)

learn racket scheme lisp in 5 minutes. Xah Racket Notes

Emacs: Dired Customization (updated. dired-hide-details-mode screenshots and how to set it as default)

reddit new subreddit, for emacs-fu

there's a new subreddit, for emacs-fu, vim-golf, like of topics. Such as, i do such and such this way, how do you do it?

if you use evil-mode, ergoemacs-mode, xah-fly-keys, god-mode, hydra, key-chord, etc, then it's for you.


learn a new thing. In dired, try dired-hide-details-mode.

thx to Rene Froger

see also Emacs: File Management (dired tutorial)

emacs kungfu fight-to-the-death!

xah-fly-keys x r keys 2015-10-03

Emacs: Commands to Move Cursor by Brackets, Quotes (updated)

xah-backward-left-bracket is my 20th most frequently used command.

here's my “keyfreq-show” output:

 1  468031   25.26%  self-insert-command
 2  127493    6.88%  next-line                                   t
 3  101031    5.45%  mwheel-scroll
 4   97262    5.25%  previous-line                               c
 5   89803    4.85%  subword-forward                             r
 6   77884    4.20%  subword-backward                            g
 7   72057    3.89%  xah-beginning-of-line-or-block              d
 8   51249    2.77%  xah-end-of-line-or-block                    s
 9   38704    2.09%  isearch-printing-char
10   33349    1.80%  xfk-command-mode-activate
11   33128    1.79%  yank                                        k
12   28310    1.53%  newline                                     RET
13   27811    1.50%  xfk-insert-mode-activate
14   27113    1.46%  delete-backward-char                        e
15   25247    1.36%  save-buffer                                 b
16   24240    1.31%  xah-cut-line-or-region                      j
17   22550    1.22%  xah-close-current-buffer                    <f14>
18   20460    1.10%  xah-backward-left-bracket                   m
19   20077    1.08%  subword-backward-kill                       .
20   15630    0.84%  xah-shrink-whitespaces                      ,
21   14205    0.77%  xah-fly-command-mode-activate               <home>
22   13218    0.71%  handle-switch-frame                         <switch-frame>
23   13191    0.71%  subword-kill                                p
24   12613    0.68%  backward-char                               h
25   12275    0.66%  open-line                                   o
26   12232    0.66%  isearch-repeat-forward
27   11897    0.64%  xah-fly-insert-mode-activate                SPC
28   11256    0.61%  undo-tree-undo                              f
29   10782    0.58%  forward-char                                n
30   10606    0.57%  isearch-exit
31   10100    0.55%  isearch-forward                             x g
32    9277    0.50%  xah-forward-right-bracket                   v
33    9234    0.50%  org-self-insert-command
34    8317    0.45%  xah-extend-selection                        1
35    7992    0.43%  xah-copy-line-or-region                     q
36    7781    0.42%  other-window                                w
37    7389    0.40%  delete-other-windows                        3
38    7068    0.38%  ido-exit-minibuffer
39    6628    0.36%  delete-char                                 u
40    6046    0.33%  set-mark-command                            y
41    5657    0.31%  xah-select-current-line                     2
42    5452    0.29%  xah-next-user-buffer                        <f12>
43    5295    0.29%  xah-html-wrap-html-tag
44    5219    0.28%  xah-select-text-in-quote                    9
45    5104    0.28%  xah-browse-url-of-buffer
46    4945    0.27%  exit-minibuffer
47    4935    0.27%  xah-select-current-block                    6
48    4718    0.25%  xah-open-file-path-under-cursor

Many emacs experts, use paredit, smartparen, ace-jump, expand-selection, and evil-mode, god-mode, hydra.

i don't use any of that. Just Xah Fly Keys

I openly challenge anyone to efficiency contest, in real time.

email me or tweet to me on social networks. We can setup a private video chat just to compare notes.

challenge, as in kungfu fight-to-the-death!

Emacs Lisp: Run Current File (updated code. Now, it'll prompt for save for non-file buffers)

Genovation Programable Keypad

found a new programable keypad, Cherry MX Black. This is not a numberpad, but a programable keypad. List of Programable Keypads

Emacs: isearch by Arrow Keys (minor update)

how to touch-type, and touch-typing tutorial, typing game

new article. Typing Tutorial, Typing Test, Typing Games

Typing Habits, Repetitive Strain Injury ⌨ (new index page. Articles related to Repetitive Strain Injury.)

The Evolution of Lisp, and Lisp Design Issues

The Evolution of Lisp By Guy L Steele Jr., Richard P Gabriel. @ http://www.dreamsongs.com/Files/Hopl2.pdf

read it. History of Scheme and Common Lisp, and lisps before that, and, many pro & con of lisp language design issues.

see also

Richard Gabriel, is one of the early lisper. He wrote a book, a short biography, and his company, which eventually gave us XEmacs. (the book detailed some history of XEmacs.)

the book is 《Patterns of Software》, which i wrote a review 17 years ago. Book Review: Patterns of Software

and, oldies;

The world, is waiting for me to change. Actually, not me, you.

found a new nice wireless number pad, with mechanical keys (Cherry Mx Black). See: List of Programable Keypads

this is good for those of you with a compact keyboard.

you can turn the numpad number keys into function keys. How to set Number Keypad as Function Keys {Windows, Linux, Mac}

or, within emacs. Emacs: Using Number Pad Keys

i know, lots programers don't like “leaving hand off homerow”. Actually, most don't know about how to use function keys. But trust me. It's good. Everything is just one key. Y'know, when you really type a lot, a lot a lot, the very idea, of the picture in your head of your hand touching keyboard while holding Control or Alt down, is PAINFUL. You shudder at that thought. You won't know this until one day it happened to you. Sure, you are young & healthy, i know. I Xah Lee, was, for most of my life, the pretty, cocky, above you, competitive altheletic-level healthy. Till, one day, you are beholden to documentation and write write write.

ok, this is getting long and i feel like rant. I'll tell you, i read enough emacs blogs, emacs key use, for over 15 years now. Actually, about typing and about keyboard since late 1987. (there is one thing in my life i'm obsessed about, and that seems to be EFFICIENCY & design) But, read far more about them every day since about 2007 when i started on ErgoEmacs Keybinding: a Ergonomics Based Keyboard Shortcut System.

I've red, all there is to say, all the blogs, the popular ones or obscure ones, about emacs keybinding. Red, all reviews of keyboards…. Now, here's my “trolling” comes in: They are all fscking idiotic.

But, actually, in the past 5 years, a lot programers, got the sense now. Look at the ergodox, the keyboardio, the truely ergo, 〔➤ Best Keyboard for Emacs〕 huge number of them really well designed keyboards coming out, with wide following, sold out, and quite a few radicals on kickstarter yet to come out.

now, in the keyboard community, you can see there are tens of thousands enthusiasts following these modern keyboards. Yet, there seems to be a separation of groups. On the one hand, you still have, huge number of folks, who, never looked at, or heard of, these new ones, and still cling to the idea of traditional PC keyboard, singing all sorts of praises about, say, Happy Hacking Keyboard or the IBM Model M keyboard.

then, i hear you say, but and but and blab…. Y'know, some things, concepts, habits, you imbibed at ya mom's feet, such as religion, programing language, or, keyboard, will never change. As Steve Jobs said, you just wait for those to die out. As i get older, and clearly, i am getting older, new life experiences comes in, telling me that i belong to the category of “old”, and i started to doubt myself, perhaps lots of my other thoughts about programing are rather too old to be good. (it is very hard to get over the “generation gap”, by the way. Because, the new generation, they start from scratch. They are simply a blank slate, don't know what's there even if they tried. While the older, need to actively take in info and mix with what we already know. (not saying one is better in general, but just illustrating the generation gap thing as a inevitable social phenomenon.))

i've actually written, few hundreds articles about keyboard, keybinding. Suppose you are a emacs die-hard, you are a serious hacker type, you live on reddit or hacker news et al and have diligently absorbed all knowledge vicinity. Then, you might have doubts about what i say. Actually, everything you possibly ever thought of about keyboard, i've written detailed analysis and experimented painfully before.

well, i haven't ranted for a while. The world, is waiting for me to change. Actually, not me, you.

when i got Truly Ergonomic Keyboard Review 3 years ago, the first thing i really missed, is my 20 or so custom function keys.

Stefan Monnier Stepping Down as GNU Emacs Maintainer

Stefan Monnier is quitting as leader of GNU emacs. See: https://lists.gnu.org/archive/html/emacs-devel/2015-09/msg00849.html

Stefan Monnier and Chong Yidong, led GNU Emacs since 2008. Chong Yidong quit in 2013. https://lists.gnu.org/archive/html/emacs-devel/2012-06/msg00259.html

It's truly sad to see them go….

For a bit memory, see this blog 〔Interview with emacs maintainer Chong Yidong and Stefan Monnier By Dirk-Jan C Binnema. @ http://emacs-fu.blogspot.com/2009/08/interview-with-chong-yidong-and-stefan.html

M-x variable-pitch-mode to toggle monospace and variable-width font.

Emacs: How to Set Font by Major Mode and Quickly Switch Fonts? (major update code)

Programing Language: Syntactic & Semantic Difference of Map

how to insert math symbols

i got this question often. How to type φ ξ? It's trivial. By abbrev or by a key setup, see Emacs: Unicode Tutorial (updated)

Emacs as Word Processor: Bold, Underline, Color Texts and save it.

when is the Emacs Overflowing Kitchen Sink Icon created? See Emacs Overflowing Kitchen Sink Icon

Emacs: Copy/Cut Current Line If No Selection

now, when the copy command is called repeatedly, it'll copy append next line.

stackoverflow question. List and review of all emacs key packages. http://emacs.stackexchange.com/questions/16641/what-packages-are-available-for-modal-editing/

the question asks for modal packages, but somehow it began to list others.

there are also others not listed there. Go and list your experience.

The following pages for emacs beginners have been updated.

If you are not a beginner, this page would probably be useful still: How to Set Emacs's User Interface to Modern Conventions

use this https://github.com/dacap/keyfreq to see which command you call the most. Install, then after a while, M-x keyfreq-show to see report.

see also Emacs's Command Frequency Statistics

Emacs Lisp: Wikipedia URL Linkify (new)

Compare to html mode you are using. Is it better? If so, comment and let me know!

Emacs Lisp: Decode/Encode URL Percent Encoding (major rewrite.)

Emacs Lisp: Change URL into HTML Link (major rewrite of code)

practical emacs lisp, discussed on Hacker News. See all the opinions there. https://news.ycombinator.com/item?id=10203538

a emacs blog by astrophysicist!

pragmatic emacs. http://pragmaticemacs.com/

It's by Dr Ben Maughan. http://www.bristol.ac.uk/physics/people/ben-j-maughan/overview.html

dogemacs 2015-09-11
dogemacs. From Paul Bauer. https://twitter.com/pmbauer/status/587481075695259648
Matias Ergo Pro keyboard 90213
Matias Ergo Pro Keyboard Matias ergo pro keyboard

this is new, and is excellent.

A new version of my emacs tutorial is sent out. Sometimes i get bounced email. If you still want updates, just email me at xah@xahlee.org with your old & new email addresses.

xah-fly-keys is now on MELPA. http://melpa.org/#/xah-fly-keys

Emacs Lisp: How to Write Keyword Completion Command (updated, added a new way with ido.)

Emacs Keys: Make Return as Control

Bozhidar Batsov gave a tip about making your Return ↩ key to act as Ctrl, when it is held down with another key.

A Crazy Productivity Boost: Remap Return to Control By Bozhidar Batsov. @ http://emacsredux.com/blog/2013/11/12/a-crazy-productivity-boost-remap-return-to-control/

Note: there are several alternatives that are better.

The problem, with control on both sides of keyboard is that, sometimes you have a control sequence where the keys are on both sides of keyboard. For example:

C-x C-j         dired-jump
C-x C-l         downcase-region
C-x C-u         upcase-region
C-x C-n         set-goal-column
C-x C-o         delete-blank-lines
C-x C-p         mark-page

If you have control as a thumb key, then it's much easier to do such key combination.

The other suggestion, is just not to use chord keys at all. For detail, see Banish Key Chords.

Here's a list of packages that help you in some way of making emacs keys easier:

But, they all only solves the problem partially and in some hackish ad-hoc way.

For real solution, i recommend 2 things.

① get a good, modern, ergonomic keyboard. See: Best Keyboard for Emacs.

One of those keyboards pretty much solves 90% of emacs pinky problems, far better than keybinding tricks.

② In addition, or if you are stuck with laptop keyboard, i recommend the following 3 packages, which systematically change how you work with emacs.

For more about keybinding science, see: Computer Keyboard Layouts & Keybinding, Design & Analysis ⌨

Emacs Bug: Pasting into Emacs Freezes Emacs, 2015 (on its own page, with temp solution)

in “ido-mode”, press 【Ctrl+f】 to stop suggestion. This is useful when creating new file.

Emacs: Switch Buffer, ido-mode

Richard Stallman: What's magit? Emacs Dev Condition 2015

Emacs Books

A new version is out. Buy Xah Emacs Tutorial.

Of all emacs books out there, online or in print, i do not believe there's anything that comes in close, in breath or in depth. Counting, all the emacs books O'Reilly published. (but excluding emacs lisp reference manual)

Not because Xah Emacs Tutorial is that great, but because, there is actually not much out there.

Of book-length emacs tutorials, there are just maybe 5 of them. Half of which are decade old, and none of them cover much emacs lisp. Except one: https://www.masteringemacs.org/.

Buy that book, and or buy my book. Thanks.

Emacs Lisp: How to Write Comment/Uncomment Command in Major Mode (new)

Emacs's Menu Usability Problem (repost)

what features would you want for a keyboard

Reddit question: https://www.reddit.com/r/emacs/comments/3igjwa/what_features_would_you_want_for_a_keyboard/

See also:

Emacs: Graphical User Interface vs Terminal (someone asked on reddit)

Emacs: Unicode Tutorial (minor update)

emacs 24.5 is out. Where to Download Emacs for {Windows, Mac, Linux}

it's out in April. Somehow i missed it.

on linux, you should build it yourself. 〔➤ How to Build Emacs on Linux

xah fly keys. Major update. Now you can load it without errors. No dependencies. I'll be polishing it more in coming days.

Emacs Lisp: Run Current File (now supports Java, and Clojure, TeX/LaTeX.)

Emacs: Copy/Cut All or Selection (new)

How to Edit Lisp Code with Emacs

Essential knowledge if you ever code emacs lisp.

emacs: should you use evil-mode?

here's my recommendation.

if you want efficient keyset, there are 3 choices. evil-mode, ergoemacs-mode, xah-fly-keys.

if you don't like modal keys, then ergoemacs-mode is the best. It also supports standard keys for open close new copy cut paste undo etc, like any other software. Install and use right away, no need to learn. Also, extremely efficient keys. Keys are based on statistics of command call, mapped to score of key position, and using Alt+key instead of Control for fundamental cursor commands or delete operations.

use evil-mode if you are also a vi user, or plan to use vi too in the future. Modal keys is more efficient than Control/Alt. This also has large user base.

if you want the utmost efficiency, use xah-fly-keys. It's modal like vi, but without any vi baggage or compatibility. Key choice based on statistics of command call. Most keys are same as ergoemacs but modal. You'll need to learn everything fresh.

When in xah-fly-keys, you NEVER need to press Control+x. Everything C-x is a sequence of 2 to 3 single keys. Meta key is never used neither. You can still use all gnu emacs keys because xah-fly-keys doesn't use any of emacs keys.

from question on g+ about whether one should use evil. https://plus.google.com/107417407213709101682/posts/JKuXLk83aN6

About keybinding, each point above i have detailed article about it. About 2 hundred articles on every aspect of keybinding and keyboard too. You can find them at the following indexes.

Emacs Lisp: Run Current File (minor update)

Emacs Autotetris Mode

elisp program that play emacs tetris-mode by itself.

See the package here: https://github.com/skeeto/autotetris-mode

See explanation here: http://nullprogram.com/blog/2014/10/19/

Chris Wellons is a expert emacs lisp programer. He wrote quite a few non-trivial emacs software.

non-trivial here means, takes several months to do, involving not just emacs lisp knowledge, but algorithms and protocols and languages outside of emacs. In contrast, a typical language major mode takes 1 day to a week.

Some of the notable include:

Wellons is also a professional Java developer. So, if you work with Java, i'd recommend looking into his emacs config.

Wellons has mentioned in sacha's emacs talk 〔http://sachachua.com/blog/2014/05/emacs-chat-christopher-wellons/〕 that he has read the emacs lisp manual cover-to-cover several times. (info "(elisp) index") (yours truly, haven't done so even once.)

Wellons's got quite a lot interesting things in his blog. Of all emacs blogs out there, if you want me to name just 1, i can only think of Chris Wellons.

in emacs, call display-time-world.

Emacs Lisp: Run Elisp Script in Shell (repost)

i do this every day for the past 6 years, text processing 5k html files.

#Emacs «how» ‘to’ 「type」 ‹curly› “quotes”, 〔and〕 【ALWAYS】 (insert) [Brackets] {by} 《Pair》 Emacs Lisp: Insert Brackets by Pair

Emacs Lisp: Cycle Replace Space Hyphen Underscore (updated code)

Clojure Instaparse Parser Tutorial

Emacs: subword-mode, superword-mode, camelCase, snake_case (minor update. repost)

Emacs Lisp: Make Backup of Current File (updated code. Now, if in dired, it'll backup current file or all marked files.)

thanks to reddit discussion, more keyboard added to

List of Keyboards with Topre Switch

reddit link at bottom.

Find File Location of a Feature Name

in emacs, if you know a feature name, you can locate the file by calling find-library

For example, call describe-variable then type “features”. Then pick any of the item. Then, call find-library, type that item. Emacs will jump to the file where the feature is defined.

〔➤ What's Emacs Lisp feature?

I usually do describe-function, then jump to the file location. But, find-library is more direct, and useful. Because sometimes you only know the feature name, not the command to invoke it.

got the tip from https://twitter.com/_wilfredh

List of Keyboards with Topre Switches (on its own page) This is the famous switch used in Happy Hacking Keyboard.

xah fly keys

is now a minor mode.

if you have question using it, just ask me. Best way is just to post a comment on the page or on the github page. You can also ask me on twitter or g+. Email's ok too but sometimes got eaten by spam filter.

currently it's suitable for those who love to tweak emacs keys.

i've seen pretty much all emacs keybinding systems out there. Especially in the past few years with lots packages. Including, evil, hydra, god-mode, etc. They are, scientifically, less efficient. But, better than GNU emacs default.

if you want something quality that works out of the box with lots users, then i recommend:

the ergoemacs-mode is Alt+key based. Evil is vi based.

Emacs Conference 2015, San Francisco

There's a emacs conference, (a Saturday) in San Francisco, CA, USA.


register or plan at the above site.

i learned about it from the following emacs hangout.

2015-08-13 Emacs Hangout European Edition

sachachua leads the emacs hangout. Check out schedule and news at her site at http://sachachua.com/blog/tag/emacs-hangout/

emacs lisp programer for hire

if you have a emacs project, such as writing a mode for your company, i'm available. I charge $50/hour.

For basic mode, 1 hour would do.

Please contact me at 〔xahlee@gmail.com〕. (twitter ping me if i didn't respond. Sometimes new email are filtered by spam)

Emacs highlight current line

How to Set Emacs's User Interface to Modern Conventions (added a screenshot for global-hl-line-mode)

Emacs Lisp: Delete Current File (update from yesterday's code. Now it won't ask to save if buffer is modified)

Mac OS X: How to Create Keyboard Layout and Keybinding ⌨ (repost)

Mac OS X supports basics emacs keys. But you can add more.

Emacs and Microsoft Windows Tips


Emacs Lisp: Delete Current File.

A new version of the command. The new one doesn't make backup, but simply copy file content to emacs's clipboard first.

fun emacs lisp: emulate real typing

(defun insert-typewriter (str)
  "Insert STR into the current buffer as if you were typing it by hand.

Modified from
URL `https://gist.github.com/howardabrams/b5dc2082bcce46fdc9b8'
  (interactive "s")
   (lambda (char)
     (insert char)
     (sit-for (/ 1.0 (1+ (random 100)))))

;; test
(insert-typewriter "something, paste for example source code here.
Be sure to escape double quotes.")

via https://twitter.com/howardabrams

scifi author Tony Ballantyne on emacs

scifi author Tony Ballantyne (Recursion (novel) etc.), wrote a article on using emacs. See:

My Emacs Writing Setup By Tony Ballantyne. @ http://www.tonyballantyne.com/EmacsWritingTips.html

eshell now has doc

in emacs 24.4.1, there's finally documentation for eshell. Call info, then just go to the eshell point.

you can also read it online at GNU site at http://www.gnu.org/software/emacs/manual/html_mono/eshell.html

Emacs Lisp: Copy File Path of Current Buffer (improved code)

try this. blind fold yourself. Use your favorite language, favorite editor, write “hello world”, and run it.

did you succeed?

if so, it means, you can blind type, super fluent with your editor and without using mouse, familiar with your language.

comment at https://plus.google.com/113859563190964307534/posts/3SfNXQ6oc7D

Banish Key Chords. (repost. Whence Key Chord Came From? Is emacs keys or vi keys more efficient?)

Emacs: magit-mode Tutorial (minor update)

printed org-mode manual

there's a printed org-mode manual, published by GNU.

emacs org mode manual cover

Emacs: Manage Split Windows (repost)

emacs major version of magit is out. To upgrade, call list-packages, press U x.

Like it? Buy Xah Emacs Tutorial.