Xah Emacs Blog

Buy Xah Emacs Tutorial. Master emacs benefits for life.

Tips & Tricks for emacs and emacs lisp.

emacs major version of magit is out. To upgrade, call list-packages, press U x.

Emacs: Convert Straight/Curly Quotes (updated code. fixed a out-of-range bug.)

Emacs: How to Sort by Time, Size, in Dired? new command.

added a manifesto at Xah Emacs Tutorial

Emacs Lisp: Word to Wikipedia HTML Link

Emacs Lisp: Make HTML Ruby Annotation (on its own page)

gnu emacs lisp reference manual emacs 24.5 2015-07
GNU emacs lisp reference manual, for emacs 24.5. 〔photo By Jules L White〕 amazon

There's a new hard-printed edition of GNU emacs lisp reference manual, for emacs 24.5. amazon

The elisp manual is also online at https://www.gnu.org/software/emacs/manual/elisp.html

I have a copy with different CSS at (info "(elisp) index")

see also Which Chapters of Elisp Manual to Read?

if you want to learn practical emacs lisp, as fast as possible, i recommend you give my tutorial a shot. Practical Emacs Lisp

new version. Emacs Package: xah-find.el grep/sed in Pure Emacs Lisp. Now, prompt for path regex defaults to your current buffer file's extension, if any.

Emacs Lisp: Batch Convert Line Ending in Dired (updated code)

Microsoft Universal Foldable Keyboard is now available. For your phone or tablet.

Logitech G910 Keyboard. New key switch: romer-g.

Programer Repetitive Strain Injury

every month, i see stories of programer Repetitive Strain Injury.

Here's another one i ran into today.

My Experience with Repetitive Strain Injury (RSI) By Yi Tang. @ http://blog.yitang.uk/2015/07/19/repetitive-strain-injury/

Those, who carelessly advocates GNU emacs keys, or swapping Capslock and Control, should be … well, kicked, hard. They don't know what they are talking about. Most of them don't touch type. And, they don't type that much.

This is not a matter of funny trolling. It is a bunch of vocal people spreading harm in society.

over the past 5 years, things got tremendously better. There are now quite a few alternative emacs keybinding systems than the GNU Eamcs default, and quite a lot people using them, and it is no longer being ridiculed upon (⁖ hydra, god mode, key-chord-mode, evil-mode, spacemacs, ergoemacs-mode). Meanwhile, many ergonomic keyboards coming out, with mechanical keys too. 〔➤ Best Keyboard for Emacs

Still, there are still people, who chants GNU Emacs keybinding and or Swap capslock/Control, as a mantra.

Emacs's Customization Tutorial (minor update)

Emacs Lisp: Make Backup of Current File (minor update)

i watched Sacha's emacs hangout today. I hope to join in in the future. See: http://sachachua.com/blog/2015/07/july-2015-emacs-hangout/

emacs lisp REPL, associate it with buffer

Today's hidden Emacs gem: pressing C-c C-b in an ielm buffer lets you associate it with a buffer, so you can inspect buffer-local variables.

from Wilfred Hughes, https://twitter.com/@_wilfredh

via jcs @ http://irreal.org/blog/?p=4222

emacs lisp command to HTML markup ruby

Emacs Lisp: Make HTML Ruby Annotation

been busy with javascript in past weeks… to learn JavaScript, please subscribe to my web dev blog Xah's Web Dev Blog

Keyboardio will be in San Francisco, Monday, July 13, 2015 from 7:00 PM to 10:00 PM (PDT). If you want to try the keyboard, go there. Might need to register first, do now. https://www.eventbrite.com/e/meet-the-keyboardio-model-01-san-francisco-tickets-17316336629

thanks to https://twitter.com/EmmanuelOga for headup.

Emacs: Run Shell in Emacs (major update)

Emacs: What's the difference between {shell, term, ansi-term, eshell}? (minor update)

Emacs: Command to Open Menu (on its own page)

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 “what you see is what you get”. (as opposed to talking about a computing model underneath the language.)
  2. Clarity in explaining the confusing part of JavaScript object system.
  3. Example based. Every explanation comes with a self-contained example you can run, so its practically useful and veritably correct in browser.
  4. Concrete. 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
       /usr/bin/emacs24-lucid

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

           http://matt.might.net/articles/low-level-web-in-racket/

    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.

Thanks,
-Al

[0] message #149
    http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16737#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:

Like it? Buy Xah Emacs Tutorial.