Xah Emacs Blog Archive 2011-11 to 2011-11

Emacs Lisp Exercise: latitude-longitude-decimalize

Updated: Tips on Long Term Emacs Productivity.

Updated: Emacs: View Info Page

Updated: Emacs Regex Quirk: Matching Beginning/End of Line/String/Buffer

Emacs: Flow Buffer from Left to Right Window

Emacs for Windows; Crash on linum-mode

Steps to reproduce:

Thanks to Jon Snader for discussion.

Spent about 10 hours keyboard geeking again. Several major updates in the following pages. Addition of some 15 glorious photos of keyboards and their layouts.

The Glorious μTRON Keyboard

Emacs: Insert Parenthesis by Pair: electric-pair-mode

Emacs Lisp Example: wrap-html-tag

A little elisp command, useful if you do a lot HTML coding.

(defun wrap-html-tag (tagName &optional className $id)
  "Add a HTML tag to beginning and ending of current word or text selection.

If tagName is empty or nil, use “span”.
If className is empty or nil, don't add any class attribute.
If ξid is empty or nil, don't add id attribute."
  (interactive "sEnter tag name:
sEnter class:
sEnter id:")
  (let (bds p1 p2 inputText outputText)
    (setq bds (get-selection-or-unit 'word))
    (setq inputText (elt bds 0) )
    (setq p1 (elt bds 1) )
    (setq p2 (elt bds 2) )

      (if (or (equal tagName nil) (string= tagName "")) "span" tagName)
      (if (or (equal $id nil) (string= $id "")) "" (concat " id=\"" $id "\""))
      (if (or (equal className nil) (string-equal className "")) "" (concat " class=\"" className "\""))
      (if (or (equal tagName nil) (string= tagName "")) "span" tagName)
      ">" ) )

    (delete-region p1 p2)
    (goto-char p1)
    (insert outputText) ) )

Remember to bind it to a key.

I used some elisp utils i wrote. You'll need to get it at: xeu_elisp_util.el http://code.google.com/p/ergoemacs/source/browse/packages/xeu_elisp_util.el

Or, replace the get-selection-or-unit part by thing-at-point. For tutorial, see: Elisp: Using thing-at-point.

by the way, you could define your own commands for all HTML tags, but you probably shouldn't. html-mode has keys to insert many basic HTML tags. [see Emacs HTML Tips] Also, yasnippet has a whole set of HTML templates. [see Emacs Templates with YASnippet]. Though, still sometimes they don't cover everything you need. That's when adding your own is helpful.

from yesterday: Ergonomic Keyboards: Microsoft 4000 vs Natural Elite @ http://xahlee.blogspot.com/2011/11/ergonomic-keyboards-microsoft-4000-vs.html. PS if you are a customer of Amazon, feel free to buy from my site's links. Thank you for support.

Thank You from Xah Lee

I want to write a quick Thank You to those of you who read my emacs blog, and also to many who have donated.

Reminder: it's preferred that you post questions as comments to my blog or website, because it gets seen by many, also better for my blog because people can see interaction. My email is often flooded, though i try to reply to all.

Also thank you for those who have donated, or bought my emacs tutorial. I haven't had a chance to update my Donor List. There is one person, Aigerim, who bought my entire website (for offline reading) for $100. Thank you Aigerim so much!

Am writing this quickly, been wanting to write it for a couple of weeks now. Wanted to mention all names but big plan always results in no action.

I want to thank those who retweeted my emacs tutorials, linked to my site, those who commented on my articles, or exchanged emails, and also those on Facebook and g+. I'm not much a social person, not much into chitchat, and don't like to follow marketing strategies on “establishing communities” or such, but i appreciate many discussions and support. Lew Perin recently sent me a printed pamphlet “Emacs Quick Ref”, of 3 leaflets, that was from 1984 of MIT's Project Athena. Thank you Lew for such a treasure. I hope to take a photo of it and show it to all soon.

On last note, my annual income is about USD$2.5k for the past few years. (or ~$200/month.) So, your donation is appreciated, or, Buy Xah Emacs Tutorial. As far as i know, no emacs book covers elisp as much except GNU Emacs Lisp Reference Manual. With your donation, i'd be able to write a complete cookbook, covering topics such as full controlling GUI elements (windows, frames, menu), text highlighting, emacs input system, display system, IO system, etc, and always with a little practical application you can use right away.

Elisp: Text Processing Example: HTML Markup Elisp Function Words

Review of ErgoEmacs by Joseph Buchignani

Joseph Buchignani wrote a review of ErgoEmacs, at: Source www.cyborganize.org. Check it out!

Besides some praises, he also listed several items he believed to be bad. He made many excellent points. Some of his points are due to him being a experienced emacs user, but some are still good points. I think we will follow up about half of his points in next release. Here's a list that is now fixed:

For org-mode, the only customization in ErgoEmacs is (add-hook 'org-mode-hook 'soft-wrap-lines). What the soft-wrap-lines function do is to set “truncate-lines” to false and “word-wrap” to true. Otherwise, long lines will disappear into the right window border. Am not sure this is a good thing. Has newer org-mode changed this behavior?

Also, emacs 24 beta is out, and people are saying it's pretty stable. So, next release will probably be based on emacs 24.

Thanks to Joseph. Check out his review linked above.

Updated a function toggle-line-spacing for emacs 24, at How to Set Emacs's User Interface. Thanks to Ivan Kozik for the tip.

Emacs: Updates: insert-random-uuid, forward-close-bracket

Last week, we discussed how to write a elisp to generat UUID. Christopher Wellons provided a excellent implementation involving random info from emacs, then Alt+x md5. See bottom at: Emacs Lisp Exercise: insert-random-uuid.

For those of you using ergoemacs-backward-close-bracket and ergoemacs-forward-close-bracket, there's a bug that's been fixed. The bug is this: it misses some brackets because there's some typo in the regex in the code, it contained extra space. Get updated code at: Emacs: Move Cursor to Bracket/Quote.

Emacs: Inconsistency of Search Features

Emacs: Change to Title Case

Emacs: Enter Unicode by Decimal

Added to Emacs: Unicode Tutorial.

Emacs Lisp Example: mark-unicode

Often, when coding HTML, i need to mark a character as Unicode, using a custom HTML tag with special CSS markup, like this:

<b class="u">∑</b>

The <b>bold</b> tag is used to markup a text to stand out, with no particular semantic meaning (as opposed to <strong>strong</strong> or <em>emphasis</em>. [see HTML5 Tags]). The class “u” just indicate its Unicode. This way, i can write a JavaScript so that when mouse hovers on the symbol, it'll show the Unicode number and also a large glyph of the char.

I have several elisp commands that wraps HTML tags in various ways, but i need to do this so often that i decided to write a dedicated command just for this. Here it is:

(defun mark-unicode (p1)
  "Wrap 「<b class=\"u\"></span>」 around current character.

When called in elisp program, wrap the tag at point P1."
  (interactive (list (point)))
    (goto-char p1)
    (insert "<b class=\"u\">")
    (forward-char 1)
    (insert "</b>"))

All my easy keys are used up, so i give it a alias of “u”. [see Emacs: Use Alias for Fast M-x]

1990s Web, Emacs W3 Browser, XEmacs, Nostalgia

Discovered a old W3C doc that proposes some HTML Entities to represent some commonly used icon-like symbols. What's interesting is that, one of the contributor listed: William M Perry, is the guy who wrote the “w3” web browser in emacs lisp. (See: www.emacswiki.org w3.) It's not just a text browser like lynx and many others. “w3” supports images, HTML table, and, and CSS too. Back in the 1990s, it's a big deal. It is bundled with XEmacs. I actually used it during 1999. If i recall correctly, JavaScript support was planned but never implemented.

The w3 browser was declared abandoned around ~2006. Rather expected. Today's browsers are too complex to be implemented purely with emacs lisp.

Also of interest is that, in the file, you see some history of the web. Many of the icons proposed, are widely used in late 1990s. You see such things as telnet, gopher, ftp, uuencode, TeX DVI, “under construction” sign. See: Unicode: W3C Proposed Icons {Image, Video, Sound File, Trash, Keyboard, Mouse, …}.

Updated: Emacs: Letter-Case Commands Usability Problems.

Poll: Behavior of Home/End Keys

Poll: do you prefer the Home/End keys to:


Emacs: Search Text in Files

GNU Emacs Bug: rgrep, “find: invalid predicate `-nam'”

Added to Emacs Misc Bugs, bottom.

Updated: Elisp: Multi-Pair String Replacement Function.

proper elbow position during typing
Proper Elbow Position During Typing

Emacs Package: xah-lookup.el

A new package xah-lookup.el for lookup in {google search, dictionary, Wikipedia}. See the download link at: Emacs: Lookup Google, Dictionary, Documentation.

Emacs: ParEdit, Smartparens, Lispy, and ErgoEmacs, xah-fly-keys

Two weeks ago, i had a lisp exercise of writing “extract-url”. Here is a solution: Elisp: Command to Extract URL.

Updated 2 neglected but very useful articles:

Solution to last week's elisp exercise: Emacs Lisp Exercise: insert-random-uuid.

Updated with new examples: Emacs: Keyboard Macro.

New major version of math symbol input mode is out, at v1.3.3.

Feature additions:

Buy it at: Emacs: Xah Math Input Mode.

Emacs Lisp Exercise: insert-random-uuid

Emacs Lisp Programing: Beware of Region Boundary Change

Unicode Characters for Space

See: http://xahlee.blogspot.com/2011/11/unicode-character-for-space.html

Solution to the problem last week: Emacs: Align Text.