Celtic Knots, Truchet tiles, Combinatorial Patterns

Perm url with updates: http://xahlee.org/math/Truchet_tiles.html

Celtic Knots, Truchet tiles, Combinatorial Patterns

Xah Lee, 2010-06-25

knot puzzle-s

A image made by Henry Segerman.

This is made by using a “Celtic Knot font” (from clanbadge.com).

Basically, this method is just a combination of square tiles. Each tile has a pattern. When 2 tiles are placed together, the pattern on them connect at the edges. When a bunch of these tiles are placed together, each tile may have different pattern or orientation, they form various knots or paths. If each tile's pattern and orientation is choosen carefully, a symmetric over all design can be created.

This way of creating patterns is known as Truchet tiles.

It can be done with equilateral triangles too, or, any tiling of n polygonal prototiles. Just make sure that the patterns on each tile is such that their edge can connect smoothly.

For several tiles by the truchet tile method, see:

sq arc503Tile-p sq squarly weave-p t hexagon link-p sq lotus vine weaving-p
Truchet tiles

Truchet tiles. Floor by Colin Fizgig, tube by Sleeves Rhode. These are created in Second Life.

The idea can easily be extended to 3D.

Truchet tiles 3d

3D version by Sleeves.

hyperbolic paraboloid

A Hyperbolic Paraboloid, on a background several tilings by the Truchet method. For info about the metal surface, see: Math in Second Life (page 2)

How to Use Unison for Syncing Files (Unison tutorial)

Perm url with updates: http://xahlee.org/UnixResource_dir/unison_file_sync.html

How to Use Unison for Syncing Files (Unison tutorial)

Xah Lee, 2007-03, 2010-06-25

This page gives you some practical tips on using Unison for syncing files on a local machine and a remote server. (or 2 directories on the same machine)


Unison lets you sync files in both directions. The “rsync” tool does just one way sync. (It overwrites any changes on the destination machine) The “unison” asks you which direction you want to overwrite for each difference in file/dir.

For brief into and history, see Wikipedia Unison. Unison home page is at: www.cis.upenn.edu unison.

Both machines must have unison installed.

  • Type “unison -help” for list of options.
  • Type “unison -doc topics” for tutorial on different topics.

Unison version must be the same on both machines. Type: unison -version to find out what version you are running.

Usually, you install multiple versions of Unison on the same machine.

To start with a particular version, start you command like this: “unison-2.32 ...”.


Local OS X to remote OS X

Here are some examples of commands that i actually use. I use it for synching my local files and a remote server, both running OS X:

unison -servercmd /sw/bin/unison ~/uci-server/vmm -ignore "Name .DS_Store" ssh://xahlee@example.com//Library/WebServer/Documents/vmm

In this server, it contains works done by other people, so i can't just update it one-way with rsync.

The “-servercmd /sw/bin/unison” specifies the path of the unison command on the server. (needed when it is not in the default search path on remote machine's user account)

The “~/uci-server/vmm” is the local dir. The “ssh://xahlee@example.com//Library/WebServer/Documents/vmm” specifies the remote dir, remote machine's domain name, login account, and the protocol to use.

The -ignore "Name .DS_Store" tells it to ignore the Mac's temp file “.DS_Store”.

PC and Mac

Synching my PC and Mac:

unison -servercmd /usr/bin/unison c:/Users/xah/web ssh://xah@

If you are syncing from Mac and Windows, you many want to add “-rsrc false”, which will ignore resource fork and file type info. If you want to ignore file permissions, you can use “-perms 0”.

Note that Unison as of version 2.27, it may have problems with file names containing Unicode chars. So, if you have files with Chinese chars, math symbols, etc, Unison will still work but the result file name will be gibberish. You might checkout the option “-unicode”.

Dir ending in Slash or no?

WARNING: It is important to know whether directory path should end in a slash or not. Also, it makes a difference whether it is the source dir or destination dir.

For a example discussion different semantics of this, see: Idiocy Of Unix Copy Command.

For many language and tools, with a slash or without a slash at the end means the same thing. However, for some tools it has different meanings, and their meanings may not be the same. For example, in rsync, the following:

rsync -r -v -t --delete --exclude="**/My *" --rsh="ssh -l xah" ~/Documents ~/web ~/Pictures ~/ErgoEmacs_Source ~/Shared ~/cinse_pixra3 xah@

If you added a slash in one of the source dir, the dir won't be copied over but only their children, resulting spam in the top level destination dir, or overwriting dirs of the same name.

If you missed the slash at the destination dir above, it will wipe out all basically all dirs in the destination.

Most tool's documentation usually isn't very clear or precise about this. Best thing to do is to test some sample cases yourself.


Emacs Form Feed (^L) Display Suggestion and Tips

Perm url with updates: http://xahlee.org/emacs/modernization_formfeed.html

Emacs Form Feed (^L) Display Suggestion and Tips

Xah Lee, 2010-06-24

This page discusses some problems involving the Form feed character (^L) in emacs, and gives you some tips for better solution.

In emacs lisp source code, sometimes you'll see “^L”. That's the “form feed” character, ascii 12. For example, type “Alt+x describe-function”, then dired, then click on the “dired.el” link to view the source code. Scroll around and you'll see it.


The form feed char is used in 1990s or earlier to cause printer to start with a new page. Printers today no longer use that in their protocol. However, sometimes it is also used by programer as a section marker. Many emacs lisp source code still have it. It is also sometimes seen in Python source code.

The displaying of ^L is hard to read, and is mysterious to modern programers.


You can make emacs display a horizontal line instead. You need to install Pretty Control-L minor mode, by Drew Adams. Download at: emacswiki.org PrettyControlL.

To install, place the file in your “~/.emacs.d/” dir, then put the following in your emacs init file (“~/.emacs”):

;; add the dir to load path
(add-to-list 'load-path "~/.emacs.d/")

;; display horizontal line for the Form Feed char (ASCII 12, ^L) The
;; Form Feed char is often used in elisp source code for marking
;; sections. The command forward-page (and backward-page) moves to the
;; next form feed char.
(require 'pp-c-l)
(setq pp^L-^L-string "                                                           ")
(pretty-control-l-mode 1)

By default, it'll display a line, but also with the annoying text “Section (Printable Page)”.

The line “(setq pp^L-^L-string ...)” above solves that problem.

Hotkey to Jump to Form Feed

Also, emacs support a hotkey to jump to the form feed char. By default, the key is “C-x [” and “C-x ]”. Very hard to use and hard to remember. You can set a more convenient key. For example:

;; shortcut for moving to prev/next form feed 
(global-set-key (kbd "<M-S-next>") 'forward-page) ; Alt+Shift+PageDown 
(global-set-key (kbd "<M-S-prior>") 'backward-page) ; Alt+Shift+PageUp

Note that emacs already uses Ctrl+Page up/down for scrolling left/right, and Meta+page up/down for paging up/down the next pane, and Shift+Page up/down selects text. You should not use Ctrl+Shift combo because Ctrl+Shift+‹letter› is avoided because text based terminals have problems distinguishing the key from non-shifted letters.

If you have Hyper key set, you can use the following more easier keys:

(global-set-key (kbd "<H-next>") 'forward-page)
(global-set-key (kbd "<H-prior>") 'backward-page)

If you don't use the number pad keys, you can set it to those keys, like this:

(global-set-key (kbd "<kp-9>") 'backward-page) ; keypad 9
(global-set-key (kbd "<kp-6>") 'forward-page) ; keypad 6

For how to set up hyper key and others, see: How to Define Keyboard Shortcuts in Emacs.

Typing the Form Feed Char

In emacs, you can type the char by pressing “Ctrl+q” then “Ctrl+l”.

(For explanation of this, see: The Confusion of Emacs's Keystroke Representation.)

Advantages of Using Form Feed As Section Marker in Source Code

Normally, programer mark section in source code with lots of comment chars. For example:





These are not as elegant or convenient as the form feed char. First problem is typing them. Even if your editor provide a easy way to type the char repeatedly, such as emacs's “C-u 50” prefix, that's still 4 or 5 extra keys to press.

It is also hard to search. Because the style varies, some source code repeat the comment chars such as “##########”, some start with a comment char then followed by dashes “#----------”, some uses underline, some draws a ascii art box, like this:

#      functions             #

All these variations makes it hard to jump to the section. Typically, you search the string, for example, search a sequence of 5 #, but because the line has more than 5, your search will linger on the same line. Instead, you have to search almost the exact the number of chars used for this, and it is common that the number of chars for such line is not consistent. Or, you may use regex, but again, much more typing and the result is not precise.

The form feed char has several advantages over this. If you use it for section mark, it makes it precise, easy to locate, and easy to navigate to all different sections. All this because there's a single ^L char as a delimiter, and it's meaning is basically universal.

Problems of Using Form Feed As Section Marker

In lisp, the form feed char is ignored by the compiler. This is probably true for vast majority of languages today still. Though, make sure that if you use the char, your language will have no problem with it. You could also insert one comment char in front of it.

A major problem of using form feed char for section break is simply the visibility. Almost no editors display the form feed as a line. So, for vast majority of coders, a sequence of dash “----------” is simply the more practical solution. Also, today, few programers know how to insert a form feed character in their editor.

For reasons of why it is displayed in emacs as ^L, see: The Confusion of Emacs's Keystroke Representation.


emacs switching to Scheme

Perm url with updates: http://xahlee.org/UnixResource_dir/writ/emacs_switch_to_scheme.html

Emacs Switching to Guile Scheme Lisp?

Xah Lee, 2010-06-23

Recently, there's discussion on Emacs dev forum about switching to Guile, a Scheme lisp. Of course, such discussion always sparks controversy. Namely, the Common Lisp camp isn't happy. Among the posts in the emacs dev list, those by Thomas Lord has some good info of emacs and Guile history around late 1990s. See: emacs dev. 2010-04-11, Thomas Lord.

Here's the post that the Guile's current maintainer, offers his help on this and why he thinks it's a good choice. emacs dev. 2010-04-14, Andy Wingo.

Whisper to myself: please don't fuck up, please don't fuck up.

I hope the emacs maintainers would just let Andy do his work. In non commercially backup open source projects (e.g. not Google, Firefox), there's always huge number of opinions, ideologies, arguing and arguing for years, nothing gets done. What actually happens in the end is whoever wrote the code and made it work, ends up as real progress; bad design choices or other problems not withstanding. Ideology and “good” design oriented intentions usually don't go anywhere.

From my own experiences, i find it true of Thomas's account of the late 1990s history of gnu language. I also think moving to Guile is the best practical choice for emacs, in particular because there's someone willing and able to do the work.

It's been 10 years. Sun Microsystems, once was trying to kill Microsoft, is now dead. (am very, very glad. There's no commercial software company i hate more than Sun Microsystems) Perl, once was the craze and number 1 scripting language, is now barely heard (am also very, very glad). For detail, see: Language, Purity, Cult, and Deception.

a Mathematica book citing my article

Perm url with updates: http://xahlee.org/comp/blog.html

Discovered a new book that cites my site. The book is:

Mathematica Cookbook (2010), by Sal Mangano. amazon.

The citation is: The Concepts and Confusions of Prefix, Infix, Postfix and Fully Nested Notations.

For more, see: Printed references to XahLee.org and XahLee.org Site Awards and Recognitions.


emacs byte compile incompability on 23.1 vs 23.2

Perm url with updates: http://xahlee.org/emacs/elisp_byte_compile_problem.html

Emacs byte compile incompability on 23.1 vs 23.2

Xah Lee, 2010-06-22

Stung by a emacs byte-compile problem. Cost: 2 hours.

Summary: if you are doing elisp dev on more than one machine, best to re-byte-compile the files on the machine if you run into some strange errors.

Byte compiled elisp files should work cross-platform for emacs 23.2. It has been working between my Windows Vista and Mac 10.4.x in the past year. Today, i just byte compiled the whole dir of elisp files on our ErgoEmacs source trunk, then synced over to my Mac as a regular routine, then started emacs on my Mac. I keep getting this strange error on my Mac:

Wrong number of arguments: called-interactively-p, 1

Very odd error. Starting emacs with “--debug-init” didn't help. Turning on toggle-debug-on-error while emacs is running didn't help much neither.

I thought some new change i made to ErgoEmacs recently caused the error. So, i started to bebug. Tried to comment out various packages, but it's elusive. One time commenting out loading package X seems to work, but another time no, but commenting out package Y worked.

First i thought the problem is the ErgoEmacs Keybinding minor mode. Then i'm sure it's YASnippet. But that's odd, because we haven't touched that package for many months. Then, i think it could be xbbcode-mode.

Very odd error. “Wrong number of arguments”. Thats pretty much the error you'll notice first when you write a new function. And “called-interactively-p”?? In the “*Messages*” buffer, i also saw something about a hook that caused this. Bah, there's lots hooks in ErgoEmacs. The ErgoEmacs keybinding has hooks, yasnippet adds hooks i think. Maybe the new version off PrettyControlL (pp-c-l) i just updated today caused the problem.

In short, took me 2 hours to eventually realize that it is the “.elc”. Byte compile the whole elisp dir of packages on the Mac made it work.

Emacs 23.2's release notes does not mention any byte-compile incompatible changes.

Not quite sure what's the problem exactly. The emacs on my Windows is Emacs 23.2.1, while on the Mac is 23.1.1.

Note: emacs 22 can't read emacs 23's byte compiled file if the file contains unicode chars, due to emacs 23's unicode change. See: New Features in Emacs 23.


emacs. new version of bbcode and unicode browser modes.

A new version of bbcode-mode.

Also a new version of xub Unicode Browser mode.

Petronas towers

Perm url with updates: http://xahlee.org/dinju/Petronas_towers.html

Petronas towers

Petronas Towers. A incredibly beautiful skyscraper, modeled in the style of ancient South Asia temples.

Have a look at Khajuraho Temple, which is a ancient temple in India. You can see the similarity of the style.


xub Unicode Browser mode for Emacs

Perm url with updates: http://xahlee.org/emacs/unicode-browser.html

Emacs Unicode Browser: xub-mode

Xah Lee, 2010-06-20, ..., 2010-12-20

This is the home page for xub-mode, a Emacs major mode for browsing unicode characters.

Current version is 1.1.4, 2010-12-20

Usage and Features

To start the mode, type 【Alt+x xub-mode】.

When this mode is on, pressing the arrow keys will display info about the character under cursor. Pressing mouse left button on a character also works.

emacs xub-unicode-browser2

xub-mode in action. (this is a older screenshot. The zoom in/out keys have changed.)

Press 【Ctrl++】 to zoom in. 【Ctrl+-】 to zoom out. Or, you can hold down Ctrl and scroll mouse wheel.

There's a menu named “XUB” at the top.

While in the mode, type 【Ctrl+h m】 (describe-mode) to see inline documentation.

Unicode Files

The mode includes about 20 files of unicode symbols of different categories, used as a character palette. Some of the palette's characters can be seen in the following:

Get Unicode Font

For best result, you'll need a font that support unicode. See: Best Fonts for Unicode.

Also, you should be using Emacs 23, because it has a entire new unicode engine and font engine that supports operating system's fonts.

Buy xub-mode Now

Download the mode for $3. In the comment field, put “emacs unicode browser”. I'll email you the download link. Make sure your email address is included and correct.