Xah Emacs Blog Archive 2013-07 to 2013-07
Correction to previous post on Emacs: How to Set a Theme Depending on Mode?. As far as i know, there's no way to do this correctly, because background color is associated with emacs window (what emacs “frame”), not buffer.
(updated. Thanks to xfq for comment.)
recently, started to have discomfort in my left hand again (pre RSI symptom). For me, the onset of RSI symptom is feeling the need to strech the hand constantly. For example, bending the palm backward makes it feel very comfortable. For those of you programers, watch out.
so, am thinking of publishing a emacs book. How Much You'll Get for Writing a Programing Book?
emacs helpful coding/writing commands in a package xah-misc-commands.el
collected some 18 emacs lisp commands i've been using for years into a package. You can download it at https://code.google.com/p/ergoemacs/source/browse/packages/xah-misc-commands.el
most of them i've covered in my elisp tutorial. For example, look at Emacs Lisp Find Replace String-Pairs Commands
Nice blog by a friend, showing many rarely seen photos of famous emacs users. See: [• Famous Emacs Users (that are not famous for using Emacs) By 肉山博客 (Wenshan's Blog). At http://wenshanren.org/?p=418 , Accessed on 2013-07-23 ]
Don't like the numerical keypad on keyboard? Saw it off! Keyboard with Numeric Keypad Sawed Off
more credit of Julian Assange's emacs's work, see updated: Richard Stallman meets Julian Assange 2013
Truly Ergonomic Keyboard Review
Another TECK keyboard review, by a friend. [• Truly Ergonomic - full review By Toon Claes. At http://writepermission.com/2013/07/truly-ergonomic-full-review/ , Accessed on 2013-07-21 ]
You can read my review here. Truly Ergonomic Keyboard Review
写中英混合的时后，中英标点符号常混合在一起。这可帮解。Emacs: Convert Full-Width/Half-Width Punctuations
Emacs: Set Environment Variables within Emacs (slight update)
For keyboard geeks, here's a very geeky keyboard discussion. 〔http://www.reddit.com/r/emacs/comments/1i69i6/best_keyboard_post/ 〕 Thanks to MoreHugs for recommending my keyboard articles.
Keyboard article hit Hacker News. Thanks to “blacktulip”. https://news.ycombinator.com/item?id=6056420
ErgoEmacs-Mode New Home Page
ergoemacs-mode has a new home page. See: https://ergoemacs.github.io/. Check it out. Matt is leading the project in a truely open source spirit. Follow his lead.
ergoemacs-mode 新官方网址 https://ergoemacs.github.io/ 现由 Matthew L Fidler 领導。新气象。欢迎新用户。 #emacs#
History of Emacs and vi Keys (updated)
Now, you can mouse hover any emacs lisp function name, and a tooltip will show its doc string. Try it out on this page Emacs Lisp Basics by Example.
Julian Assange is also a emacs user. See this package he wrote. http://quimby.gnus.org/s/change-windows-intuitively.el 〔local copy change-windows-intuitively.el 〕
Richard Stallman meets Julian Assange
perm url: Richard Stallman meets Julian Assange (photo)
New version of emacs tutorial is out. Be a emacs lisp master in a month! Buy Xah Emacs Tutorial.
Emacs Tips for C/C++ Programers
I don't code C/C++, but Bin Chen has written a guide for C++ development. It's terse and for advanced emacs users. See: [• Emacs for C++ developers By Bin Chen (陈斌). At https://github.com/redguardtoo/mastering-emacs-in-one-year-guide/blob/master/emacs_cpp_developer_guide-en.org , Accessed on 2013-07-07 ]
Emacs Regex Advantages, Whitespace Syntax and Semantics Complexity in Computer Languages
Emacs Regex Advantages
emacs regex is usually a pain, but it has advantages.
today, i need to remove the linebreaks in texts like this:
<p>盖闻天地之数，有十二万九千六百岁为一元。将一元分为十二会，乃子、丑、 寅、卯、辰、巳、午、未、申、酉、戌、亥之十二支也。每会该一万八百岁。且 就一日而论：子时得阳气，而丑则鸡鸣；寅不通光，而卯则日出；辰时食后，而 巳则挨排；日午天中，而未则西蹉；申时晡而日落酉；戌黄昏而人定亥。</p>
Note: only if the newline is inside the “p” paragraph tag, and only when that text is Chinese, not English.
there are few hundred of such pages i need to do this.
Emacs regex has a nonascii character class. So, i can use this regex:
and replacement is this:
[see Emacs: Regex Tutorial]
I looked at Python, it doesn't have a named char class for Unicode. Though, am sure one can use a char range. Perl does support Unicode char class, same syntax as emacs, which is POSIX regex. Am not sure if it's added in recent years or existed around 2000.
Syntax, Whitespace, Programing Languages
Note that this is important, because otherwise browser will render a gap when there is a newline, and for Chinese text, it's very annoying. There is no way to use CSS to remove such gap.
And here we have a interesting issue. Namely, the semantic of whitespace among languages.
in HTML, it's quite complex. Newline char can be equivalent to space, and multiple spaces can be equivalent to single space, and newline char at beginning/ending of a tag has special meaning. See: Programing Language Design: Syntax Sugar Problem: Irregularity vs Convenience. Only some of these semantic complexity can be adjusted by CSS, but there's no systematic rule to know which can and which cannot, see: CSS Text Wrapping Tutorial.
In other languages such as Perl, Python, Ruby, it's also very complex. See: What Does it Means When a Programing Language Claims “Whitespace is Insignificant”?.
Should Programer Keep Lines to 70 Chars?
another interesting aspect this touches on is the habit of cutting lines at every 70 char or so.
as you can see, for Chinese language, doing that is unacceptable. Gaps in Chinese can affect meaning. Because, ancient Chinese started not having any punctuation, then later one gaps are used for punctuation. Today, gaps as the only punctuation is still used often, especially for verse or title.)
note that emacs usually have problems when the lines are very long. This is due to deeply ingrained implementation of unix habit of cutting lines.
Also, it's interesting that emacs's
fill-paragraph command behave correctly on this. That is, when the neighboring chars around newline are Chinese characters, emacs simply remove the newline, instead of replacing it with space.
So, this means, another approach to solve this problem is to programmatically call “unfill-paragraph”. [see Emacs: Hard Wrap Lines]
new version of 〔xah_file_util.el〕. It's basically grep and sed in elisp. If you are on Microsoft Windows and you don't have Cygwin installed, this is very handy. Download at http://code.google.com/p/ergoemacs/source/browse/packages/xah_file_util.el
lisp related, essay, semi-rant. Syntax, Formal Language, Pattern Matching
redesigned the website's nav bar. See top. Do you like the new look?
Might do some more CSS adjustments in following days to improve appearance. If you have any thoughts, let me know.
Emacs: M-x customize Tutorial (updated screenshot. thx to xfq)
Or Buy Xah Emacs Tutorial
Or buy a nice keyboard: Best Keyboard for Emacs
Ask me question on patreon