2012-11-22

spammer post spam to deceased blogs

when you stop using blogger for a few months, flurry of spammers goes to your blog and post spam.

2012-07-17

Xah at Blogger is Desisting!

I'll be stop publishing on this blogger at http://xahlee.blogspot.com/.

To read my blogs of different subjects, please subscribe at Xah Lee Feeds

This blog won't be closed. All articles stay. I might post once or twice in a year. Especially in emergency situation such as if my sites are down, or testing some blogger widget features (such as poll.)

Thank you all for reading, comments, and support!

Complaints? Gripes? Comment below to me know. If enough of you want a blogger mirror, you might change my mind.

2012-07-13

Why I Hate C

Perm URL with updates: http://xahlee.info/comp/why_i_hate_C_lang.html

I despise C the language, not because of particular technical aspect, or lacking some functionality such as lacking {automatical memory management, module system, namespace, list/hashtable datatype, complex number datatype, regex, function closure, function as value, OOP support, functional programing support, …}, none of that, but on certain sloppiness that's in the bones of C. (pretty much like unix (they bootstrap each other (it's scam booting scam)))

Perhaps the best simple example to illustrate, is its invention of the format function printf. Completely ad hoc, inflexible, cryptic syntax and semantics. When i first learned it (thru Perl. (C/Unix has a knack like virus. Now it's in about every lang.)), i went WTF is this? (i came from Mathematica). The printf can print hex, but with fixed representation of the digits, and can't do arbitrary n-based number system. It can print decimal in several formats, but in a bunch of ad hoc fixed ways. And did i mention cryptic syntax? The syntax and semantics isn't extensible in any general way.

There it is, the C language! In C, just about anything it does, it's done in a {ad hoc, fixed, inflexible, non-extensible, cryptic} way, and with a PRETENSE that it is done for speed and efficiency. Note the word “PRETENSE” here. That's important. I don't dislike C because it's a low-level, system language, designed for speed, but because there's a strong HACK element in its blood.

(to this day, due to C's spread of printf, many programers don't really understand what's n-based number system, they just recognize {binary, oct, hex} when they see a string of 0123456789abcdef. And if you show them hex number system using decimal digits in a list, they would be wildly flabbergasted and goes “WHY would you ever want do that??”. To this day, the hex with 0…9a…f have so ingrained in every computing spec. In particular, RGB color e.g. #c2c2c2. (the RGB color spec, is a entire story of complete ad hoc f��� by itself (e.g. ad hoc range of 0 to 255, just because it is convenient at the time!). (not sure who started it, probably unix X11 first popularized it.)))

• Extensive ad hoc syntax. So, we need to increment a counter often. Instead of working on a better compiler, let's invent a short syntax on the spot! Thus was born these abomination: {i++, ++i, i--, --i, =+, …}. And witness the syntax soup: {i++, ++i, for(;;){}, while(){}, 0x123, expr1 ? expr2 : expr3, sprint(…%s…,…), …}. These are ad hoc, cryptic, inflexible, non-extensible, syntaxes — the nature of C. (➲ The Concepts and Confusions of Prefix, Infix, Postfix and Fully Nested Notations)

• the use of bitmask as boolean parameters. (to this day, there are programers who don't understand the difference between a set of true/false formal parameters vs their internal representation, and insists that bitmask is the most efficient way to “encode” boolean parameters. Encode? Encode their ass. (this again, spread like virus. You see it in perl/python regex flags. Did i mention cryptic?)) (➲ Programing Language Design: the Hack of Bitmask Used as Boolean Parameters)

• the include as a lib system. No namespace. Granted, in the 1970s, computing resources are meager. Many of C's issues we can't really blame C. But, the key point i want to emphasize is, that everything in C is done is a sloppy no-design way without any apology. If pressed, the C types delight in the ad hoc cryptic nature as hackery. It “give them freedom”, it “allow them to shoot their own foot”, it “is for real programers”, …, they chant. (much inherited by Perl) So, C's include has gone into Perl, and from Perl to PHP. (luckly, include fell off starting with Perl in the late 1990s. Most langs now have a namespace/module system.)

• cryptic error code. This have been transfused into the veins of unix. You have to check the exit code, then you need to decode the error code. And here we onto the related bitmask f��� as in unix.

C and unix are such a sloppy, spineless tech that they act like a virus. (this point has been well exposited by lisper Richard P Gabriel's 〈The Rise of “Worse is Better”〉.) C spawned csh, C++, Perl, Java, Pretty Home Page (aka PHP) (and the entire C-like syntax langs), C#, Go Lang. They ride on sloppiness and speed which masquerade as portability and distributed like drugs. The whole C Unix things spread like drugs, in particular: unix, perl, Apache, MySQL. Their slogan is often “MOST Popular in Industry!”. And as a consequence, usually “Industry STANDARD”! O, and there is one thing that always accompany these: $FREE$! (as in, free drugs!)

So, C++ is better? if you think C++ fixed C, then this whole essay has been written in vain. C++ is far worse. (in the context of this essay, Java can be considered as a improvement of C.)

Curiosity: Perl File Extension in Emacs Config

A curiosity question.

emacs's “auto-mode-alist” has this value:

("\\.\\([pP]\\([Llm]\\|erl\\|od\\)\\|al\\)\\'" . perl-mode)

the regex there seems a bit wild. If i didn't get it wrong, then its like this

. ([pP] ( [Llm] | erl | od ) | al )

so it covers:

.pl
.perl
.pod
.pm
.al

plus SOME case variations. e.g. {.pL , .PL}.

what's the “.al” for?

is it necessary to include the “.pod”? because the perl-mode doesn't do any coloring with “.pod” files, nor cperl-mode. If there's a mode handing “.pod” file am guessing it won't be perl-mode.

also, is the “.perl” there necessary? Is that a accepted perl file suffix? (Just checked it's not in any file bundled with perl v5.10.1.)

would it be better if it's just

("\\.\\(p\\([lm]\\)\\)\\'" . perl-mode)

?

Tonight I'm Frakking You

Perm URL with updates: http://xahlee.org/funny/tonight_im_frakking_you.html

Tonight I'm Frakking You

2012-07-12

emacs lisp: getting current buffer path

In your elisp program, you may call (buffer-file-name) to get the full path of the file, but sometimes the current buffer isn't associated with a file, so your program will fail.

Here's a idiom: (or (buffer-file-name) default-directory). This way, if the buffer isn't a file, it'll return the directory path of the buffer. (when a buffer is created, its “default-directory” is typically the same as previous buffer. In the case of temp buffers created by emacs such as {*info*, *scratch*, *Bookmark List*, …}, it's usually home dir.)

I just searched all my elisp files for this oversight.

BMW's Sexual Ad

post removed because it might violate Google's ad program policy. See here instead: 〈Xah's Sex Blog〉 http://xahlee.org/sex/blog.html

Gauss's construction of the 17-gon

Gauss's construction of the 17-gon (Heptadecagon). He probably didn't actually draw it, only proved possible.

Gauss construction 17-gon
Gauss construction 17-gon (unverified)

More info on Wikipedia Constructible polygon

2012-07-11

Emacs Lisp: Ways to Exit/Break a Loop

Perm URL with updates: http://ergoemacs.org/emacs/elisp_break_loop.html

In many languages, there's “break” or “exit” keywords that you can use to exit a loop. In functional programing, usually you don't do loops or exit loops, but sometimes that's just what you need.

In elisp, to exit loop, you can either use a flag (i.e. set a variable to indicate whether to exit.), or use the built-in catch and throw.

Using a Flag

Here's a pseudo-code for using a flag:

(while (and (not found) (< i listLength))
 …
 ; if found, set found

 (setq i (1+ i))
)

Here's a actual example using a flag:

(defun get-new-fpath (ξfPath moveFromToList)
  "Return a new file full path for ξfPath.
moveFromToList is a alist."
  (let ((ξfoundResult nil) (ξi 0) (ξlen (length moveFromToList)) )
    ;; compare to each moved dir.
    (while (and (not ξfoundResult) (< ξi ξlen))
      (when (string-match (concat "\\`" (regexp-quote (car (elt moveFromToList ξi))) ) ξfPath )
        (let (
              (fromDir (car (elt moveFromToList ξi)))
              (toDir (cdr (elt moveFromToList ξi)))
              )
          (setq ξfoundResult (concat toDir (substract-path ξfPath fromDir)) )
          )
        )
      (setq ξi (1+ ξi) )
      )
    (if ξfoundResult ξfoundResult ξfPath )
    )
  )

Using throw and catch

Here's a pseudo-code of throw and catch.

(catch TAG
  (mapc
   (lambda (x)
     …
     (if …
       (progn (throw TAG VALUE) )
       (progn …)
     )
    )
   ‹list›
  )
 ‹value of catch if throw didn't occur›
)

Here's a example using throw and catch.

(defun xahsite-url-is-xah-website-p (myURL)
  "Returns t if MYURL contains a xah domain name, else nil.

See: `xahsite-domain-names'."
  (catch 'myloop
    (mapc (lambda (x)
            (when (string-match-p (format "\\`http://\\(www\\.\\)*%s\.*/*" (regexp-quote x)) myURL)
              (throw 'myloop t)))
          (xahsite-domain-names))
    nil
    )
  )

(info "(elisp) Catch and Throw")

JavaScript: Exclamation Before function

I come across JavaScript code like this today:

!function(d,s,id){…}(…);

What does that !function mean?

Turns out, it is equivalent to this:

(function(d,s,id){…})(…);

The exclamation makes the function a expression. (it's the boolean “not” operator.) People do this hack to save one character worth of source code file size. Silly.

2012-07-10

List of Keyboards with Mechanical Switch

Perm URL with updates: http://xahlee.info/kbd/keyboards_with_mechanical_switch.html

Here's a quick list of keyboards with mechanical switches. They typically start at $70. Ergonomic ones with fancy shapes usually starts at $200. (If you don't know what Cherry MX means, first see: Guide to Computer Keyboard Key Switch Mechanisms.)

Note: Microsoft or Logitech keyboards do not use mechanical switches, even expensive ones.

Ergonomic

Truly Ergonomic Keyboard (Cherry MX Brown)

The μTRON Keyboard (hard to buy in USA)

Kinesis Contoured Keyboard (Cherry MX Brown)

Maltron Keyboard

Datadesk Tech Smartboard Keyboard. (may be hard to buy) Picture at Ergonomic Keyboards Gallery

Standard

Corsair K60, K90 (Cherry MX Red)

Filco Majestouch. Produces many different models, with or without numberical keypad, and also with many switch type: Brown, Black, Blue, or Red. Be sure to read model's spec in detail. (104 keys: amazon) (See: Keyboards Without Numberic Keypad.)

Razer BlackWidow. (Cherry MX Blue) amazon

Cooler Master keyboard. (See: Keyboards Without Numberic Keypad.)

Azio Levetron Mech4 Gaming Keyboard. (See: Keyboards Without Numberic Keypad.)

Das keyboard. Some model are not mechanical. Be sure to check spec. (➲ review here)

Ducky keyboard (may be hard to buy in USA) (➲ KBC Poker Keyboard, Ducky Keyboard)

KBC Poker keyboard (may be hard to buy in USA) (➲ KBC Poker Keyboard, Ducky Keyboard)

Unicomp IBM Model M (➲ review here)

Happy Hacking Keyboard (professional model only) (➲ The Idiocy of the Happy Hacking Keyboard)

SteelSeries 6Gv2 keyboard. (Cherry MX Black) amazon

Matias Tactile Pro 3.0. Switch Type: White Alps Strongman. http://matias.ca/tactilepro3/index.php

• Adesso Full Size Mechanical Gaming Keyboard with USB Hub and Audio Jack - USB and PS/2 (MKB-135B) Adesso MKB-135B Pro. Switch Type: Cherry MX Blue. amazon

Cherry SmartBoard G83-6744 Keyboard - wired - Black - English - US http://www.cherrycorp.com/english/keyboards/Office/G80_3000_MX/index.htm amazon

2012-07-09

Wordy English: A Etymology Rhapsody on Spiracle

New Wordy English article: 〈A Etymology Rhapsody on Spiracle〉: spiracle, fan, allophone, camouflage @ http://wordy-english.blogspot.com/2012/07/etymology-rhapsody-on-spiracle.html.

Be sure to subscribe Wordy English for literature/writing/vocabulary related articles.

Emacs: Ways to Jump to Points

when coding, there's a common need to jump to a particular place, then return to previous position.

There are several ways. Most common standard way are:

  • exchange-point-and-markCtrl+x Ctrl+x】.
  • Ctrl+u Ctrl+Space

I've tried all ways in past years, including custom elisp that push marks. But i found split windows to be the best.

e.g. split window. Go to where you wanna be. When done, unsplit. Give split/unsplit a easy key. (➲ Emacs: How to Define Keyboard Shortcuts) e.g. In ErgoEmacs, it's:

  • Alt+3delete-other-windows
  • Alt+4split-window-vertically
  • Alt+0delete-window
  • Alt+sother-window

On a different note, here's a nice tip when using mouse (thx to Ken Goldman):

  • Middle mouse button on a status bar expands current pane.
  • Right mouse button on a status bar closes current pane.

2012-07-06

Emacs Lisp: Adding Your Package to MELPA

Emacs 24's package system is hot. It spreads a few hundred packages to every emacs user. (In GNU emacs, 41 packages (not counting built-in ones). With MELPA, 307 packages.) Before this, it takes years of emacs experience to know what packages are out there that are actually usable.

So, if you have written a package, putting it into a package repository would greatly increase your user base. I haven't done it yet myself, but here's a tutorial from Jon-Michael Deldin.

MELPA is pretty easy (https://github.com/milkypostman/melpa#contributing-new-packages) after you do it once.

  1. Fork the MELPA repository on GitHub
  2. Create a new file in the “recipes” directory with the right format. It's really easy — just take a look at an example recipe (https://github.com/milkypostman/melpa/blob/master/recipes/ir-black-theme).
  3. Test it with the ./buildpkg script and do M-x package-install-file
  4. On GitHub, visit your fork and click the Pull Request button

That's pretty much it. Marmalade is a little easier (just upload a tar or .el), but you have to upload a new version for each release.

2012-07-05

Lisp Syntax Readable?

lisp syntax is really unreadable. 10 years ago, i thought it's more of a joke for those uninitiated. But then surely the basic fact of uniformity is a problem for reading (because in nature, things are not uniform). But now having coded lisp for ≈5 years, i do find it comparatively unreadable.

here's sample code am currently reading.

(defun kill-new (string &optional replace yank-handler)
  "Make STRING the latest kill in the kill ring.
…"
  (if (> (length string) 0)
      (if yank-handler
          (put-text-property 0 (length string)
                             'yank-handler yank-handler string))
    (if yank-handler
        (signal 'args-out-of-range
                (list string "yank-handler specified for empty string"))))
  (unless (and kill-do-not-save-duplicates
               ;; Due to text properties such as 'yank-handler that
               ;; can alter the contents to yank, comparison using
               ;; `equal' is unsafe.
               (equal-including-properties string (car kill-ring)))
    (if (fboundp 'menu-bar-update-yank-menu)
        (menu-bar-update-yank-menu string (and replace (car kill-ring)))))
  (when save-interprogram-paste-before-kill
    (let ((interprogram-paste (and interprogram-paste-function
                                   (funcall interprogram-paste-function))))
      (when interprogram-paste
        (dolist (s (if (listp interprogram-paste)
                       (nreverse interprogram-paste)
                     (list interprogram-paste)))
          (unless (and kill-do-not-save-duplicates
                       (equal-including-properties s (car kill-ring)))
            (push s kill-ring))))))
  (unless (and kill-do-not-save-duplicates
               (equal-including-properties string (car kill-ring)))
    (if (and replace kill-ring)
        (setcar kill-ring string)
      (push string kill-ring)
      (if (> (length kill-ring) kill-ring-max)
          (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil))))
  (setq kill-ring-yank-pointer kill-ring)
  (if interprogram-cut-function
      (funcall interprogram-cut-function string)))

Even though i hate Perl, but when perl script is well-coded, it's still more readable than lisp.

See also: The Concepts and Confusions of Prefix, Infix, Postfix and Fully Nested Notations.

2012-07-04

Emacs Key Macro and Elisp Exercise: Reformat XML

2012-07-02, Mihamina Rakotomandimby posted a interesting problem (Source groups.google.com):

I got a big one line XML file. I want to break the lines to make it more readable.

Replacing "><" with "C-j" then indenting is the most obvious solution, but would you know a more elegant solution?

This is a good exercise for emacs a keyboard macro. Record a key macro, save it, assign it a key. So, just press one key, and the file is indented and well-formatted.

to indent, just select all then call indent-regionCtrl+Alt+\】.

For key macro tutorial, see: Emacs: Using Keyboard Macro to Record/Playback Keystrokes.

or, if you are a emacs expert but never done any elisp, this is a great exercise. Write a command that does this. It's about 5 lines of elisp. (➲ Emacs Lisp Examples ₁)

2012-07-03

Emacs bug: Inserting French Quotation Mark

Perm URL with updates: http://ergoemacs.org/emacs/emacs_bugs.html

Steps to reproduce:

  1. Start emacs by: emacs -Q.
  2. Evaluate this: (global-set-key (kbd "<kp-8>") "«").
  3. Now, press the 8 on numerical keypad.
  4. Expected result: the french open quote is inserted. However, you get this error:
After 0 kbd macro iterations: Keyboard macro terminated by a command ringing the bell

Note that the following all work:

(global-set-key (kbd "<kp-8>") "「")
(global-set-key (kbd "<kp-8>") "『")
(global-set-key (kbd "<kp-8>") "〈")
(global-set-key (kbd "<kp-8>") "《")
(global-set-key (kbd "<kp-8>") "“")
(global-set-key (kbd "<kp-8>") "‘")
(global-set-key (kbd "<kp-8>") "‹")
(global-set-key (kbd "<kp-8>") "〔")

GNU Emacs 24.1.1 (i386-mingw-nt6.1.7601) of 2012-06-10 on MARVIN

2012-07-01

Queen - Bohemian Rhapsody

«Galaxy Nexus and Google+ Hangouts: Bohemians»

Cute girls. Cute.

Now, the real version. A fantastic song. Fantasmagorical.

“Queen - Bohemian Rhapsody” amazon

But, half of the charm lies in the lyrics. see: http://xahlee.org/music/Bohemian_Rhapsody.html

The song is written and sung by Freddie Mercury. he died of AIDS, in 1991 (age 45).

copy/paste in Linux X11 and emacs 24

In linux, if copy/paste doesn't work with other apps, you need to add this line:

(setq x-select-enable-clipboard t)

in GNU Emacs 24.0.93.1, that var is set to t now.

In X11 (Linux), there are basically 2 major copy/paste mechanisms: ① primary selection. ② clipboard. By convention, when you select a text using mouse, the text is automatically put into the primary selection, and middle click will paste it. The “X11's clipboard” is similar to the clipboard in Mac or Windows. You copy/paste by menu or keyboard. The primary selection and clipboard are independent.

Perm URL with updates: http://ergoemacs.org/emacs/emacs24_features.html

2012-06-30

Emacs Defect. file-relative-name fail on some MS Windows Styled Path

file-relative-name doesn't work on MS Windows style path when the drive letter is capitalized.

(file-relative-name "C:/Users/web/xyz.html" "C:/Users/web/") ; returns "C:/Users/web/xyz.html"
(file-relative-name "c:/Users/web/xyz.html" "c:/Users/web/") ; returns "xyz.html"
(file-relative-name "/Users/web/xyz.html" "/Users/web/") ; returns "xyz.html"

GNU Emacs 24.1.1 (i386-mingw-nt6.1.7601) of 2012-06-10 on MARVIN

Perm URL with updates: http://ergoemacs.org/emacs/emacs_bugs.html

2012-06-29

Emacs Commpand to Copy Rectangle to Clipboard

Here's a command to copy a column of text to clipboard.

(defun copy-rectangle-to-clipboard (p1 p2)
  "Copy region as column (rectangle) to operating system's clipboard.
This command will also put the text in register 0. (see: `copy-to-register')"
  (interactive "r")
  (let ((x-select-enable-clipboard t))
    (copy-rectangle-to-register ?0 p1 p2)
    (kill-new
     (with-temp-buffer
       (insert-register ?0)
       (buffer-string) )) ) )

See also: Emacs: Manipulate Column Text, string-rectangle, ASCII-Art

2012-06-25

Microsoft Classified FSF Donation site as Gambling

There's this piece of news going around:

How Microsoft Threat Management Gateway Classifies donate.fsf.org (self.gnu) By Rebbsitor. @ Source www.reddit.com

In summery, a Microsoft security site “Microsoft Reputation Services” classified Free Software Foundation's donation site 〔https://donate.fsf.org/〕 as in the “gambling” category. (but also {Technical Information, Shareware/Freeware})

This means, corporations using Microsoft's services will automatically block visiting such site. More about this is has been written by FSF:

  • Dear Microsoft: fsf.org is not a “gambling site” By Posted John Sullivan. @ Source www.fsf.org

I was curious about what Microsoft thought of my website.

my website xahlee.org is classified by Microsoft as {Pornography, Blogs/Wiki, Shareware/Freeware}. See: https://www.microsoft.com/security/portal/mrs/default.aspx. LOL. It appears, their service is quite off.

Here's a correction i submitted to their site:

hi, your service classified my site xahlee.org as Pornography, Blogs/Wiki, Shareware/Freeware. I think the porn and shareware/ware labels are quite inaccurate.

My site has 5 thousand pages. There are about maybe 10 pages that features explicit images of sex, and is accompanied by social commentary. There are about 20 pages featuring nudity or swimsuit, they are collections of a cultural phenomenon of wearing flags as underwear. And maybe 20 more pages about human sexuality. All in all, less that 100 page has anything to do with sex. Also, my site doesn't host any shareware/freeware. The rest 4 thousand nine hundred pages are about mathematics, computer programing, classical english literature, arts (gallery, some nudity), architecture (gallery), linguistics, as references, tutorials, or essays/blogs.

It's more correct to be: {Education/Reference, Blogs/Wiki, Nudity, Technical Information}.

Thanks for looking at this.

The complete list of their categories and definitions is: http://www.microsoft.com/security/portal/mrs/categories/MRS_Categories.en-us.htm (local mirror)

2012-06-18

emacs 24 feature: electric-pair-mode

Perm URL with updates: http://xahlee.org/emacs/emacs24_features.html

electric-pair-mode

new minor mode electric-pair-mode. When on, typing any left bracket automatically insert the right matching bracket. Brackets includes the ASCII ones: "double" 'single' () {} [], but also any unicode ones: «» ‹› “curly” ‘single’ 「」 『』 〈〉 《》 〔〕 【】…. (➲ Matching Brackets in Unicode)

Deleting one bracket doesn't delete the other. (If you want that, install autopairs package. (➲ A Guide on Emacs Package System))

Exactly which brackets are auto-closed depends on the current major mode's syntax table. (You can call describe-syntax to see current syntax table. (info "(elisp) Syntax Tables"))

If you always want certain brackets be inserted in pairs, you can customize the variable “electric-pair-pairs”. Its value should be a Association List (i.e. a list of cons pairs. (info "(elisp) Association Lists")).

For example, the curly bracket {} isn't auto-closed when in emacs-lisp-mode. But if you put the following in your emacs init:

;; setting for auto-close brackets for electric-pair-mode regardless of current major mode syntax table
(setq electric-pair-pairs '(
                            (?\" . ?\")
                            (?\{ . ?\})
                            ) )

Now, {} will always be auto-closed.

See also:

2012-06-17

Controversy of Common Lisp Package in Emacs Lisp

Perm URL with updates: http://xahlee.org/emacs/elisp_common_lisp_in_emacs.html

For you emacs lisp coders, there's controversy in using the cl package (require 'cl). This page is my introduction about the issue, with opinions from emacs developers.

First, here's what the official manual (info "(cl) Top") says about it:

   *Please note:* the "CL" functions are not standard parts of the
Emacs Lisp name space, so it is legitimate for users to define them
with other, conflicting meanings.  To avoid conflicting with those user
activities, we have a policy that packages installed in Emacs must not
load "CL" at run time.  (It is ok for them to load "CL" at compile time
only, with `eval-when-compile', and use the macros it provides.)  If
you are writing packages that you plan to distribute and invite
widespread use for, you might want to observe the same rule.

What that means is this: don't use (require 'cl) in your package. But if you want to use it, do it like this: (eval-when-compile (require 'cl)). This means, loading cl package is officially sanctioned by GNU only if your package is to be byte-compiled.

However, that doesn't seem to be the whole story. Eric Schulte (co-author of Org-babel) says:

http://lists.gnu.org/archive/html/emacs-devel/2012-02/msg00279.html

Eric Schulte wrote:

The above only applies to *macros* which are expanded at compile time. The expanded macros leave no reference to cl in the resulting compiled code. On the contrary cl functions (even in compiled code) when called at runtime still require cl to be loaded and available at runtime.

while discussing with a friend (Jon Snader) today, we broached on the controversy of CL package.

Common Lisp Compatibility Layer for Emacs Lisp?

The CL package is often thought of as a package that make emacs lisp compatible with Common Lisp. That is not exactly the case. Stefan Monnier (one of the two current emacs dev leader) explains:

http://lists.gnu.org/archive/html/emacs-devel/2012-02/msg00202.html

From: Stefan Monnier
Date: Mon, 06 Feb 2012 16:08:56 -0500

Elisp is not Common-Lisp. CL does try to provide some CL-style functionality, but indeed it has some rough edges in this regard. It is much better to look at it as a handy toolbox, whose design was inspired by the experience of Common-Lisp, than to look at it as a “Common-Lisp compatibility layer”.

The points you raise sound like bugs indeed. We welcome patches to fix them, but I personally won't spend much time tracking those bugs down, because my experience with this part of CL is that it's not always easy to dig into it (it's *very* lightly commented for one, and parts of it are fundamentally broken).

Why Some Emacs Lisp Programers Don't Like CL Package

the gnu emacs dev list i scan occasionally, and this hot topic was debated now and then.

there are strong supporters in both camps.

Summary of pro-CL:

  • Many major packages use it. Practically, there isn't any problem.
  • XEmacs has been using it without any problems.
  • It's practical. Just use it. This is better than every developer re-invent the wheel. Especially useful are sequence functions (e.g. checking member existence, deleting members, union, intersection, ….).

Summary of anti-CL:

  • Common Lisp the language is ugly.
  • CL package implementation has many issues (e.g. inefficiency, incorrect behavior)
  • CL package as it is encroaches elisp namespace. (in emacs 24.1, some of these are moved into “cl-*” namespace.)
  • Embracing CL package burdens documentation for elisp. (RMS)

the reason for CL package reservation does not seem to be definite. Some veterans have said that it's simply due to some gnu emacs dev don't like CL thru the ages. RMS being the major one. Stefan Monnier, one of the current emacs dev leader, also seem to be reserved about CL. (he's functional lang researcher academic)

Lars Ingebrigtsen (author of gnus newsgroup/email reader)

http://lists.gnu.org/archive/html/emacs-devel/2012-02/msg00297.html
From: Lars Ingebrigtsen
Subject: Re: CL package serious deficiencies
Date: Wed, 08 Feb 2012 23:28:03 +0100
│ I've never understood what's wrong with including cl.el, nor why the
│ byte-compiler should warn specially about it, any more than it warns
│ about any other package.

Since the beginning of time, the Emacs maintainer (whoever they were at the time) just hasn't liked Common Lisp. The stated rationale for not “allowing” cl.el usage has shifted around a lot over the years, though. (“It's too big run-time-wise”, “we're going to reimplement Emacs in Scheme”, and now “the manual will be too big” and “it uses the wrong prefix”.)

Meanwhile, most of the people who program Emacs Lisp daily (i.e., people like me) have always been in favour of including it. Who doesn't want `incf'? `plusp'? `delete-if-not'? `position'? So you get all these hundreds of reimplementations of all these necessary functions, only spread over all the different packages.

Stephen J. Turnbull (a XEmacs leader)

http://lists.gnu.org/archive/html/emacs-devel/2012-02/msg00259.html
From: Stephen J. Turnbull
Subject: Re: CL package serious deficiencies
Date: Wed, 08 Feb 2012 11:07:02 +0900
Nix writes:
 │ (FWIW, the *last* time I asked about this, many years ago, I was told
 │ that runtime use of cl was out of the question because it used too much
 │ memory. I presume that this argument is obsolete :) )

The feeling I get is that some senior Emacs developers simply rather dislike Common Lisp, think that the programming style it encourages sucks, and don't want to see it in code they work on frequently.

Ah, the sweet smell of “technical differences” in the design fog….

Real Reason for/against CL

From what i see, i guess the divide is basically like this:

For those who have done Common Lisp programing, clearly it should be included. But for Scheme fans, they don't want CL encroach elisp, rather prefer C implementation for really useful functions, or wait for the scheme implementation of elisp.

Pro CL Excerpts from Emacs Dev

http://lists.gnu.org/archive/html/emacs-devel/2012-02/msg00227.html

Nix wrote:

I've never understood what's wrong with including cl.el, nor why the byte-compiler should warn specially about it, any more than it warns about any other package. XEmacs has had cl.el in the dumped set for absolutely ages and it has caused zero problems as far as I know.

http://lists.gnu.org/archive/html/emacs-devel/2012-02/msg00337.html
From: John Wiegley
Date: Thu, 09 Feb 2012 15:09:47 -1000

Lars Ingebrigtsen writes:

│ Meanwhile, most of the people who program Emacs Lisp daily (i.e., people
│ like me) have always been in favour of including it.  Who doesn't want
│ `incf'?  `plusp'?  `delete-if-not'?  `position'?  So you get all these
│ hundreds of reimplementations of all these necessary functions, only spread
│ over all the different packages.

I completely agree, Lars. Eshell had to reimplement several functions that I knew were in cl.el, simply because of this restriction.

Some of the things in cl.el -- such as loop, defun*, and a few others -- I could care less about. These are more about coding in a CL style as opposed to the equivalent Elisp style. But other functions that concern basic algorithms, such as `reduce', I really would like to see dumped into Emacs core. *With* keywords (they make some usages very clear and easy to read).

I'm also one of those who has had cl.el required into my Emacs for over ten years now, and I've never once encountered a hiccup because of it. It's time has come!

Daniel Colascione wrote (http://lists.gnu.org/archive/html/emacs-devel/2012-02/msg00240.html):

The latest objection is that dumping CL would Emacs would increase the size of the printed and bound Emacs Lisp Reference Manual from the FSF. I find this objection unconvincing because it applies to _any_ new feature, and I don't think we're against adding new features to Emacs.

Anti CL Excerpts from Emacs Dev

http://lists.gnu.org/archive/html/emacs-devel/2012-06/msg00056.html
From: Richard Stallman
Subject: Re: Using cl in rst.el and elsewhere
Date: Sun, 03 Jun 2012 14:30:49 -0400
 │ We are already using CLOS (in the form of EIEIO), so the elisp lib cl.el
 │ really has been unfairly treated for such a long time because it was put
 │ into emacs too ahead of time and because of rms's dislike of CL (the
                                               ^^^^^^^^^^^^^^^^^^^
 │ language).

 Ah, I see. Indeed this whole things really smells a lot like a
 political decision like this.

That is erroneous as well as arrogant and nasty.

Some of my decisions about GNU Emacs are political -- derived from the political purpose of GNU Emacs and of GNU as a whole. If you think that is a bad thing, you may be in the wrong place.

However, my decision not to include the cl functions in the normal Emacs name space is simply technical. So is my decision not to make the CL definition of functions such as `member' the standard definitions in GNU Emacs.

My technical design decisions are based on my ideas of what is technically better or worse, as are everyone's technical design decisions.

http://lists.gnu.org/archive/html/emacs-devel/2012-02/msg00272.html

Richard Stallman wrote:

The point is that it would make the CL functions part of the standard Emacs namespace. That has two problems:

* CL is ugly. It is not well integrated with the rest of Emacs Lisp.

* We would have to document the CL functions in the manual, which is a big increase in the size. It is not that that is totally intolerable, it's that the benefit is not worth the burden.

Maybe we are miscommunicating. The ugliness I am talking about is in the specs of these functions, not the implementation. The specs of the CL functions don't fit in well with Emacs Lisp. This isn't something that could be fixed with more work on the code.

Alan Mackenzie (maintainer of cc-mode):

http://lists.gnu.org/archive/html/emacs-devel/2012-02/msg00241.html
From: Alan Mackenzie
Subject: Re: CL package serious deficiencies
Date: Tue, 7 Feb 2012 22:16:53 +0000

Hi, Daniel.

On Tue, Feb 07, 2012 at 01:34:06PM -0800, Daniel Colascione wrote:
│ On 2/7/12 1:23 PM, Nix wrote:
│ │ (FWIW, the *last* time I asked about this, many years ago, I was told
│ │ that runtime use of cl was out of the question because it used too much
│ │ memory. I presume that this argument is obsolete :) )

│ I've long been an advocate of dumping cl with Emacs; XEmacs does so
│ without problems.

The CC Mode test suite (in particular, 000tests.el, available from the CC Mode site at SourceForge), uses cl at run time. It's been getting wierd “can't happen” errors for years: some error starts appearing, repeatedly, then after some unrelated change in CC Mode, stops appearing. Then another wierd error starts happening, then stops. This has been going on for years. The current error, which has been happening for ~6 months, is:

    Testing awk-face-1.awk (fonts)  Buffer is read-only: #<buffer *cc-test*>

. This doesn't happen with XEmacs (though other errors do).

I believe that the cl files are somehow responsible; Barry Warsaw (who originally wrote 000tests.el) was and is a competent hacker.

│ CLisms simply result in cleaner, smaller code than one can write using
│ nothing but elisp primitives.

│ The latest objection is that dumping CL would Emacs would increase the
│ size of the printed and bound Emacs Lisp Reference Manual from the
│ FSF. I find this objection unconvincing because it applies to _any_ new
│ feature, and I don't think we're against adding new features to Emacs.

I'd recommend not changing the policy on CL until it acquires a rigorous test suite. I don't really trust it beyond use at byte-compile time.

quality hand toy for RSI, emacs users

discovered a quality hand toy

crazy aaron putty
Crazy Aaron Thinking Putty. amazon
〈Thinking Putty unboxing〉 amazon

more hand toys, bottom: http://xahlee.org/emacs/emacs_pinky.html

2012-06-15

编辑部的故事, 人工智能人

Perm URL with updates: http://xahlee.org/Periodic_dosage_dir/stories_from_the_editorial_board_smart_robot.html

A fantastic TV show from China: 〈Stories from the Editorial Board〉, 1991.

Here's a wonderful episode, titled 〈Smart Robot〉. (Chinese only. No English subtitle.)

编辑部的故事 EPISODE 22 PART 1
编辑部的故事 EPISODE 22 PART 2
编辑部的故事 EPISODE 22 PART 3
编辑部的故事 EPISODE 22 PART 4
编辑部的故事 EPISODE 22 PART 5

More info about this show can be found at http://baike.baidu.com/view/287556.htm and 编辑部的故事. Quote:

1991年上映的25集电视连续剧《编辑部的故事》,导演赵宝刚。该剧描写一个叫《人间指南》的杂志编辑部里,6个性格各异却都善解人意、乐于助人的编辑之间的交流与碰撞,描写他们与社会发生联系后产生的形形色色的人生故事。这是我国第一部电视系列喜剧,剧中的调侃、幽默、讽刺、戏谑,开电视系列片之先河,它的出现,拓展了我国电视剧的美学品格。

2012-06-13

Nation-state sponsored: Flame Malware

Wow, Flame (malware).

• Most advanced malware to date.

• Likely nation-state sponsored.

• Create fake but valid certificates.

• hijacks Microsoft update.

• User level program can't even see it.

• Can record audio, screenshots, keyboard activity and network traffic.[6] The program also records Skype conversations and can turn infected computers into Bluetooth beacons which attempt to download contact information from nearby Bluetooth-enabled devices.

• Remotely controlled. Including a command to self-destruct.

• Target seems to be Iran.

Who wrote it? We did! (suspects: one of {Israel, USA, China}.)

2012-06-12

Human Walking Speed, Power Walk, Racewalking

Perm URL with updates: http://xahlee.org/Periodic_dosage_dir/racewalking.html

Racewalking ≈ Sissy-walk

Russia's Olga Kaniskina won the women's 20-kilometer walk

Racewalking is different from power walk.

Power Walk is walking fast, with the criterion that at least one foot must be in contact with the ground. A very good exercise, alternative to jogging.

Racewalking has additional rule: when leg contact the ground, the knee must be straight. (i.e. you can't crouch walk like ninja)

so, i guess this developed this sissy-like hip swinging form. It's somewhat unnatural. Can't see how it became a olympic sport.

  • average human walking speed = 5 km/h ≈ 1.39 m/s.
  • average person walk very fast = 7 km/h to 9 km/h.
  • pro level racewalk 20km = 14 km/h.
2011 Australian Race Walk Champs, Canberra

2012-06-11

emacs 24: {beginning-of-defun, end-of-defun} in {C, C++} modes

Perm URL with updates: http://xahlee.org/emacs/emacs24_features.html

There's some changes on how the cursor moves when you call {beginning-of-defunCtrl+Alt+Home】, end-of-defunCtrl+Alt+End】} in {C,C++} modes in emacs.

Now, it move the cursor just one level up of a nested block. Before, it moves several levels up to actual function/class definition, out of several nested blocks of code if necessary.

Here's a sample C++ template code you can test on.

namespace my_namespace {

  void func1() {
  }

  void func2() {
  }
  
  class MyClass {
  public:
    MyClass() {
    }

    void method1() {
    }

    void method2() {
    }
  };

}

Here's a video showing the difference. (Thanks a lot to David Capello.)

〈C++ navigation in Emacs 23.4 vs Emacs 24.1〉, by David Capello

Emacs: to Mouse or Not to Mouse?

Bill Meahan, a veteran of emacs users and veteran programer back to 1960s, in a comment said he usually don't mouse in emacs. That is true for me too. Come to think of it, to be honest i do use mouse when i want to adjust the different window or frame sizes (I do this perhaps once a day). I think i also use mouse to scroll sometimes (probably hourly). Another instance where sometimes i use mouse is when browsing info doc for long session.

Emacs culture usually sticks to keyboard only. Though, i remember one time i was surprised reading on gnu.emacs.help where i think a experienced emacs user uses mouse for text selection. I think this might be more common before emacs 23 had move by visual line.

There's not much data about how average emacs users (who may never read emacs online forums) may or may not use mouse. So, i'd like to ask this to you all.

Do you use mouse in emacs? for what operation?

Comment at my blogger http://xahlee.blogspot.com/2012/06/emacs-to-mouse-or-not-to-mouse.html or at g+ or at twitter @ErgoEmacs.

Sci-fi, Orgasm Machine, Pure Pain Machine, and Human Suffering

Perm URL with updates: http://xahlee.org/Periodic_dosage_dir/human_suffering.html

There is a agent, in scifi, that causes orgasm, non-stop, at will, at girls you want. Wonderful. But am thinking, perhaps in a similar train, that there be a agent that causes pure pang for human suffering.

No, not pain. Pain, as in torture, is of course popular. Human animals is of no lack of imagination of causing extreme pain to other human animals. There are plenty pure pain machine in scifi. But am talking about a emotional pain, a pain for human suffering. Like, for example, when you are not in the mood and saw a girl being violently raped to death, or such. But if you have the feel of this, then imagine the general suffering of humanity. The poverty, the hunger, atrocities, little wanting, desires, the little kindness, gratitude, even a little innocent smile …

it seems am afflicted with such a neurotic disorder. So, am thinking, on scifi train, of such a pure agent that could cause this at will. So, perhaps, others can feel what i feel.

there are 2 historical figures i can identify who share my this idiosyncratic empathy. One is Bertrand Russell. The other is Franz Liszt.

Bertrand Russel is on record about this. See, first 20 seconds.

The Three Passions of Bertrand Russell

This is from his autobiography. amazon Quote:

Three passions, simple but overwhelmingly strong, have governed my life: the longing for love, the search for knowledge, and unbearable pity for the suffering of mankind. These passions, like great winds, have blown me hither and thither, in a wayward course, over a great ocean of anguish, reaching to the very verge of despair.

I have sought love, first, because it brings ecstasy - ecstasy so great that I would often have sacrificed all the rest of life for a few hours of this joy. I have sought it, next, because it relieves loneliness--that terrible loneliness in which one shivering consciousness looks over the rim of the world into the cold unfathomable lifeless abyss. I have sought it finally, because in the union of love I have seen, in a mystic miniature, the prefiguring vision of the heaven that saints and poets have imagined. This is what I sought, and though it might seem too good for human life, this is what--at last--I have found.

With equal passion I have sought knowledge. I have wished to understand the hearts of men. I have wished to know why the stars shine. And I have tried to apprehend the Pythagorean power by which number holds sway above the flux. A little of this, but not much, I have achieved.

Love and knowledge, so far as they were possible, led upward toward the heavens. But always pity brought me back to earth. Echoes of cries of pain reverberate in my heart. Children in famine, victims tortured by oppressors, helpless old people a burden to their sons, and the whole world of loneliness, poverty, and pain make a mockery of what human life should be. I long to alleviate this evil, but I cannot, and I too suffer.

This has been my life. I have found it worth living, and would gladly live it again if the chance were offered me.

I share with him EXACTLY these sentiments. These sentiments describes my life EXACTLY. The longing for love, the eager want of knowledge, and the pang of human suffering.

For about Franz Liszt, read Wikipedia about him, or hear 2 of his music here: Liszt & Bach, 4 Songs to Die For.

2012-06-10

emacs regex affair

spent good part of the past 2 days on this.

emacs regex affair
emacs regex affair

See also: Your Regex Brain.

Space Groups, Math and Chicks

got a chick from Moscow State University asking me about implementing Space group in Mathematica. Life's been worth living.

Anna, yes, you.

… haven't worked on this since 1998. I did 2D version. The 3D version would be much spectacular, especially with today's computing technologies (e.g. dynamic rotation in web browser). Also, going into higher dimension (e.g. 4th) would be a wonderful exercise in writing combinatorics programs or exploration into proof systems. Dimension 7 or higher hasn't been solved yet. Fame awaits!

emacs 24 is out

Emacs 24 is out. https://lists.gnu.org/archive/html/emacs-devel/2012-06/msg00164.html

See also: New Features in Emacs 24. I'll add a new item there every few days.

music: Bronski Beat - Smalltown Boy

Perm URL with updates: http://xahlee.org/music/smalltown_boy.html

Great song, lousy music video. Bronski Beat - Smalltown Boy, 1984.

Bronski Beat - Smalltown Boy. amazon
Title: Smalltown Boy
Music, Lyrics: James Somerville; Lawrence Cole; Steve Bronski

You leave in the morning with everything you own
In a little black case
Alone on a platform, the wind and the rain
On a sad and lonely face

Mother will never understand
Why you had to leave
For the answers you seek will never be found at home
The love that you need will never be found at home

Run away, turn away, run away, turn away, run away
Run away, turn away, run away, turn away, run away

Pushed around and kicked around, always a lonely boy
You were the one that they'd talk about around town
As they put you down

And as hard as they would try, they'd hurt to make you cry
But you'd never cry to them, just to your soul
No, you'd never cry to them, just to your soul

Run away, turn away, run away, turn away, run away
Run away, turn away, run away, turn away, run away
Run away, turn away, run away, turn away, run away
Run away, turn away, run away, turn away, run away

Cry boy, cry, cry boy, cry, cry boy
Cry boy, cry, cry boy, cry boy, cry, cry boy
Cry boy, cry, cry boy, cry boy, cry, cry boy
Cry boy, cry, cry boy, cry boy, cry

You leave in the morning with everything you own
In a little black case
Alone on a platform, the wind and the rain
On a sad and lonely face

Run away, turn away, run away, turn away, run away
Run away, turn away, run away, turn away, run away
Run away, turn away, run away, turn away, run away

This song is about gay boy. All members of the Bronski Beat band, are open gays. Quote from Wikipedia:

The song is a popular gay anthem and was a huge commercial success, reaching number 3 in the band's native UK. As well, it was a number one hit in Holland and Italy, and hit the top 10 in Australia, Canada, France, and Switzerland. The track reached number 48 in the U.S. pop chart and was a #1 U.S dance hit.

The song addresses key issues in 1980s homosexual culture. It addresses family rejection for being homosexual and homophobia in British society. It also deals with loneliness and bullying through societal and familial rejection.

I was listening to this song all day ≈1987, when i was ≈18. I never really paid attention to the lyrics. I didn't know what the song's about till now.

(No, am not gay. I was a pretty boy, and the gays, young and old, were all eyeing me. This is in Montreal, Canada. There were guys, inviting me to their houses, and tried to be initimate. Many instances involved physical touching, starting with hugging. Though, i was rather clueless at the time. One time, a guy deceived me as a agent interviewing me to be a male model. Who, had me naked and actually took out a tape to measure my penis size.)

In any case, this song is exceedingly attractive. The the falsetto, frenzy beat. Another song i listened all the time is 〈I Feel Love〉.

Bronski Beat, Marc Almond - I Feel Love

Bronski Beat, Marc Almond - I FEEL LOVE

2012-06-08

Random Math Notes: Friedrich Hirzebruch, Theorema Egregium, … (2012-06-06)

Perm URL with updates: http://xahlee.org/math/random_math_notes_2012-06-08.html

learned today from my friend Richard Palais that Friedrich Hirzebruch (1927 〜 2012) passed away last week.

Friedrich Ernst Peter Hirzebruch (17 October 1927 – 27 May 2012) was a German mathematician, working in the fields of topology, complex manifolds and algebraic geometry, and a leading figure in his generation. He has been described as “the most important mathematician in the Germany of the postwar period.”

Complex manifolds

In differential geometry, a complex manifold is a manifold with an atlas of charts to the open unit disk[1] in Cn, such that the transition maps are holomorphic.

The term complex manifold is variously used to mean a complex manifold in the sense above (which can be specified as an integrable complex manifold), and an almost complex manifold.

Holomorphic = Holomorphic function. Quote:

In mathematics, holomorphic functions are the central objects of study in complex analysis. A holomorphic function is a complex-valued function of one or more complex variables that is complex differentiable in a neighborhood of every point in its domain. The existence of a complex derivative is a very strong condition, for it implies that any holomorphic function is actually infinitely differentiable and equal to its own Taylor series.

The term analytic function is often used interchangeably with “holomorphic function”, although the word “analytic” is also used in a broader sense to describe any function (real, complex, or of more general type) that is equal to its Taylor series in a neighborhood of each point in its domain. The fact that the class of complex analytic functions coincides with the class of holomorphic functions is a major theorem in complex analysis.

Holomorphic functions are also sometimes referred to as regular functions[1] or as conformal maps. A holomorphic function whose domain is the whole complex plane is called an entire function. The phrase “holomorphic at a point z0” means not just differentiable at z0, but differentiable everywhere within some neighborhood of z0 in the complex plane.

Homeomorphism

In the mathematical field of topology, a homeomorphism or topological isomorphism or bicontinuous function is a continuous function between topological spaces that has a continuous inverse function. Homeomorphisms are the isomorphisms in the category of topological spaces—that is, they are the mappings that preserve all the topological properties of a given space. Two spaces with a homeomorphism between them are called homeomorphic, and from a topological viewpoint they are the same.

Two most beautiful awe-inspiring theorem i learned from Richard Palais are:

Gauss's Theorema Egregium (Latin: “Remarkable Theorem”) is a foundational result in differential geometry proved by Carl Friedrich Gauss that concerns the curvature of surfaces. The theorem says that the Gaussian curvature of a surface can be determined entirely by measuring angles, distances and their rates on the surface itself, without further reference to the particular way in which the surface is embedded in the ambient 3-dimensional Euclidean space. Thus the Gaussian curvature is an intrinsic invariant of a surface.

Started to write the above, didn't finish….

傷心酒店 (Heartbreak Bar)

Perm URL with updates: http://xahlee.org/music/heartbreak_bar.html

江蕙+施文彬 - 傷心酒店.
傷心酒店

作詞:羅文聰
作曲:吉幾三
Date: 1993

(女) 冷淡的光線, 哀怨的歌聲, 飲酒的人無心情
(女) 世間的繁華, 好像夢一場, 也是沒有用
(男) 暗淡酒店內, 悲傷誰人知, 痛苦吞腹內

△0
(女) 一杯又再來
(男) 妳若有了解
(合) 甭問我從那來

△1
(女) 不願講出來, 鬱悶在心裡, 感情失落的無奈
(女) 苦苦在等待, 還是等不到愛, 虛情的對待
(男) 多情的世界, 找不到真愛, 引我心悲哀

△2
(女) 有愛也罷
(男) 無愛也快活
(合) 今夜伴我是孤單

(合) 冷淡的光線, 哀怨的歌聲, 飲酒的人無心情
(合) 世間的繁華, 好像夢一場, 也是沒有用
(男) 暗淡酒店內, 悲傷誰人知, 痛苦吞腹內

△0

△1

△2

(男) 多情的世界, 找無真情愛, 引我心悲哀

△2
蔡幸娟+傅振輝 - 傷心酒店

Quick translation:

Heartbreak Bar

cold lights, sad music, this drinker has no mood
the beautiful world, a transient dream, useless
this dim lit bar, who can understand, i keep to myself

drink after drink
if you understand
don't ask me where i'm from

unable to to tell, the sadness in my heart, the feelings of heartbreak
waiting for a love, that never came, the uncaring treatment
this beautiful world, but no love for me, only the blues
皓皓 - 伤心酒店 (singing both male/female)

English Accents

Created a index page of all accent related videos, at: http://xahlee.org/lit/index_accents.html.

Here's a excerpt:

2012-06-06

Gmail State-Sponsored Attack Warning 2012-06-06

I'm getting a warning from Gmail.

gmail state-sponsored attack warning 2012-06-06
Gmail state-sponsored attack warning 2012-06-06

It started yesterday. I've since turned on Google's 2-steps verification, but the warning still come on today. It's pretty weird, since am in USA, and am not a China activist. Hardly know anyone in China except a few programers recently met on twitter.

Nice Text Column Commands in cua-mode

There's a nice feature of cua-mode. Turn it on, then 【Ctrl+Enter】 to start selecting rectangle. Then, you can start typing to insert text to the whole column, or press 【⌫ Backspace】 to delete to the left every char on the left boundary, or press 【⌦ Delete】 to delete the whole rectangle, or use any of {Cut, 【Ctrl+x】, Copy 【Ctrl+c】, Paste 【Ctrl+v】}. To cancel selection, press 【Ctrl+Enter】 again.

This is much better than emacs's rectangular commands (e.g. kill-rectangleCtrl+x r k】) because it visually highlight only the column selection, and no need for use specialized rectangle commands.

via +Markus Schütz

for more about working with column text, see: Emacs: Manipulate Column Text, string-rectangle, ASCII-Art

emacs url-unhex-string defect

Perm URL with updates: http://xahlee.org/emacs/emacs_bugs.html

The emacs functions {url-unhex-string, gnus-url-unhex-string} returns incorrect result. Example:

(require 'url-util)
;; emacs-24.1.50_2/lisp/url/url-util.el
(url-hexify-string "Gauss–Bonnet_theorem") ; returns "Gauss%E2%80%93Bonnet_theorem"

(url-unhex-string "Gauss%E2%80%93Bonnet_theorem")
;; returns "Gauss\342\200\223Bonnet_theorem"

(require 'gnus-util)
;; emacs-24.1.50_2/lisp/gnus/gnus-util.el
(gnus-url-unhex-string "Gauss%E2%80%93Bonnet_theorem")
;; returns "Gauss–Bonnet_theorem"

;; correct result should be: "Gauss–Bonnet_theorem"

Another issue is, why there's duplicate {url-unhex-string, gnus-url-unhex-string}?

Some discussion and temp solutions at:

Reported to FSF: bug#6252.

For browser's behavior, see: URL Percent Encoding and Unicode. For example of correct behavior in JavaScript, see: JavaScript Encode URL, Escape String.

math: Fractal Gears

fractal gears clockwork by zy0rg
“clockwork” (2012) by zy0rg. img src

2012-06-05

CSS 3 Selector not in CSS 2.1

Here's CSS 3 selector syntax that's not in CSS 2.1.

PatternMeaning
‹tag›[‹attr›^="‹val›"]Matches any ‹tag› element whose ‹attr› attribute value begins with the string "‹val›"
‹tag›[‹attr›$="‹val›"]Matches any ‹tag› element whose ‹attr› attribute value ends with the string "‹val›"
‹tag›[‹attr›*="‹val›"]Matches any ‹tag› element whose ‹attr› attribute value contains the string "‹val›"
PatternMeaning
‹tag›:rootMatches element ‹tag› that is root of document.
‹tag›:nth-child(‹n›)Matches element ‹tag› that is nth child of its parent.
‹tag›:nth-last-child(‹n›)Matches element ‹tag› that is nth child of its parent, counting from the last one.
‹tag›:nth-of-type(‹n›)Matches element ‹tag› that is nth child of the same type.
‹tag›:nth-last-of-type(‹n›)Same as ‹tag›:nth-of-type(‹n›) but counting from bottom.
‹tag›:last-childMatches element ‹tag› when ‹tag› is the last child of its parent.
‹tag›:first-of-typeSame as ‹tag›:nth-of-type(1)
‹tag›:last-of-typeSame as ‹tag›:first-of-type but the last.
‹tag›:only-childMatches element ‹tag› if it's the only child of its parent.
‹tag›:only-of-typeMatches element ‹tag› if its type is unique among siblings.
‹tag›:emptyMatches element ‹tag› that has no children (including text nodes)
‹tag›:targetMatches element ‹tag› that is the target of the referring URI.
‹tag›:enabled
‹tag›:disabled
a user interface element ‹tag› that is enabled or disabled
‹tag›:checked
‹tag›:disabled
a user interface element ‹tag› which is checked (for instance a radio-button or checkbox)
‹tag›:not(‹s›)Matches element ‹tag› if it's that does not match simple selector ‹s›.

http://www.w3.org/TR/selectors/

For complete list of CSS2.1 selectors, see http://xahlee.org/js/css_selector_syntax.html

2012-06-04

Emacs 24 Package System Problems

Perm URL with updates: http://xahlee.org/emacs/emacs_package_system_problem.html

This page describes some flaws with emacs 24's package system. If you are not familiar what it is, see: A Guide on Emacs 24 Package System.

does anyone have problems with emacs package system?

recently, installed several packages with it: {rainbow-mode, “bookmark+”, smex, “expand-region”}.

But they all have a similar problem related to autoload. For example, let's say rainbow-mode. When opening a CSS file, it's not loaded. You have to manually call it. So, if you want it to activate in CSS, you have to add stuff to your init file. Then, this means the package system does not really automatically manage things. You still have know some elisp, and manually add things to your init file. (we talking about basic activation, not advanced customization)

The issue is more pronounced with modes such as “bookmark+”, smex, “expand-region”. For example, after installing “bookmark+”, restart emacs, then i press 【Ctrl+x r l】 to open my bookmark, it gives a error call-interactively: Symbol's value as variable is void: bmkp-current-bookmark-file.

Apparently, the problem is that bookmark+ is not properly initialized. (when calling bookmark-bmenu-list, it does automatically load bookmark+, but isn't properly initialized) Here, i've spent some 20 min but haven't succeeded in making it work.

Similar problem with {smex, “expand-region”}. For example, smex requires you to define a key for M-x. So i added (global-set-key (kbd "<apps>") 'smex) in my init. But after starting emacs, i press the apps key, i get: “Symbol's function definition is void: smex”. If i put (require 'smex), restart, i get Debugger entered--Lisp error: (file-error "Cannot open load file" "smex"). Next step is to add the load path, which i haven't tried yet. But that seems to defeat half of goodness of package system.

Any insight on this? For emacs 24, is this the way things are?


Here's answer by José A. Romero L. https://groups.google.com/group/gnu.emacs.help/browse_frm/thread/0e83b11fb5c036a4#

Newsgroups: gnu.emacs.help
From: José A. Romero L. 
Date: Mon, 4 Jun 2012 01:58:03 -0700 (PDT)
Local: Mon, Jun 4 2012 4:58 am
Subject: Re: elpa package loading problem?

AFAIK, ELPA relies heavily on correctly declared autoload cookies, especially if you really want to avoid loading whole packages at startup. From my own experience adapting SC to ELPA I know this is not easy to get right from the beginning — you, as a user, may end needing to add the missing autoloads to the xxx-autoloads.el file automatically generated by ELPA (this sucks big time, because your added code is ditched away with every upgrade of the package). ELPA works wonderfully well, but only if the authors of the packages you happen to use did make that extra effort to get things right from the start.

«for emacs 24, is this the way things are?»

Yep, that's just the way it is. I'm afraid you'll have to submit a few bug reports before things start working properly for you.

BTW, for smex I've added this to my .emacs:

(defun jarl/smex ()
  (interactive)
  (condition-case description
      (progn
        (smex-initialize)
        (global-set-key (kbd "M-x") 'smex)
        (global-set-key (kbd "M-X") 'smex-major-mode-commands)
        (global-set-key (kbd "C-c C-c M-x") 'execute-extended-command)
        (smex))
    (error (execute-extended-command))))

(global-set-key (kbd "M-x") 'jarl/smex)

Solution

Here's example of code to put in your emacs init file to properly setup packages installed from ELPA. Still better than no ELPA.

(add-hook 'css-mode-hook 'rainbow-mode)
(add-to-list 'load-path "~/.emacs.d/elpa/bookmark+-20120516/")
(require 'bookmark+)
(add-to-list 'load-path "~/.emacs.d/elpa/smex-20120301/")
(require 'smex)
(smex-initialize)
(global-set-key (kbd "<apps>") 'smex)   ; make the Menu/Apps key do M-x on Windows. On linux, use (global-set-key (kbd "<menu>") 'smex)
(global-set-key (kbd "<S-apps>") 'smex-major-mode-commands)