Posts

Showing posts from January 18, 2009

Language, Purity, Cult, and Deception

perm url: http://xahlee.org/UnixResource_dir/writ/lang_purity_cult_deception.htmlXah Lee, 2009-01-24[this essay is roughly a 10 years personal retrospect of some languages, in particular Scheme and Haskell.]I learned far more Ocaml in the past 2 days than the fucking 2 months i tried to learn Haskell, with 10 years of “I WANT TO BELIEVE” in haskell.The Haskell's problem is similar to Scheme lisp, being academic and of little industrial involvement. About 10 years ago, during the dot com era around 1999, where scripting war is going on (Perl, tcl, Applescript, Userland Frontier, with in the corner Python, Ruby, Icon, Scheme, in the air of Java, HTML 3, CSS, CGI, javascript), i was sold a lie by Scheme lisp. Scheme, has a aura of elegance and minimalism that's one hundred miles in radius. I have always been a advocate of functional programing, with a heart for formal methods. Scheme, being a academic lang, has such a association. At the time, Open Source and Linux have just arri…

dehtmlize source code in emacs lisp

perm url: http://xahlee.org/emacs/elisp_htmlize.htmladded elisp code to dehtmilze a block of htmlized source code.DeHtmlize Text2009-01-24 When a source code in a html file is htmlized, it is usually unreadible. Suppose you want to modify the source code presented in html. Usually, you view it in a browser, then copy the source code. Then create a new buffer, paste the code, to edit it. When done, you copy the newly edited text, close temp buffer, delete the htmilzed version in your html file, paste the new in, then htmlize it again. This process is painful.It would be nice, if you can press a button, then the htmlized source code in your html will become plain. So you can modify it. Press a button again to have it htmlized again.Here are 2 elisp code to dehtmlize. The dehtmilze-region will dehtmilze a selected region. The dehtmlize-block will dehtmlize code inside a pre block of the form “<pre class="langName">”. (defundehtmlize-block () "Delete span tags inside…

emacs command usage frequency

here's my own usage of emacs commands. From 2008-08-30 ta 2009-01-23. here's a list of the top 30 most used commands. 1119668 45.96% self-insert-command 203404 8.35% next-line 148571 6.10% previous-line 146318 6.01% forward-word 116557 4.78% backward-word 46370 1.90% delete-backward-char 44569 1.83% isearch-printing-char 41315 1.70% forward-char 36771 1.51% backward-char 36692 1.51% backward-kill-word 33890 1.39% newline 22912 0.94% save-buffer 22247 0.91% yank 18696 0.77% mwheel-scroll 18031 0.74% kill-line 16647 0.68% close-current-buffer 13485 0.55% move-beginning-of-line 13029 0.53% scroll-up 11420 0.47% isearch-forward 11380 0.47% isearch-other-meta-char 10840 0.44% kill-word 10363 0.43% set-mark-command 10349 0.42% isearch-repeat-forward 10256 0.42% find-file 10037 0.41% execute-extended-command 9328 0.38% move-cursor-ne…

Updating Atom/RSS with Elisp

Updating Atom/RSS with ElispXah Lee, 2009-01-21This page describes a real world example of using emacs to update a web syndication (RSS/Atom) page. If you don't know elisp, see: Emacs Lisp Basics.The ProblemSummaryI want to write a command, so that, when invoked, the current selected text will be added as a entry in a RSS/Atom file.This lesson will show you how write a command that grabs the region text, switch buffer, search string to locate position for inserting text, insert the text, and update date field in a file.DetailI run a website “xahlee.org”. The site is hosted by a website service provider. Typically, i create or edit my site on local disk. Then, i upload by switching to shell “Alt+a sh”, then type “trsync ”, it would automatically be expanded to:rsync -z -av --exclude="*~" --exclude=".DS_Store" --delete --rsh="ssh -l xyz" ~/web/ xyz@xahlee.org:~/This will update my website on the server.You can define your keyboard shortcut, alias, abbr…