Xah Emacs Blog

Buy Xah Emacs Tutorial. Master emacs benefits for life.

Tips & Tricks for emacs and emacs lisp.

Windows: Keyboard Layout Tools, Key Macro Tools ⌨ (minor update)

new photos. Logitech G710+ Mechanical Keyboard

word/letter frequency, key chord design

2 very interesting articles related to word/letter frequency, in particular, for the purposes of creating abbrevs, or key chords.

English Letter Frequency Counts: Mayzner Revisited or ETAOIN SRHLDCU By Peter Norvig. @ http://norvig.com/mayzner.html

Rare letter combinations and key chords By John D Cook. @ http://www.johndcook.com/blog/2015/02/01/rare-bigrams/

see also: 〔Using Emacs to figure out where I need to improve in order to type faster By Sacha Chua. @ http://sachachua.com/blog/2013/09/using-emacs-to-figure-out-where-i-need-to-improve-in-order-to-type-faster/

see also Computer Keyboard Layouts & Keybinding Design & Analysis ⌨

new, as promised. Emacs: Org Mode Tutorial: Embed Source Code, Literate Programing

Also updated all org mode tutorials:

New version of emacs tutorial is out. Long overdue. Buy it, thanks. Buy Xah Emacs Tutorial.

if you already got it, you'll get a update thru email.

Keyboard RSI: 《Biomechanics of the Upper Limbs: Mechanics, Modeling and Musculoskeletal Injuries》. See bottom: Computer Keyboard Design Flaws

History of Emacs & vi Keys (Keyboard Influence on Keybinding Design) (minor update)

new: Emacs: Org Mode Markup Cheatsheet

jbm has written a review comparing ergodox, truly ergonomic keyboard, and the new esrille. See bottom: Esrille New Keyboard (M-Type & TRON) from Japan

Emacs Lisp: Command to Change Earth-Coordinate to Google Map Link (minor update)

emacs org babel: elisp & clojure always session, ruby session require inf-ruby, python is good properly support session & no-session

Emacs Lisp: Delete Current File (minor update)

Emacs Lisp Examples, page 1 (minor update)

Emacs: Extend Selection, Select Text in Quote, Select Line, Select Block (Major update. Removed relying on the painful emacs syntax table. Back to simple text based search.)

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)

: 3

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

: 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.

Emacs Lisp: Delete Trailing Whitespace on Save and Compact Empty Lines (minor update)

Keybinding Science: Emacs C-u vs Prompt

Emacs: Interactive Abbrev in Shell (minor update)

Emacs Lisp: Convert Punctuation Between English/Chinese Forms (minor, updated code)

Emacs Lisp: Twitterfy

Emacs: Stop Cursor Going into Minibuffer Prompt (repost)

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.

the Esrille keyboard can be ordered now outside Japan. See its home page: http://www.esrille.com/keyboard/. My review at: Esrille New Keyboard (M-Type & TRON) from Japan

show pretty lambda in any mode. Added to Emacs: Pretty Lambda λ in Emacs 24.4

Emacs: How to Bind Keys for Major Mode? What's a Hook? (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 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 the output is never the same for any 2 input. Generally, i think the 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?

emacs clojure cider changes.

;; cider 0.8.2alpha 20141219.948
(defun cider-interactive-eval (form &optional start-pos callback) …)

;; cider 0.8.0snapshopt 20141030.214
(defun cider-interactive-eval (form &optional callback) …)

for my record.

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.

nREPL is written in Clojure. 〔➤ Clojure Tutorial: nREPL

Who uses nREPL?

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.

“eshell” keys & commands.

key             binding
---             -------

C-a             eshell-bol
C-c             eshell-command-prefix
TAB             eshell-pcomplete
RET             eshell-send-input
ESC             Prefix Command
<C-down>        eshell-next-input
<C-up>          eshell-previous-input
<M-tab>         eshell-complete-lisp-symbol
<backtab>       pcomplete-reverse
<down>          eshell-next-matching-input-from-input
<tab>           eshell-pcomplete
<up>            eshell-previous-matching-input-from-input

C-c C-a         eshell-bol
C-c C-b         eshell-backward-argument
C-c C-c         eshell-interrupt-process
C-c C-d         eshell-send-eof-to-process
C-c C-e         eshell-show-maximum-output
C-c C-f         eshell-forward-argument
C-c TAB         pcomplete-expand-and-complete
C-c C-k         eshell-kill-process
C-c C-l         eshell-list-history
C-c RET         eshell-copy-old-input
C-c C-n         eshell-next-prompt
C-c C-o         eshell-kill-output
C-c C-p         eshell-previous-prompt
C-c C-r         eshell-show-output
C-c C-s         list-processes
C-c C-t         eshell-truncate-buffer
C-c C-u         eshell-kill-input
C-c C-w         backward-kill-word
C-c C-x         eshell-get-next-from-history
C-c C-y         eshell-repeat-argument
C-c ESC         Prefix Command
C-c C-\         eshell-quit-process
C-c SPC         pcomplete-expand
C-c <return>    eshell-copy-old-input
C-c <space>     pcomplete-expand
C-c <tab>       pcomplete-expand-and-complete

C-M-i           eshell-complete-lisp-symbol
C-M-l           eshell-show-output
M-RET           eshell-queue-input
M-.             eshell-find-tag
M-?             pcomplete-list
M-n             eshell-next-matching-input-from-input
M-p             eshell-previous-matching-input-from-input
M-r             eshell-previous-matching-input
M-s             eshell-next-matching-input

C-c M-b         eshell-insert-buffer-name
C-c M-d         eshell-toggle-direct-send
C-c M-h         eshell-completion-help
C-c M-i         eshell-insert-process
C-c M-m         eshell-display-modifier-help
C-c M-n         eshell-next-input
C-c M-o         eshell-mark-output
C-c M-p         eshell-previous-input
C-c M-q         eshell-display-predicate-help
C-c M-r         eshell-previous-matching-input-from-input
C-c M-s         eshell-next-matching-input-from-input
C-c M-v         eshell-insert-envvar

Emacs Lisp: 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 Tutorial (minor update)

Emacs Lisp: Escape Quotes (Updated. Removed lib dependency)

Problems of Calling Unix grep in Emacs (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 occurances 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's no easy command to search the current string under cursor. You resort to the wilderness of 3rd party stuff.

Emacs: Search & Highlight Words

see also Emacs's Incremental Search (isearch) Problems

for unparalleled emacs efficiency, try ErgoEmacs mode http://ergoemacs.github.io/

for keybinding tinkerers, the ultimate efficiency, try xah fly keys Mode (more efficient than vim)

Emacs Lisp: Convert Unicode Chars to ASCII (Zap Gremlins) (updated code. Now it works on chars such as ā ē ī ō ū)

Secretly Sniff Anything Typed from Microsoft Wireless Keyboard

Emacs Lisp: Automatically Eval Elisp Code When File Opens

Emacs Lisp: Copy File Path of Current Buffer. Updated. Now the command also print the path.

Emacs Lisp: Writing a Toggle Command (new, on its own page)

Emacs: How to Turn Major/Minor Mode on/off? (major update)

the famous LISP expert Paul Graham asked how to type the logic symbol forall on Twitter. 〔https://twitter.com/paulg/status/555062607074586624〕.

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 OS X: Keyboard Layout, Keymapping, Keybinding, Software ⌨ (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%  xhm-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%  xhm-wrap-p-tag
   1988    0.23%  split-window-vertically
   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-shell-commands
    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%  xhm-toggle-syntax-coloring-markup
    443    0.05%  recenter-top-bottom

see Emacs's Command Frequency Statistics

Emacs Lisp: Decode URI Percent Encoding (major update)

see also: Emacs: Xah HTML Mode

Emacs: How to List & Set Font (updated)

Emacs Lisp: Switching Next/Previous User Buffers. Updated code. Now, has a feature to ignore dired buffers.

emacs & vi: Science of Command Efficiency (minor update)

Like it? or share

Past Articles by Date