Xah Emacs Blog Archive 2015-01
show pretty lambda in any mode. Added to emacs init: Display Lambda as λ
Emacs Keys: Change Major Mode Keys (updated)
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, Org-mode version 8.2.8 (current as of ) 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 https://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 https://orgmode.org/manual/Working-with-Source-Code.html
if you don't know org mode basics, see Emacs: Outline, org-mode Intro
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 hexadecimal 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: Insert 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 the output is never the same for any 2 input. Generally, i think the primary focus of “hash function” is more about the impossibility of generating the input given the output, and the “not getting the same output” (aka collision) is usually secondary. Does anyone know?
Monroe, Simple Clojure nREPL client for Emacs
if you are a Clojure programer and also a emacs lisp programer, you'd be interested in this.
“Monroe - Clojure nREPL client for Emacs” https://github.com/sanel/monroe
it is a SIMPLE nrepl for clojure in emacs.
here's a short explanation if you have no idea what it is.
- Clojure is a lang that runs on Java virtual machine (JVM), and comes with a basic “repl” tool, meaning, a command line interactive interface (aka shell).
- but the Clojure repl tool is “closed” tool. Meaning, other programs, such as emacs, cannot talk to it.
- So, “nREPL” is born. It is a Clojure library. “nREPL” stands for “networked” repl. Meaning, this program is a server and client that allows other programs to talk with Clojure thru network (e.g. network socket). This means, emacs or web based tools, can write programs to talk to Clojure. For example, emacs can have the ability to evaluate Clojure code while in emacs, or, run a Clojure shell inside emacs.
nREPL is written in Clojure. [see Clojure: nREPL]
Who uses nREPL?
- The Clojure build tool Leiningen uses it, which gives you a better clojure shell with extra features. [see Clojure: Leiningen Tutorial]
- The emacs Clojure mode, uses a emacs lisp package called CIDER to allow evaluation of Clojure code. CIDER itself, is a emacs lisp package that talks to nREPL. (CIDER requires Leiningen, which requires nREPL) CIDER gives you Clojure shell inside emacs. [see Emacs: Run Interactive Clojure Shell/REPL in Emacs: cider]
- gorilla-repl, a web-based Clojure interface. Clojure: Interactive Notebook. gorilla-repl
So, nREPL is a essential tool for Clojure.
And, for emacs, CIDER is the other essential tool, because it is thru CIDER (which talks to nREPL) that allows Clojure mode to eval Clojure code, as well as having a Clojure shell inside emacs.
But, here's the thing. CIDER is annoying in that it prints “hacker quotes” messages whever you start it. Also, it is large, some 7k lines. It's more than just a emacs client to nREPL.
Here's what “Monroe - Clojure nREPL client for Emacs” comes in.
i haven't tried it yet.
emacs has “eshell”, which is a shell written in emacs lisp.
I'm now fond of eshell. I tried to use it before, but always have problems. But now, eshell is actually better then shell for many tasks. It's hard to describe exactly. You just have to spend time to try and decide for yourself.
Emacs: Open File in External App 📜 (minor update code)
Corsair now has a compact version of its mechanical keyboard. See: Keyboard: Corsair K60, K65, K70, K95 Review
Emacs: magit-mode for git (minor update)
Emacs: Escape Quotes Command 📜 (Updated. Removed lib dependency)
Emacs Flaw: Problems of grep (old article)
emacs's isearch advanced features sucks
emacs's isearch advanced features
{isearch-forward-symbol-at-point,
isearch-forward-symbol,
isearch-forward-word}
are annoying, to the point of useless.
first problem is that they check boundary. So, searching “xyz” may not find “xyz2”. This seems useful to programers in source code, but is rather useless. Most of the time you want to find all occurrences of a string, even if it is part of another string. And, isearch-forward-symbol-at-point is very dangerous, in the sense that it seems to be convenient for searching the word under cursor, but the boundary check fools you.
then, the isearch-forward-word seems useful, as it will treat {_,-, } as same. But, it also checks boundary, and, you cannot find next occurrence as with isearch if it is not below cursor (it doesn't wrap). This too, fools you dangerously. You think some string doesn't occur, but you are WRONG! YOU NO UNSTAND emacs!
O, you can't easily modify them to make them work neither. isearch is a complicated special-case minor mode. It's easier if you just write a function from scratch.
to this date, there is no easy command to search the current string under cursor. You resort to the wilderness of 3rd party stuff.
see also Emacs Flaw: isearch Current Word
for unparalleled emacs efficiency, try ErgoEmacs mode http://ergoemacs.github.io/
for keybinding tinkerers, the ultimate efficiency, try Emacs: Xah Fly Keys 📦 (more efficient than vim)
Emacs: Remove Accent Marks 📜 (updated code. Now it works on chars such as ā ē ī ō ū)
Emacs: Copy File Path of Current Buffer 📜. Updated. Now the command also print the path.
Elisp: How to Write a Toggle Command (new, on its own page)
the famous LISP expert Paul Graham asked how to type the logic symbol forall ∀ on Twitter.
〔
this can be easily done. How to Create a APL or Math Symbols Keyboard Layout ⌨ (minor update)
the new Mac book is rumored to have the Power key at the Esc key location. A woe for vim users and emacs users alike.
to fix, see Mac: Keyboard Software Guide (updated)
for Linux and Microsoft Windows, see:
Emacs Command Frequency
my emacs command frequency.
For all major modes:
216265 24.78% self-insert-command
58315 6.68% next-line
47313 5.42% xah-beginning-of-line-or-block
41892 4.80% previous-line
41648 4.77% xah-end-of-line-or-block
40317 4.62% backward-word
38398 4.40% forward-word
23821 2.73% xfk-command-mode-activate
22765 2.61% isearch-printing-char
22113 2.53% xah-close-current-buffer
18698 2.14% xfk-insert-mode-activate
18337 2.10% mwheel-scroll
14144 1.62% yank
14032 1.61% newline
12238 1.40% delete-backward-char
10953 1.25% xah-backward-left-bracket
9751 1.12% handle-switch-frame
9411 1.08% save-buffer
8389 0.96% backward-kill-word
8187 0.94% backward-char
8186 0.94% isearch-repeat-forward
7409 0.85% xah-forward-right-bracket
6399 0.73% xah-shrink-whitespaces
6309 0.72% xah-cut-line-or-region
6040 0.69% kill-word
5807 0.67% xah-copy-line-or-region
5591 0.64% forward-char
5490 0.63% isearch-forward
4389 0.50% other-window
3945 0.45% open-line
3910 0.45% dired-previous-line
3857 0.44% undo-tree-undo
3532 0.40% isearch-exit
3413 0.39% dired-find-file
3378 0.39% dired-next-line
3359 0.38% delete-other-windows
3275 0.38% set-mark-command
3274 0.38% xah-open-file-fast
3213 0.37% minibuffer-keyboard-quit
3119 0.36% scroll-up-command
3042 0.35% delete-char
2986 0.34% xah-select-current-line
2644 0.30% xah-extend-selection
2642 0.30% xah-html-wrap-html-tag
2496 0.29% left-char
2422 0.28% xah-select-text-in-bracket-or-quote
2159 0.25% kill-line
2156 0.25% xah-open-file-path-under-cursor
2153 0.25% scroll-down-command
2105 0.24% org-self-insert-command
2081 0.24% xah-html-wrap-p-tag
1988 0.23% split-window-below
1943 0.22% xah-toggle-letter-case
1845 0.21% beginning-of-buffer
1819 0.21% xah-select-current-block
1722 0.20% exit-minibuffer
1650 0.19% keyboard-quit
1645 0.19% xah-compact-uncompact-block
1589 0.18% dired-jump
1515 0.17% right-char
1514 0.17% previous-history-element
1509 0.17% xah-next-user-buffer
1440 0.16% xah-clean-whitespace
1430 0.16% xah-all-linkify
1427 0.16% xah-browse-url-of-buffer
1225 0.14% xah-previous-user-buffer
1197 0.14% xah-forward-punct
1054 0.12% query-replace
1022 0.12% xah-copy-file-path
1013 0.12% ido-exit-minibuffer
953 0.11% isearch-repeat-backward
908 0.10% comment-dwim
895 0.10% xah-insert-paren
875 0.10% revert-buffer
836 0.10% xah-new-empty-buffer
826 0.09% xah-insert-corner-bracket「」
815 0.09% smex
805 0.09% markdown-enter-key
793 0.09% xah-insert-space-after
778 0.09% xah-interactive-abbrev
703 0.08% isearch-forward-symbol-at-point
682 0.08% xah-brackets-to-html
664 0.08% eshell
641 0.07% describe-key
619 0.07% delete-window
603 0.07% eshell-send-input
598 0.07% describe-function
520 0.06% xah-find-text
506 0.06% dired-up-directory
504 0.06% ido-delete-backward-updir
498 0.06% xah-delete-current-file
495 0.06% xah-run-current-file
489 0.06% xah-insert-double-curly-quote“”
472 0.05% recentf-open-files
460 0.05% xah-cite
451 0.05% magit-toggle-section
443 0.05% xah-html-toggle-syntax-coloring-markup
443 0.05% recenter-top-bottom
…
Elisp: URL Percent Decode, Encode (major update)
see also: Emacs: Xah HTML Mode 📦
emacs init: Set default font (updated)
Emacs: Next/Previous User Buffer 📜. Updated code. Now, has a feature to ignore dired buffers.
emacs and vi: Science of Command Efficiency (minor update)