Xah Emacs Blog

Emacs: Writing Outline, org-mode Tutorial (updated.)

Overview of Text-Processing in Emacs Lisp (major rewrite)

Emacs Lisp: Get universal-argument (major update. New sample code for complex case, simpler.)

Emacs: Show kill-ring (new command)

emacs lisp delete wikipedia links 2017 06 19
emacs lisp on the whim! delete all Wikipedia links.

Emacs: Interactive Abbrev (command complete rewrite)

Emacs: Display Formfeed ^L as Line (now, a command to do so)

Emacs Lisp: Text Properties (new)

how to chose keys to bind in emacs

my take https://www.reddit.com/r/emacs/comments/6gxjnw/tips_for_custom_bindings_and_also_considering/diuac26/

here's the post:

lots headaches will be avoided if you chose a key space that no emacs or packages will ever touch.

hyper and super are such. (e.g., make the Windows key send Hyper, or Command or Option key.)

〔 ►see Emacs: How to Bind Super Hyper Keys

Emacs: How to Bind Super Hyper Keys

but even better, is use key sequences. It's easier to press, faster (if the leader is thumb or capslock), and less hand injury risk.

Make F8 as leader to begin. (not on laptops as F keys are not easy to press there) So, all your commands are F8 a, F8 b, F8 c, etc, or F8 d a, F8 d b, etc.

If you are using a traditional Microsoft keyboard, can make the menu key as leader.

Best is to make capslock as leader, or an alt close to thumb.

You can find my tutorials of how to on these.

More radical is to replace ALL emacs key combos by leader key sequence. For that, try xah-fly-keys.

〔►see Emacs: Xah Fly Keys

emacs replacing all search-forward-regexp by re-search-forward, using xah-find.el

xah find replace text 2017 06 10
emacs replacing all search-forward-regexp by re-search-forward, using xah-find.el 〔 ►see Emacs: xah-find.el, Find Replace in Pure Elisp

Emacs Lisp: Multi-Pair String Replacement with Report (updated code. Now support repeat-complex-command properly)

Emacs Lisp: Overlay Highlighting (updated)

Emacs: How to Define Menu Key (minor update)

very much appreciate all who bought my tutorials, and supporters. Thank you!

Emacs: Batch Rename Files

minor update. Also, all other pages related to shell are reviewed/updated. See the “shell topic” navigation links at bottom of the page.

Why Run Shell in Emacs? (minor update)

Emacs Lisp: Functions to Process Lines (updated)

Emacs: What's the Best Setup for Python, Ruby, Java, JavaScript, etc? (rewrite)

doc string popup update

Now, when you browse my tutorial, all commands have popup doc string.

For example, go to Emacs Keys Overview or Emacs Lisp Basics, move hover on any command name.

(note, technically not ALL, but all that are documented in emacs and elisp manuals.)

Emacs: Avoid Lambda in Hook (minor update)

Emacs: Change Major Mode Keys

Emacs: Change Minor Mode Keys

minor updates

Emacs: Uncolor Region/Buffer (minor update)

emacs lisp find/replace text processing saved the day

2017 05 30 174228 660x761 scrot
emacs find/replace code.

this saved the day. 250 files, among some 7 thousand html files.

Emacs: Select Line, between Quotes, Extend Selection (code update for xah-select-block )

Why Clojure is Dense

Emacs: Select Line, between Quotes, Extend Selection (code update for xah-select-block. fixed bug where it select block before cursor)

Emacs AutoHotkey Mode (ahk-mode) (minor update)

Emacs: Insert Random Number/Hex/String (code update. Now, by default, insert 4 digits.)

History of Emacs and vi Keys, on hackernews

my article hit hackernews. yay. https://news.ycombinator.com/item?id=14367207

the article is History of Emacs and vi Keys

thanks to whoever submitted.

Emacs: Change Brackets and Quotes (now supports ascii quote)

Emacs: xah-lookup.el, Lookup the Web (package updated)

emacs tutorial update 2017 May

Buy Xah Emacs Tutorial

new version of emacs tutorial is out. If you haven't got it yet, buy it. Thanks. (sending update to previous buyers this week)

last update is Feb 17. So it's been full 3 months.

in the past 3 months, quite a lot updates, you can see here in the blog. They are pretty much minor updates and code updates on tens of pages, and few pages are complete rewrite. (only content update counts here. I typically make typo and format updates (such as adding/changing navigation bar etc) every week on lots pages.)

also, i work on my emacs packages all the time. 〔►see Xah Emacs Packages〕 The updates there are not counted for the tutorial here.

or, if you liked my work, please donate. goto paypal.com, and pay to “xah@xahlee.org”. Or, buy something from my keyboard pages at Keyboard Articles Index.

Thank you.

Emacs Lisp: Association List (new article)

Emacs Lisp: Sequence: List, Array (new figure added)

Xah teaching emacs/lisp, one-on-one video hangout

i'm teaching emacs or elisp, one-on-one, via video hangout.

It can be free-form, where you can ask me questions randomly.

or, we can do it in a free-form course format. Where, i teach you emacs for beginner from the ground up, or, i teach you elisp from the ground up. Starting at a level you are comfortable with.

I charge $25 per hour, via paypal.

please email me xahlee@gmail.com or private message via twitter to schedule a time. my twitter: https://twitter.com/ErgoEmacs

Emacs: xah-lookup.el, Lookup the Web (package updated. More ergonomic default keys.)

someone on reddit asking about whether he should use ergoemacs.

If you use it, please voice your views. Thanks.


Emacs Lisp: Font Lock Mode Basics (on its own page, expanded.)

pen spinning

yours truly fidgeting with pens like double lightsaber

xah lee pen spinning

good for preventing Repetitive Strain Injury!

and onto the roads of How to Avoid the Emacs Pinky Problem

and Why Emacs's Keyboard Shortcuts are Painful

Emacs: Move Cursor to Beginning of Line/Paragraph (sorry, more fixes.)

Emacs: Xah Fly Keys, swapped keys for copy/cut

Emacs: Xah Fly Keys (code update)

Swapped keys for xah-copy-line-or-region , xah-cut-line-or-region. Because, it seems lots users question it, and now looking at stats, my reasoning that cut is more frequently used does not have solid evidence.

Emacs: Convert Straight/Curly Quotes (code update. fixed highlight bug.)

Emacs: Move Cursor to Beginning of Line/Paragraph (revert to previous version. The version that moves to indentation end then beginning of line is too slow (too many steps) to jump over paragraphs.)

Emacs: How to Define Menu Key (minor update)

Emacs Always use kbd to define keys. Other syntax got problems and should be ban'd.

see https://www.reddit.com/r/emacs/comments/6adli0/preferred_syntax_for_defining_keys/dheggib/

Emacs: Move Cursor to Beginning of Line/Paragraph (code upgrade. now support visual-line-mode. Thanks to stasvlasov.)

Emacs Keybinding Syntax Examples (updated)

Emacs: Change Brackets and Quotes

more code update. Now support • `emacs' • `markdown` • ~org~ and others.

emacs 25.2 released

Download Emacs for Windows, Mac, Linux (updated)

See also: How to Build Emacs on Linux

Emacs in Microsoft Windows FAQ (updated.)

Emacs: Change Brackets and Quotes (new code. Now work with markdown style quotes and double square brackets)

Emacs Lisp Sucks Donkey Ass. Please Grow Emacs, Not External Tools

xah-js-mode now properly deal with /regex/ as string for syntax coloring. Emacs: Xah JavaScript Mode

Emacs: Move Cursor to Beginning of Line/Paragraph (code upgrade. now moves to indentation.)

art of git commit messages 2017 04 30
art of git commit messages

Emacs: Change Brackets and Quotes (fixed a bug of xah-change-bracket-pairs when region is active)

Emacs: Proportional Font (on its own page.)

moved from Emacs: Cycle Fonts by Command

Function Key vs Key Chord, Which is Healthier, Which is Faster?

If we rank people who sit in front of comp longest, measured by statistics with a device on the seat, i'd say i rank within top 500.

My Typing/RSI Experience 1992 to 2017 (updated)

Emacs: Open File Fast (code updated. Now ignore bookmarked cursor position.)

emacs. Don't use text-mode, use fundamental-mode

text-mode is annoying because the “U+22: QUOTATION MARK” does not have syntax of string.

that means, when in xah-fly-keys, the qwerty d key does not delete the whole string.

you can solve by:

(add-to-list 'auto-mode-alist '("\\.txt\\'" . fundamental-mode))

Emacs: Delete Backward Char or Bracket Text (code change. fixed https://github.com/xahlee/xah-fly-keys/issues/19#issuecomment-297099907 )

Using Emacs Lisp as Scripting Language

A question on reddit asking about using elisp as scripting language.


my answer:

i wrote a lot elisp scripts, for over 10 years. Converted my perl python scripts to elisp. We had build script in elisp for ErgoEmacs distro back then. But i'd recommend use ruby python perl for those, or Scheme/Racket, golang. I don't write batch scripts in elisp anymore.

Here's elisp problems for scripting.

elisp shines when you need interactivity, and especially if you want to run it inside emacs and output in emacs. Such as grep or find/replace on directory of files. It's still much slower, but much easier to write, more convenient to use, can jump to file by link, colored output, etc, in a buffer.

but if you are comparing to bash+awk, i'd stick with elisp. Bash+awk are less powerful.

rms is on gnusocial, accessible via mastodon


here's emacs packages for them

Emacs: Toggle Letter Case (better code. Now will do whole string connected by low line _ and hyphen -.)

ergoemacs melpa stat 2017 04 19
ergoemacs-mode, 6.6k downloads. https://melpa.org/#/ergoemacs-mode

Emacs Lisp: Convert Color Formats: RGB, HSL, HSV (updated)

Emacs: Open File Fast (now the command will open file from emacs bookmarks, instead own list.)

Emacs: Bookmark (complete update)

My Journey with Touch Typing and Vim By Chris Wellons. At http://nullprogram.com/blog/2017/04/01/

Customize Hippie Expand to Words Only

about 1 or 2 years ago, Hippie Expand started to have annoying behavior of expanding a word into a line or a blob of long text.

Here's how to fix. Put this in your init.

(setq hippie-expand-try-functions-list
        ;; try-expand-dabbrev-from-kill
        ;; try-expand-all-abbrevs
        ;; try-expand-list
        ;; try-expand-line

Note: order matters. This is what am using now.

Printed Citations to Xah Lee Site

nice to find 2016 book still cite Xah Lee.

Emacs: Interactive Abbrev (moved url)

get a practical understanding. Public-Key Cryptography Concepts for Programers

The X-Windows Disaster This rant that every unix user knows in 1990s. Not so much in 2000s. Forgotten today.

learn how to use GNU GPG in 10 minutes. GPG Tutorial

Emacs: Abbrev Mode

The above is rewritten, reverting to my old method of using abbrev by using a elisp abbrev file. It is the most simple and efficient way of using emacs abbrev.

Here's the traditional way of using emacs command, see:

Emacs: Abbrev Mode Tutorial

It's much more complex. After using the traditional way for half a year, i reverted to the elisp file way.

Emacs: git, magit-mode (updated)

Customize Emacs

following are reviewed and updated (all minor).

  1. How to Set Emacs's User Interface
  2. Emacs: How to Install Packages Using ELPA, MELPA
  3. How to Install Emacs Package Manually
  4. Emacs: How to Define Keys
  5. Emacs: M-x customize Tutorial
  6. Emacs: Set File to Open in a Major Mode
  7. Organize Emacs Init File in 5 Minutes
  8. Emacs: Byte Compile Elisp Files
  9. Emacs: What's Hook?
  10. Emacs: Set Environment Variables within Emacs
emacs rsi pinky 2017 03 23

i get a lot flames for this over the years.

see Emacs: Why You Should Not Swap CapsLock and Control

Emacs Chinese Input (minor update)

Emacs: Copy/Cut Current Line If No Selection

code update. now xah-copy-line-or-region won't move cursor to next line if region is active.

Thanks to baron42bba, from https://github.com/baron42bba/.emacs.d/commit/d96ce7e671628bb0f7b5307734a7e6f25295e602

JavaScript is the Number 1 Programing Language

Emacs: Xah JavaScript Mode

worked much on this in past year. Still 2 things need to be done. Indentation, and coloring of js regex string. But otherwise, it's got best completion, best function template, and best syntax coloring.

by the way, js is the most popular language for a number of years now. See http://redmonk.com/sogrady/2017/03/17/language-rankings-1-17/ and reddit discussion

also, learn from my tutorial.

〔►see JavaScript in Depth

Been working on that in past 6 months, adding ES2015 features, and transforming it into a complete reference. That is, detailed page of ALL JavaScript objects and methods.

〔►see JavaScript Objects Reference Panel Index

〔►see JavaScript: ECMAScript 2015 Features

i'm surviving on $500 a month for past few years.

Buy Xah Emacs Tutorial


Buy Xah JavaScript Tutorial

much appreciated. Thanks.

Xah Emacs Extra Panel Index. New panel index.

Emacs: Delete Backward Char or Bracket Text (code update. Now if C-u is pressed first, don't delete inner text. See docstring for detail.)

Kinesis Edge keyboard

If you like traditional shaped keyboard, a top-notch one is coming out. Kinesis Edge keyboard. I consider it better than all traditional shaped existing keyboards. If you buy now, you save about $80.

see https://www.kickstarter.com/projects/294674098/freestyle-edge-the-ultimate-split-gaming-keyboard

Also, subscribe my keyboard blog at Xah keyboard Bloghttp://xahlee.info/kbd/keyboard_blog.xml

If you are on linux, check out Xah's Linux Setup. lots tips and tutorials.

also, you might follow my programing blog. Xah Programing Bloghttp://xahlee.info/comp/blog.xml

Emacs: xah-get-thing.el (major rewrite)

Emacs: Lines to HTML Table (complete rewrite)

Emacs: Change Brackets () {} [] in Region code update, and emacs repeat-complex-command problem

Emacs: Change Brackets and Quotes (code update.)

fixed the pesky problem of emacs repeat-complex-command problem of not getting the correct region begin/end.

here's quick explanation.

In emacs, after you've done an interactive command call involving prompting, you can call the command again by Alt+x repeat-complex-command, without needing to answer the prompts.

〔►see Emacs: Repeat Last Prompted Command

The problem is, if your write your elisp code using interactive with region begin/end as arguments, like this

(defun my-do-line-or-region (begin end)
  "do x, on current line or active region."
   (if (use-region-p)
       (list (region-beginning) (region-end))
     (list (line-beginning-position) (line-end-position))))
  (message "%s %s" begin end))

then, when your call repeat-complex-command, the region positions are hard-coded from last call.

there are solutions but i haven't found them to be robust. don't have time to write a detailed account now.

basically, more reliable is simply remove the begin/end as parameters. The problem with this is that now the command is less convenient to use in elisp code. Before, you can call the function with begin/end positions. This is clear code. Now, you have to mark a region first and make it active. This is less clear code.

Emacs: Novel Reading Mode (updated)

Emacs new version xah-lookup.el, added xah-lookup-etymology Emacs: xah-lookup.el, Lookup the Web

Best Tool for Yak Shaving: Emacs

Xah Emacs Tutorial, new version out

Buy Xah Emacs Tutorial

huge amount of update in the past 3 months. Lots new super efficient commands, tutorial on syntax table, new JavaScript engine of doc popup in browser, and xah-fly-keys now supports qwerty, a major milestone.

Recommend to a friend. Link to articles. Buy it. Thanks.

sending out update to previous buyers this week.

Emacs: Make Whitespaces Visible (major rewrite)

Emacs Lisp: Syntax Table Tutorial (new)

Emacs: Delete Backward Char or Bracket Text (updated code. Now works on «»‹›“” too.)

Emacs Lisp: How to Find Syntax of a Character?

Emacs Lisp: How to Modify Syntax Table Temporarily (rewritten)

xah-fly-keys, announced on reddit. https://www.reddit.com/r/emacs/comments/5t884r/xah_fly_keys_now_supports_qwerty_layout/

If you support the project, please give it a upvote, and tell friends. Thanks.

also, star it on github. https://github.com/xahlee/xah-fly-keys Thanks.

home page at Emacs: Xah Fly Keys

Emacs: Run Current File (updated. Now supports TypeScript)

Emacs: xah-lookup.el, Lookup the Web

Major new version. Now you can customize each lookup command's URL and which browser to use. Can also write your own command to lookup php, clojure, etc. New version should be in MELPA the next day.

xah-fly-keys with Truly Ergonomic Keyboard. Major update. New layout design.

for Kinesis users, see Kinesis/Ergodox layout for xah-fly-keys

How to Make the CapsLock Key do Home Key (updated, for Linux, Mac, Microsoft Windows)

Emacs: Working with CSS Color Values (updated code. calls font-lock-flush instead of font-lock-fontify-buffer)

big thanks to Avi for donation $$$ for Emacs: Xah Fly Keys

open this file in emacs. https://tc39.github.io/ecma262/2016/#. 13th line is 1.2M chars. emacs death.

solution: M-x fundamental-mode.

Emacs: Xah Fly Keys (now it overrides other minor modes, as it should.)

Emacs: xah-find.el, Find Replace in Pure Elisp (now you can customize face. Alt+x customize-group, then type xah-find.)

reddit discussion, on emacs naming convention


it's the convention of the mothership.

many of these conventions, are kinda vague, some are out-dated, some are ill-designed.

many packages outside GNU emacs do not adhere to them, but are tolerated. For example, the most popular packages on MELPA, dash, s, break these conventions.

it's a gray area, between conservative and progressive.

if you chose progressive, the problem is that huge amounts of existing lisp code are not gonna change (lots work, risking bug to fix but little benefit, or packages not maintained but still used, etc.), you end up with inconsistency.

if you chose conservative, then you reduce progress and adoptation.

For example, let's say the naming convention. Besides the prefix:

• predicate could end in ? (as in Scheme/Racket Lisp, ruby, clojure) instead of p. Since question mark is more intuitive, is easier to identify, and can be syntactically verified by machine. (p can't because not all functions ending in p is a predicate.)

• the double dash for internal methods (aka auxiliary functions) is kinda unsaid convention, and code out there may or may not conform. (if we go strict about this, i think one'll find huge amount of functions need to be renamed.)

• variable beginning with low line _ as form-filler unused var is another unsaid convention. It kinda came from modern (say after 2010) practices in other langs (i think python ruby).

• in function doc string, it's GNU emacs convention to use ALLCAPS for parameters. This is also not a perfect convention, since elisp is case sensitive. This make it hard to actually have parameters that's ALLCAP or camelCase or single capital letter such as Z. Also, using ALLCAPS is a weak, ambiguous markup, since it prevents the normal English convention of using ALLCAPS for emphasis.

but as most coding convention goes, they are not systematically designed. They came by-and-by via practice and evolution. It'd be nice if the language enforce syntactic conventions. For example, var of ALLCAPS has semantics of global var. (sigils in perl, ruby, golang, and other lang feature these) An extreme case would be syntax algebra, where the syntax alone is the semantics and can be processed/manipulated (like highschool algebra). Formal Languages are such case.

Emacs: Xah Fly Keys now supports QWERTY layout! Try it.

Emacs lots work on Xah Fly Keys in past month. Added 5 efficient commands. Emacs: Xah Fly Keys

Emacs: 1 Key to Copy/Paste from Register

new command xah-append-to-register-1 and xah-clear-register-1

emacs poll: do you ever use point-to-register and jump-to-register?

vote at https://twitter.com/ErgoEmacs/status/821882792183099393

Emacs: Move Cursor to Beginning of Line/Paragraph code complete rewrite. Now does not depend on another function.

Emacs: Upcase Sentences (new command)

Emacs: Delete Backward Char or Bracket Text (now supports ascii quotes.)

emacs logo poll 2016 12 27
Poll result: do you like emacs logo in the splash screen? https://twitter.com/ErgoEmacs/status/813938274766966784

all syntax coloring on the site are redone, based on the latest version of Emacs: Xah Emacs Lisp Mode (that is, if you use xah-elisp-mode, the coloring in emacs buffer would be the same as on the website.)

notable is that the coloring are based on the “types” of symbol, as detailed here: Meaning of Lisp List, Function Type, and Syntax Coloring

still to do, is the tooltips for variables.

Emacs: Paste or Paste Previous (bug fix)

Meaning of Lisp List, Function Type, and Syntax Coloring


new poll, 'NOERROR vs "NOERROR". vote at

Emacs Lisp: Symbol vs String for non-nil Values

Emacs Lisp: Find Matching Bracket Character (new article)

Emacs: Quote Lines (code update. Now delimiters are added by skipping whitespaces)

emacs symbols obarray list 2017 01 06
there are 15305 symbols in obarray, when emacs is run as --batch. Normally, it's 45k to 80k symbols or more, depending number of packages loaded.

Programing Language: Syntactic and Semantic Difference of Map Function

How Many Keyboard Shortcuts Are There

new tooltips

the tooltips are regenerated, from emacs 25.1

now ALL functions mentioned in elisp manual have tooltips. try (info "(elisp) Point") and Emacs Lisp: What's Function. (goto the page, hover mouse over a function name, or touch it in phone/tablet.)

though, it turns out, quite a lot commonly used functions are not in elisp manual. For example, eval-last-sexp, ielm, describe-function.

Am working on that. Also, variable will also have tooltip soon.

Emacs Lisp: What's Function (major rewrite.)

i think sometime between 2013 to 2016, defun is moved from implemented in C to implemented in elisp.

;; test if defun is implemented in C
(subrp (symbol-function 'defun))

#emacs ido-completing-read can handle 81k items no problem

Emacs: Delete Backward Char or Bracket Text (new command.)

Emacs: Paste or Paste Previous (new command)

Emacs: Xah Emacs Lisp Mode (Major update. Now, ALL elisp symbols in elisp manual are colored, and are colored by their technical type: function, special form, macro, command, user option, variable. )

Emacs: Change to Title Case (minor code update. fixed “can'T” to “can't”)

List of Emacs Starter Kits

new one is scimax, for scientist/engineer for reproducible research and publishing. Focus on LaTeX and org-mode.

Emacs: View Info Page (minor update; new screenshot)

Like it? Buy Xah Emacs Tutorial. Thanks.

Xah Emacs Blog Archive Index