2015-02-06

Emacs Org Mode Bable bug. For emacs lisp, session is always on

Emacs Org Mode Bable bug. For emacs lisp, session is always on.

* test session; no session

#+BEGIN_SRC emacs-lisp :exports both
(setq x 3)
#+END_SRC

#+RESULTS:
: 3

#+BEGIN_SRC emacs-lisp :exports both
(+ 2 x)
#+END_SRC

#+RESULTS:
: 5

save the above as session-test.org, then open it, M-x org-mode. Move cursor to the elisp code block, press C-c C-c to eval. Repeat for the second block.

The expected result for second block should be error of unknown variable x.

2015-02-02

emacs: xah fly keys, harmless key maps

Global Bindings Starting With <menu> n:
key             binding
---             -------

<menu> n RET    Prefix Command
<menu> n SPC    Prefix Command
<menu> n 0      shell-command-on-region
<menu> n 1      set-input-method
<menu> n 2      global-hl-line-mode
<menu> n 3      whitespace-mode
<menu> n 4      linum-mode
<menu> n 5      visual-line-mode
<menu> n 6      calendar
<menu> n 7      calc
<menu> n 8      shell
<menu> n 9      shell-command
<menu> n a      text-scale-adjust
<menu> n b      toggle-debug-on-error
<menu> n c      toggle-case-fold-search
<menu> n d      narrow-to-page
<menu> n e      eshell
<menu> n f      Prefix Command
<menu> n g      toggle-frame-fullscreen
<menu> n h      widen
<menu> n i      make-frame-command
<menu> n n      narrow-to-region
<menu> n r      read-only-mode
<menu> n s      flyspell-buffer
<menu> n t      narrow-to-defun
<menu> n u      menu-bar-open
<menu> n w      eww

<menu> n SPC h  xah-toggle-read-novel-mode
<menu> n SPC n  xah-toggle-line-spacing
<menu> n SPC t  xah-toggle-margin-right

<menu> n f C-f  find-file-other-frame
<menu> n f C-o  display-buffer-other-frame
<menu> n f .    find-tag-other-frame
<menu> n f 0    delete-frame
<menu> n f 1    delete-other-frames
<menu> n f 2    make-frame-command
<menu> n f b    switch-to-buffer-other-frame
<menu> n f d    dired-other-frame
<menu> n f f    find-file-other-frame
<menu> n f m    compose-mail-other-frame
<menu> n f o    other-frame
<menu> n f r    find-file-read-only-other-frame

<menu> n RET F  set-file-name-coding-system
<menu> n RET X  set-next-selection-coding-system
<menu> n RET c  universal-coding-system-argument
<menu> n RET f  set-buffer-file-coding-system
<menu> n RET k  set-keyboard-coding-system
<menu> n RET l  set-language-environment
<menu> n RET p  set-buffer-process-coding-system
<menu> n RET r  revert-buffer-with-coding-system
<menu> n RET t  set-terminal-coding-system
<menu> n RET x  set-selection-coding-system

These are keys starting with 【▤ Menu n】 from xah fly keys Mode. This key set is for commands that are “harmless” — even if called accidentally. They usually do prompt or do some display changes, and never edit anything.

What's the Impetus that Made Lambda Calculus So Powerful?

what's lambda calculus? It's a notation, and nothing but syntax & notation.

The λ-calculus is, at heart, a simple notation for functions and application. The main ideas are applying a function to an argument and forming functions by abstraction. The syntax of basic λ-calculus is quite sparse, making it an elegant, focused notation for representing functions. Functions and arguments are on a par with one another. The result is an intensional theory of functions as rules of computation, contrasting with an extensional theory of functions as sets of ordered pairs. Despite its sparse syntax, the expressiveness and flexibility of the λ-calculus make it a cornucopia of logic and mathematics. This entry develops some of the central highlights of the field and prepares the reader for further study of the subject and its applications in philosophy, linguistics, computer science, and logic.

http://plato.stanford.edu/entries/lambda-calculus/

and that's why, syntax is the most important thing in languages. Programing Language Syntax Soup

2015-01-30

Clojure Support in emacs org-mode via nREPL/CIDER

Clojure Support in emacs org-mode via nREPL/CIDER

as you know, org-mode supports evaluating embedded source code of many languages. (that is, you can have many lang's code such as python in org file, then press a key to eval the code block and have the result embedded in the file (or just displayed), and when you export to HTML, you can also have it eval all source code and have result embedded in the doc.)

the current released version supports Clojure, but via SLIME, which is a engine for interaction with Common Lisp.

Using Clojure in emacs with SLIME is being obsoleted.

The good news is that, in the org-mode development version, it has a working version of clojure support with nREPL/CIDER.

goto http://orgmode.org/ and get the dev version.

basically, you just need to replace the old ob-clojure.el file with new.

how to use org mode's eval lang support? I'll have a article coming up. For now, you can read the official doc at http://orgmode.org/manual/Working-With-Source-Code.html#Working-With-Source-Code

if you don't know org mode basics, see Emacs: Writing Outline, org-mode Tutorial

Thanks to Bastien Guerry ( http://bzg.fr/ ), the current org-mode leader, and Eric Schulte ( http://www.cs.unm.edu/~eschulte/ ) who created the eval lang system in org-mode.

does md5 creates more randomness?

given a 32 digits hex number that is random enough. If i pass it thru md5, is the result more random or less?

few years back, i wrote a function to generate UUID, here: Emacs Lisp: Insert Random ID, Random UUID

I was simply calling random number function in emacs. Christopher Wellons improved it by first gather bunch of random info such as time, user's name, last keystroke typed, etc, then, feed it to md5, then basically use that result as UUID.

The question is, would that actually improve the function? That is, reduce the chances of generating the same UUID?

If you begin with random info such as time and user's last few keystrokes, then yes. But the step i don't quite understand is md5.

md5 takes arbitrary text and returns a 32 digits hexadecimal. Most or all other “hash function” do the same, that is, take a arbitrarily long or short text as input, and returns a fixed number of digits. But the interesting question is, such thing is mathematically impossible. Somewhat like a pigeon hole principle. You can never take many things and produce less things such that it is always unique for every input. The gist of “hash function” is about the impossibility of generating the input given the output. But, i don't know what's the uniqueness property.

2014-11-20

clojure problem: string not in core

string manipulation is the most important element in modern programing. This is the first thing you teach to beginners, about any language.

But with clojrue, it's not core part of the language. You need to load it as a lib, or, go use Java's string stuff.

Try to tell that to beginner. You either face the immense complexity of clojure namespace , or the immense complexity of dealing with a entire complexity bag the interoperation with Java.

PS: actually, just prefix the namespace. ⁖ (clojure.string/upper-case "xyz").

2014-11-19

One Weird Annoyance About Clojure: Java

one annoying thing about Clojure is that it runs on Java Virtual Machine. Clojure is actually a so-called hosted language, and this is by spec. (and JavaScript is a hosted language too. 〔➤ JavaScript Tutorial: Understand JavaScript in Depth〕).

This practically means is that, Clojure isn't a “fixed” language. For example, when it's running on JVM, its regex is Java syntax, its string functions are Java language's string methods. When it runs in JavaScript world (as ClojureScript do), its regex is JavaScript's regex. 〔➤ JavaScript Regex Syntax

But, that's not all. The MOST annoying thing is that, you actually need to know a lot about stinking Java in order to do any real world work with Clojure. (don't let any hacker type fanatics tell you otherwise) You need to know Java class/object system, its package system, its namespace scheme, Java Virtual Machine system, its compilation cycle, its tools and achive files. Even the official Clojure documentation, outright simply say things like “returns a Java xyz object.” with no further explanation, in lots of places.

it is not to be taken lightly, that when you learn Clojure, you actally need to gradually understand a lot about Java ecosystem too.

but at least, thank god, it's a lisp that has industrial value, and is a Java replacement.

2014-11-18

show/edit zip file content in emacs

there's a patch for opening zip files in emacs. When opening a zip archive of a single file, emacs now can display its content (and you can edit it)

See: 〈bug#1702: [PATCH]: feature request: correctly display single file zip archive〉 at

It's going to be in emacs 25.x. Thanks to Matthew Leach for the patch.

2014-11-15

clojure parser instaparse, and excellency of clojure docs

A clojure parser lib, instaparse: https://github.com/Engelberg/instaparse, seems to be the topnotch parser. Instaparse is written by Mark Engelberg.

It has excellent tutorial too. Clear, to the point.

so far i've seen, clojure community's doc is top-notch. The official documentation is excellent. The lib/build manager Leiningen's documentation is excellent. 〔➤ Clojure Leiningen Tutorial〕And now the instaparse documentation is excellent.

it appears, a language's community pretty much follows the style of its leader. In this case, it's Rich Hickey. You can see Hickey's writings, his documentation style, in several essays titled “Reference Documentation” at http://clojure.org/documentation. They are, concise, to the point.

meanwhile, python's documentation are pretentious garbage, following Guido's style. Here's a typical one: Python, Lambda, Guido: is Language Design Just Solving Puzzles?.

and perl's drivels are derived from Larry Wall's drivel. Here's a sample: Perl Documentation: the Key to Perl

for much more, see programing doc idiocies collection

2014-10-23

most popular pages on xahlee.info

  1. JavaScript: Get Elements by ID, Tag, Name, Class, CSS Selector
  2. Unicode Arrows → ⇒ ⇄ ↑ ↩ ⤢ ↱ ↷ ↻ ► ☛
  3. The Idiocy of Happy Hacking Keyboard
  4. JavaScript Tutorial: Understanding JavaScript in Depth
  5. CSS: Line Wrap Tutorial
  6. Python: How to Read & Parse JSON
  7. Python: Get Dir Path, File Name Part, File Name Extension, Absolute Path, Check File Existence …
  8. Unicode: Keyboard Symbols ⌘ ⏎ ↹ ⌫ ❖ ⇞ ⇟
  9. Unicode: Brackets & Quotation «» 「」 【】 《》
  10. Truly Ergonomic Keyboard Review
  11. Computer Keyboards, Layouts, Hotkeys, Macros, RSI ⌨
  12. Visual Dictionary of Special Plane Curves
  13. Keyboards without Numeric Keypad
  14. Keyboard Layouts Fight! Dvorak, Colemak, Workman, NEO, Bépo, …
  15. Simple & Useful AutoHotkey Scripts
  16. ∑ Xah Code
  17. Why LD_LIBRARY_PATH is bad
  18. List of HTML Self-Closing Tags
  19. Laptop Keyboards, No More Page Up/Down for You!
  20. Emoticons on Social Network: Facebook, Twitter, Sina Weibo
  21. HTML Framset Tutorial
  22. JavaScript: How to Change CSS
  23. HTML Frameset Index
  24. Unicode Characters ☢ ☯ ☭ ∑ ∞ ♀ ♂ ♥
  25. Difference Between Apple & PC keyboards
  26. HTML Frameset References
  27. HTML Split Windows; Frameset Example
  28. Geometry: Gallery of Surfaces
  29. Java Tutorial: The “extend” Keyword
  30. OCaml Tutorial by Example
  31. Ergonomic Keyboards Reviews: How to Chose a Ergonomic Keyboard
  32. Apple Computer Keyboards Gallery & Review
  33. Microsoft Natural Ergonomic Keyboard 4000 (review)
  34. AutoHotkey Key Syntax
  35. Pure CSS Table
  36. Mac OS X Resource Fork and Command Line Tips
  37. Equiangular Spiral
  38. Guide to Computer Keyboard Key Switch Mechanisms
  39. HTML Split Windows; Frameset Example
  40. JavaScript Floating Box Following Scroll
  41. Unicode Emoticons, Faces �� �� �� �� �� �� ��
  42. HTML Split Windows; Frameset Example
  43. http://xahlee.info/smart/ReportMain.htm
  44. Java Tutorial: The Power Function
  45. Ergodox Keyboard Review
  46. Using PowerShell to Manage Environment Variables
  47. Xah's Programing Blog
  48. Python: System Call Tutorial
  49. Great software for Tilings, Patterns, Symmetry
  50. Visual Dictionary of CSS