Xah Emacs Blog

Buy Xah Emacs Tutorial. Master emacs benefits for life.

Tips & Tricks for emacs and emacs lisp.

Atom.io editor, JavaScript ES6, Xah JavaScript Tutorial

JavaScript libraries now outnumber any language's libraries.

Guthub's Atom.io editor is completely written in JavaScript. Part of it is released as “electron” framework, which allows writing desktop apps using {JavaScript, HTML, CSS}.

It's quite amazing. Atom.io, is essentially running in a web browser as app. All the GUI, is the browser in disguise. The components are node.js and Chrome (Google's open sourced part of Google Chrome browser). (node.js or its new fork node.io lets you run JavaScript as a language engine without browser, much the same way you run python, perl, ruby, etc. node.js is based on Google's V8 JavaScript engine (which is used by Google Chrome)).

ECMAScript 2015 Language Specification – ECMA-262 6th Edition is released last month, 5 years after the previous ECMAScript Language Specification - ECMA-262 Edition 5.1

I've been continuously working on my JavaScript Tutorial for more than a year now.

it's more complete and more accurate than my Emacs Lisp tutorial

There are Microsoft JavaScript tutorial, Mozilla's JavaScript tutorial, and few books that are free online. The Microsoft one is not bad, the Mozilla's lousy, as it's a wiki, but the reference section is great and indispensible, as it covers the hundreds of DOM objects and methods. There are a few other JavaScript turorial online i can think of.

I intend my JavaScript to be the best on the web, and i think am doing reasonably well. In particular, my tutorial is:

  1. Syntax focused. (or, in jargons, it takes the perspective of formal language.) That is, it take the approach of “when you type this, what happens”. (as opposed to a internal computing “model”). JavaScript is particularly suitable for the formal language approach.
  2. Clarity in explaning the confusing part of JavaScript object system.
  3. Example based. Every explanation comes with a example, so its: ① practically useful. ② veritably correct in browser.
  4. Concrete and to the point, and about the JavaScript language only. No use of jargons or concepts of spurious software engineering point-of-view, such as “patterns”, “anti-patterns”.
  5. For people who already know how to program. You don't have to wade-thru tens of pages to learn what is a variable, function, module, etc.
  6. Concise. No story-telling style. Every word counts.

Give it a shot, and let me know what you think.

Xah JavaScript Tutorial by Example

emacs bug: can't paste into emacs

there's this bug that started to happen about a year ago. Emacs 24, and 25.

  • GNU bug report logs - #16737
  • From: Sujith Manoharan
  • Subject: 24.3.50; Yank causes hang
  • Date: Thu, 13 Feb 2014 09:10:55 +0530

Pasting content selected in a browser causes Emacs to hang completely sometimes. This is not consistently reproducible, but it happens after a few hours of usage, sometimes days.

from http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16737#17

This happens to me when i use xah-find-replace-text on few thousand files. 〔➤ Emacs Package: xah-find.el grep/sed in Pure Emacs Lisp

not always, but most of the time.

the number of files doesn't seem to matter. But what matters is likely the number of replacements.

there are 10 or so people wrote in that thread who also have the problem. But, a reproducible step is hard to get.

however, there's a reproduction steps described here

From: "Alan D. Salewski"
To: 16737 @ debbugs.gnu.org
Subject: Re: bug#16737: Timed out waiting for reply from selection owner
Date: Sun, 14 Jun 2015 23:00:34 -0400

The below cookbook works to reproduce the issue for me every time, so I
can now trigger the issue on-demand.

As noted in message #149 above[0], I'm running the
'emacs24-lucid-24.4+1-5' package on Debian GNU/Linux; x86_64; 4 core
Intel i7.

I'm running an X11 window manager (sawfish) with no clipboard manager.

To reproduce the issue:

    1. $ type -a emacs
       emacs is /usr/bin/emacs

       $ readlink -f /usr/bin/emacs

       $ emacs -Q

       The "*scratch*" buffer is visible.

    2. M-x server-start

    3. In a terminal window (xterm in my case):

       $ emacsclient -t

       The "*scratch*" buffer is visible here, as well.

    4. Select a sizable bit of text to the X11 clipboard. A small amount
       of text won't trigger the issue, but I don't yet know what the
       boundary is. For my testing, I have a browser window open to
       this web page in iceweasel (firefox), and use the 'C-a' hotkey in
       that app followed by 'C-c' to select the full page of text:


    5. In the emacsclient window in the terminal emulator, paste the
       text from the clipboard. I use the middle button on my 3-button
       mouse to do this.

    6. Back in iceweasel, select any small amount of text (~20 chars is
       fine) from the same page (again, using 'C-c').

    7. In the X11 emacs frame, position the mouse pointer over the
       blinking cursor and press the middle mouse button to attempt a
       "paste" operation (mouse-yank-primary).

       Emacs appears to hang for about 20 seconds, and then the "Timed
       out waiting for reply..." message appears.

The cookbook works not only with the stock Debian 'emacs24-lucid'
package, but also with that package compiled with different build time
options (-g, -O0, -DTRACE_SELECTION). The cookbook also works when I
build with random other debugging code compiled in (all based on the
Debian source package emacs24-24.4+1). It does not seem to be sensitive
to being set up "just right".

A slight variation of the above cookbook works with the stock 'emacs24'
Debian package (same version as the '*-lucid' package above), which is
the variation compiled to use gtk. For this version, the small amount of
text selected in step 6 above does not seem to trigger the issue, but
pasting the full amount of text from the web page does. So the cookbook
variation here is to simply skip step 6 (or replace it with step 4, if
some other process has become the X11 selction "owner"). When running
this version, the paste into the X11 emacs frame is preceeded by a pause
and CPU spiking to 100%, the same as indicated by other reports.

Once the issue has been triggered, no further "paste" operations will
work in any emacs X11 frame that is part of the same emacs process, at
least not without using gdb to jump over these lines in
x_get_foreign_selection (xselect.c):

1241    if (NILP (XCAR (reading_selection_reply)))
1242      error ("Timed out waiting for reply from selection owner");

Once those are jumped, the "paste" operation completes (the text shows
up on the buffer, as desired), but the state is still hosed.

Pasting into 'emacsclient -t' buffers running in terminal emulator
windows (xterm) does continue to work, though. So if somebody is truly
desperate to keep a given emacs process alive, keeping a terminal-based
emacsclient window handy as a target for paste operations could serve as
a workaround once the issue has been triggered.


[0] message #149

Emacs, Atom, JavaScript

Atom 1.0 released. Syntax Coloring in Editors. Added Atom screenshot.

I'll be looking into Atom a lot.

Emacs Lisp: with-syntax-table Leaking Bug

Emacs vs Vim Tip jar (on its own page)

make the Menu/App Key as leader key. Emacs: How to Define Menu/App Key (much expanded. On its own page.)

emacs lisp manual is updated to for emacs 24.5. (info "(elisp) index")

Emacs Lisp: How to Name Your Major Mode (major update)

What's Emacs Lisp feature? (on its own page)

Syntax Coloring in Editors added Microsoft Visual Studio, Slime Text.

Should emacs be different? Alternate Title: New vs. Old: the interface issue that just won't go away

controversy. See: 〔《Should emacs be different? Alternate Title: New vs. Old: the interface issue that just won't go away》 @ http://www.reddit.com/r/emacs/comments/2yp9v7/should_emacs_be_ifferent/

my opinion posted there.

decades old issue. Note:

* there are just as many, who used emacs for 2 decades, believe that emacs default keys are the worst. You can see some of it in ergoemacs comments, some of which i've collected.

* you don't hear these people much because, such opinion are not inline with the emacs community, are raely propagated.

* i think emacs should turn on cua mode by default. More urgent than ever. Tons of new editors are still cropping up every year, and seems more so in recent years. Atom, Facebook's Atom derivative, and even Microsoft Code.

* In the past 5 years, in emacs 23 and 24, some controversial UI issues have been fought hard, and decision made towards modernization. For example, visual line arrow key movement. transient-mark-mode.

* emacs default keys are scientifically Repetitive Strain Injury inducing.

* emacs default keys, are not just bad for newbies, but are scientifically, technically, inefficient for expert emacs users.

* The ~7 de facto standard keys for copy cut paste undo open new save... if emacs adopts them, then, the keys would be technically, scientifically, more efficient, for long time emacs users, not just for newbies.

* I personally believe, emacs should adopt the ~7 de facto standard keys. because: 1, it will increase emacs users by i estimate at least 2 fold within one year. 2, it will make emacs keys more efficient for long time emacs users.

i have over a hundred articles on keybinding issues. The point mentioned above, especially about keys, i have scientific data to backup. If anyone is interested, ask me. It's all on my site, by the way.

I love emacs. Emacs the system, i think is still unbeatable in many ways. But its keys, i think is scientifically one of the worst, and as well the number one problem for new users to swallow. There are lots packages that provides alternative, but vast majority of emacs users (i believe more than 60%), are not those we see in online blogs or forums, and don't even know how to use packages. It needs to be the default.

for what's worth, that's my opinion. Thanks.

Syntax Coloring in Editors (major update. Commercial editor results added.)

keyboard key 2 vs b
keyboard key 2 vs b

result from yesterday's vote @ https://plus.google.com/113859563190964307534/posts/6xd4Xb71y5E

thanks to all who voted.

which key is easier to press, 2 or b?

vote here. https://plus.google.com/113859563190964307534/posts/6xd4Xb71y5E

Emacs: Run Interactive Clojure Shell/REPL in Emacs: CIDER if you are starting with Clojure, check it out.

Emacs Keybinding Syntax Examples (minor update)

List of Emacs Starter Kits (minor update)

emacs 24.1 variable: switch-to-visible-buffer

switch-to-visible-buffer → If non-nil, allow switching to an already visible buffer.

This variable was introduced, or its default value was changed, in version 24.1 of Emacs.

Keyboard: What's the Most Efficient Layout for Numbers?

Best Keyboard for Emacs (minor update; repost)

finally, we have a keyboard with a any key

keyboard.io model 01 right-side closeup
Keyboard.io Keyboard Model 01 ⌨

Emacs Lisp: HTML image-link Command (major rewrite)

Normal PC Keyboard with Many Thumb Keys

japanese keyboard
“Japanese USB wired PC keyboard” amazon

if you want a normal PC keyboard but with lots thumb keys for emacs hyper super, get this one.

for more, with mechanical keys, see: Should You Type Space After Comma? and Tiny Space Bar on Japanese Keyboards

Once you get such a keyboard, you can remap the thumb keys. For how to, see Keyboard Layout, Shortcuts Tutorial ⌨

this would beat many keyboard hacks that makes space bar do multiple things or quick key combos like df as leader key.

Emacs Lisp: Open File in External App (minor update code)

Emacs: New Empty Buffer (minor update)

Emacs: Xah CSS Mode, is ready for public use.

Major feature is keyword completion, and coloring of all keyword, not by form. (so, if there's a typo (invalid CSS), you'll know because it won't be colored.) See the link above for screenshot and more features.

Please give it a shot. I'm looking for comment and suggestions. I'll be submitting to MELPA. Thanks.

Emacs: Find & Replace Multiple Files by Function: Add Unicode Name in HTML (minor update, repost)

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

Emacs: Working with CSS Color Values (minor update. repost)

Emacs: Copy/Cut Current Line If No Selection (fixed a issue when cut all also includes previous kill)

Emacs: narrow-to-defun, eval-defun, bug

Emacs: Abbrev and Templates for Emacs Lisp Mode

very old package. updated.

Practical Emacs Lisp (index re-organized)

New version of emacs tutorial is sent to previous buyers. If you didn't receive the update, please email me at xah@xahlee.org . Thanks.

A new version of emacs tutorial is out. Buy Xah Emacs Tutorial

Buy, blog. Thank you.

Emacs's M-key Notation vs Alt+key Notation (7 years old article. Repost. Minor update)

Emacs Lisp: Multi-Pair String Replacement with Report (updated)

Xah Emacs Packages

in past weeks, i polished several of my packages and submitted them to MELPA. Check them out in above link. In emacs, just call list-packages, then search for “xah”. 〔➤ Emacs: How to Install Packages Using ELPA, MELPA, Marmalade

I also like to thank Steve Purcell, who is currently maintaining MELPA. It's huge amount of work. I noticed, everyday, he actually tests incoming packages to check on quality. That's several per day, like full-time job.

Steve Purcell also wrote many emacs packages. You can follow him at:

emacs: how to change font size

text-scale-adjust really useful.

Emacs: How to List & Set Font (updated)

Emacs Package: xah-find.el grep/sed in Pure Emacs Lisp

now on MELPA: http://melpa.org/#/xah-find

home page Emacs Package: xah-find.el grep/sed in Pure Emacs Lisp

Space-cadet Keyboard and Lisp Machine Keyboards (repost)

Emacs Lisp: xah-get-thing.el

now on MELPA. http://melpa.org/#/xah-get-thing

For detail, see Emacs Lisp: xah-get-thing.el

Emacs: Command to Lookup Google, Wikipedia, Dictionary, Programing Reference (package feature added. Version 2.1.0. Might take a while for MELPA to pickp the change)

emacs eww browser cookies/cache file location

it's at ~/.emacs.d/url/

detail at Emacs: Using Eww Web Browser. updated.

emacs lisp: convert string to symbol, symbol to string

;; convert a symbol to string
(symbol-name 'defun)

;; convert a string to symbol
(intern "something")

Emacs Lisp Symbol (tutorial) (minor update)

emacs lisp: test even/odd

(= (% n 2) 0) ; test even
(= (% n 2) 1) ; test odd

Emacs Lisp Tutorial by Example (minor update)

Emacs: Commands to Move Cursor by Brackets, Quotes (minor update. Now cursor movement covers ALL brackets. This replaces 90% need of ace-jump or similar.)

Emacs Lisp: Filter a List (minor code update)

Emacs Lisp: Using thing-at-point (minor update)

Keyboard: Home/End Keys Arrangement: Horizontal vs Vertical (repost)

xah-elisp-mode is now on MELPA


Lots improvements in the past half a year.

home page Emacs: Xah Emacs Lisp Mode

if you have any questions about emacs, elisp, or keyboard, ask me.

post at g+ or twitter

Now on github and MELPA. Emacs: xah-math-input.el

Emacs: Associate a File with a Major Mode (repost)

Celebrity Programers with RSI (Repetitive Strain Injury) (repost)

Emacs: avy ace-jump vs isearch

Emacs: isearch by Arrow Keys

2 videos on the Kinesis keyboard. Kinesis Keyboard Review

Does Mechanical Keyboard Reduce Risk of Repetitive Strain Injury?

if you are thinking of buying a mechanical keyboard, and have questions, post and i'll try to answer.

post here https://plus.google.com/113859563190964307534/posts/DyxXPXehnit

I think you need a Google account. But you can also ask me on twitter.

GNU Logo Latte Art (repost; on its own page.)

Happy Hacking keyboard replacements. Keyboards without Numeric Keypad (major rewrite.)

Daniel P Friedman and Matthias Felleisen's books

Daniel Paul Friedman (born 1944) is a professor of Computer Science…

With David Wise, Friedman wrote a highly influential paper on lazy programming, specifically on lazy streams (ICALP 1976). The paper, entitled “Cons should not evaluate its arguments,” [1] is one of the first publications pushing for the exploration of a programming style with potentially infinite data structures and a form of programming that employs no computational effects (though programs may diverge).

In the 1980s, Friedman turned to the study of Scheme. He explored the use of macros for defining programming languages; with Kohlbecker, Felleisen, and Duba, he co-introduced the notion of “hygienic macros” in a 1986 LFP paper that is still widely cited today.[2] With Haynes and Wand, he simultaneously studied the nature of continuation objects, their uses, and the possibilities of constraining them.[3] Following that, Friedman and Felleisen introduced a lambda calculus with continuations and control operators.[4] Their work has spawned work on semantics, connections between classical logic and computation, and practical extensions of continuations.

Friedman is also the lead author of Essentials of Programming Languages, a text book on programming languages. As such, it changed the landscape of language text books in the 1980s, shifting the focus from surveys of languages to the study of principles via series of interpreters. Today's text books on this topic tend to follow this organization, though use operational semantics and type theory instead of interpreters. Like The Little LISPer, Essentials of Programming Languages is a long-living book and is in its third edition now.

Most recently, Friedman resumed work on his “Little” series with The Reasoned Schemer (with Byrd and Kiselyov), explaining logic programming via an extension of Scheme.

Daniel P. Friedman

Daniel P Friedman home page: http://www.cs.indiana.edu/~dfried/

Matthias Felleisen is the founder of PLT Scheme Lisp (now Racket Scheme Lisp). Felleisen was a student of Daniel P. Friedman.

Matthias Felleisen

Daniel P Friedman books
Daniel P Friedman books on amazon

Ruby Creator Matz on How Emacs Changed My Life (repost)

simple example of using emacs lisp for text processing. Emacs Lisp: Text Processing, Transforming Page Tag (old page, updated)

new Emacs: Convert Straight/Curly Quotes

Emacs: Copy/Cut Current Line If No Selection (updated code)

Emacs Lisp Idioms: How to Cut/Copy/Paste to/from kill-ring? (minor update)

Emacs: What's Region, Active Region, transient-mark-mode? (updated)

now on MELPA. http://melpa.org/#/xahk-mode

home page: Emacs AutoHotkey Mode (ahk-mode)

see also: AutoHotkey Tutorial ⌨

new from Microsoft: Microsoft Universal Foldable Keyboard

Keyboard for Programers: Layouts, Shortcuts, Macros, RSI ⌨ redesigned index page. Everything you ever want to know about keyboards.

Mac OS X: How to Create Keyboard Layout and Keybinding ⌨ (minor update)

Emacs: Using Org Mode for Todo (minor update)

Emacs Lisp: Escape Quotes (minor update) This is useful for elisp coders.

Emacs: Use Alias to Increase Productivity (minor update)

Thanks to George Jones

xah-lookup.el on MELPA

xah-lookup.el is now on MELPA. http://melpa.org/#/xah-lookup

Emacs Lisp: CSS Compressor (updated code)

What's Lisp-1, What's Lisp-2? Bad Jargon or Good Jargon? (old rant.)

Emacs Lisp: Convert Unicode Chars to ASCII (Zap Gremlins) (updated code. now supports all Chinese pinyin tones.)

Emacs Lisp: Chinese Character Reference Linkify (updated code)

Like it?
Buy Xah Emacs Tutorial
or share