Showing posts from July 1, 2012

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 ( after you do it once.Fork the MELPA repository on GitHubCreate a new file in the “recipes” directory with the right format. It's really easy — just take a look at an example recipe ( it with the ./buildpkg script and do M-x package-install-fileOn GitHub, visit your fork and click the Pull Request buttonThat's pretty much it. Marmalade is a lit…

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's sample code am currently reading. (defunkill-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-inclu…

Emacs Key Macro and Elisp Exercise: Reformat XML

2012-07-02, Mihamina Rakotomandimby posted a interesting problem (Source 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 indent, just select all then call indent-region 【Ctrl+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 ₁)

Emacs bug: Inserting French Quotation Mark

Perm URL with updates: to reproduce:Start emacs by: emacs -Q.Evaluate this: (global-set-key (kbd "<kp-8>") "«").Now, press the 8 on numerical keypad.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

Queen - Bohemian Rhapsody

«Galaxy Nexus and Google+ Hangouts: Bohemians»Cute girls. Cute.Now, the real version. A fantastic song. Fantasmagorical.“Queen - Bohemian Rhapsody” amazonBut, half of the charm lies in the lyrics. see: song is written and sung by Freddie Mercury. he died of AIDS, in 1991 (age 45).A Whiter Shade of PaleMoody Blues - Nights in White SatinDavid Bowie - Life on MarsSupertramp (Roger Hodgson) - the Logical SongJefferson Airplane - White RabbitMurray Head - One Night in BangkokChoi Sung-Bong - Nella Fantasia

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) 2012-04-22 in GNU Emacs, 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.(info "(elisp) Window System Selections")X Selections, Cut Buffers, and Kill Rings ≈2002-01-01 By Jamie Zawinski . @ Source www.jwz.orgX Window selectionPerm URL with updates: