Xah Emacs Blog Archive 2011-11
Updated: Emacs: Master Tips.
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 24.0.91.1 for Windows; Crash on linum-mode
Steps to reproduce:
- Download the emacs at Source alpha.gnu.org
- After install, cd to the “bin” dir, start it like this
./emacs.exe -Q
. - Type Alt+x linum-mode Enter. Emacs crashes.
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.
Emacs Init: Auto Insert Closing Bracket (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 xid) "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) ) (setq outputText (concat "<" (if (or (equal tagName nil) (string-equal tagName "")) "span" tagName) (if (or (equal xid nil) (string-equal xid "")) "" (concat " id=\"" xid "\"")) (if (or (equal className nil) (string-equal className "")) "" (concat " class=\"" className "\"")) ">" inputText "</" (if (or (equal tagName nil) (string-equal tagName "")) "span" tagName) ">" ) ) (delete-region p1 p2) (goto-char p1) (insert outputText) ) )
Remember to give it a key. see Emacs Keys: Define 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: 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: Xah HTML Mode Tutorial〕 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 Google Plus. 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 (http://www.panix.com/~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.
Emacs Lisp: Text Processing Example: HTML Markup Elisp Function Words
elisp_curly-quotes-to-emacs-function-tag.html
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:
math-symbol-input-mode(alias ofxmsi-mode) will be off by default. Also, a menu will be added to toggle it. 〔see Emacs: Xah Math Input Mode 📦〕- Dired recursive load problem will be fixed as he described.
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 Emacs Init: Intro.
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 [http://nullprogram.com/] provided a excellent implementation involving random info from emacs, then Alt+x md5
.
See bottom at: Emacs: 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 🚀.
Emacs: Inconsistency of Search Features
Emacs: Enter Unicode by Decimal
Added to Emacs: Insert Unicode Character.
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: Command Name Alias〕
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, etc}.
Updated: Emacs: Letter-Case Commands Usability Problems.
Poll: Behavior of Home/End Keys
Poll: do you prefer the Home/End keys to:
- Move to the beginning/end of the line. (Windows/Linux convention)
- Move to the beginning/end of the document. (Mac convention)
Results:
- [25 (65%)] Move to the beginning/end of the line.
- [13 (34%)] Move to the beginning/end of the document.
Emacs: Search Text in Directory
GNU Emacs Bug: rgrep, “find: invalid predicate `-nam'”
Added to Emacs Misc Bugs, 2008 to 2014, bottom.
Updated:
Emacs Package: xah-lookup.el
A new package xah-lookup.el
for lookup in {google search, dictionary, Wikipedia}. See the download link at: Emacs: Command to Search Web 🚀.
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: Emacs: HTML, Extract URL 🚀.
Updated 2 neglected but very useful articles:
Solution to last week's elisp exercise: Emacs: Insert Random UUID 🚀.
Updated with new examples: Emacs: Key Macro.
New major version of math symbol input mode is out, at v1.3.3.
Feature additions:
- Added support of input using Unicode names. e.g.
greek small letter alpha
. - Added support of input using decimal forms, for examples: {
955
,#955
} or hexadimal forms {x3bb
,#x3bb
}. XML entities forms such as {λ
,λ
,alpha
} are still supported. - Added about 5 more subscript symbols, for example, {ₐ ₑ ₕ ᵢ ⱼ ₖ ₗ ₘ ₙ ₒ ₚ ᵣ ₛ ₜ ᵤ ᵥ ₓ}. Their abbrev start with “_”.
- When no valid input are found, list of valid abbrevs shows in a separate pane.
Buy it at: Emacs: Xah Math Input Mode 📦.
Elisp: Beware of Region Boundary Change
Unicode Characters for Space
http://xahlee.blogspot.com/2011/11/unicode-character-for-space.html
Solution to the problem last week: Emacs: Align Text Column.