November 24, 2008
About book, that I've read
During weekend I finished reading of the "Beautiful Code" book - collection of essays from well-known (and not well-known) software developers, about what is a "beautiful code". I can say, that book is good, but not more, as there are many essays about solving simple (from my point of view) problems. From all essays, that I've read, I can recommend following:
- "Beautiful concurrency" by Simon Peyton Jones - about implementation of parallel programs in Haskell
- "Syntactic abstraction: the syntax-case expander" by R. Kent Dybvig - how macros in Scheme work
- "Enacspeak: the complete audio desktop" by T.V. Raman
- "Top Down Operator Precedence" by Douglas Crockford
- "Growing Beautiful Code in BioPerl" by Lincoln Stein
- "Another level of indirection"
- "Distributed programming with map/reducev by Jeffrey Dean & Sanjay Ghemawat
November 19, 2008
Updates to the article about Emacs & Git
I updated the article about Emacs & Git with description of the magit, git-emacs, and some auxiliary packages - gitsum, egit & git-blame.
The comments and additions are welcome
The comments and additions are welcome
November 12, 2008
Emacs + Git
I slowly migrate to magit and at the same time I'm trying to describe it in my article about Emacs & Git integration. Working with this package, i understood, that sometimes i switch to console, just to run some commands from git-svn. Than i decided to add missing functionality, and implement simple support of git-svn in magit. Repository with my changes could be found here.
I like Emacs for this - in many cases i can easily extend it's functionality without restarting it, or compiling and installing separate plugins
I like Emacs for this - in many cases i can easily extend it's functionality without restarting it, or compiling and installing separate plugins
November 3, 2008
Working with Growl from Emacs
For Mac OS X there is separate package Growl, that provides notification services for different programs. Notifications are represented as floating windows, containing text and icon. There notifications could be very useful for some things, like notifications from org-mode.
After some search, I found information how I can output notifications using AppleSript interface to Growl. To make this work, you need to perform two things — first you need to register your application and notifications types, produced by this application, and than you can send notifications to Growl.
To register application you will need following script, that declares notification types and register them, together with application in Growl:1
And after registration, user can send notifications with following script, that is a base of our Emacs's interface to Growl.
To interact with AppleScript from Emacs we'll could use
1. I need to mention, that long lines were split with
After some search, I found information how I can output notifications using AppleSript interface to Growl. To make this work, you need to perform two things — first you need to register your application and notifications types, produced by this application, and than you can send notifications to Growl.
To register application you will need following script, that declares notification types and register them, together with application in Growl:1
tell application "GrowlHelperApp"You can execute this script with
-- Declare a list of notification types
set the allNotificationsList to {"Emacs Notification"}
-- Declare list of active notifications. If some of them
-- isn't activated, user can do this later via preferences
set the enabledNotificationsList to {"Emacs Notification"}
-- Register our application in Growl.
register as application "Aquamacs Emacs" all notifications allNotificationsList \
default notifications enabledNotificationsList \
icon of application "Aquamacs Emacs"
end tell
osascript command from command line, or put it into Script Editor and execute it directly. After registration, user can customize look of the registered notification via Applications tab at preference pane of Growl.And after registration, user can send notifications with following script, that is a base of our Emacs's interface to Growl.
tell application "GrowlHelperApp"This script also could be executed via
notify with name "Emacs Notification" title "Emacs alert" \
description "Message!!!" application name "Aquamacs Emacs"
end tell
osascript, and it'll output message Message!!! with title Emacs alert, but to output non-Latin1 symbols from AppleScript, you'll need to encode them using UTF-16 and represent them as hexadecimal string, so we'll going to add special code, that will recode message strings to corresponding format.To interact with AppleScript from Emacs we'll could use
do-applescript function, but I found, that it doesn't properly handle multi-byte symbols « and », that are used to specify text in multi-byte encoding. So we'll form script in temporary file, and than execute it with osascript, and delete temporary file. This executed with following function:(defun output-to-growl (msg)To proper output of strings, containing Cyrillic & other non-Latin1 symbols, AppleScript requires, that data should be encoded in UTF-16, and presented as string
(let ((fname (make-temp-file "/tmp/growlXXXXXX")))
(with-temp-file fname
(setq coding-system-for-write 'utf-16)
(insert (format "tell application \"GrowlHelperApp\"
notify with name \"Emacs Notification\" title \"Emacs alert\" \
description «data utxt%s» as Unicode text \
application name \"Aquamacs Emacs\"
end tell" (osd-text-to-utf-16-hex msg))))
(shell-command (format "osascript %s" fname))
(delete-file fname)))
data utxtXXXXXX, where utxtXXXXXXX — hexadecimal representation of corresponding bytes of string in UTF-16 encoding. To do this task, I wrote function osd-text-to-utf-16-hex, that is called from output-to-growl function:(defun osd-text-to-utf-16-hex (text)And that's all. Now you can call
(let* ((utext (encode-coding-string text 'utf-16))
(ltext (string-to-list utext)))
(apply #'concat
(mapcar (lambda (x) (format "%02x" x)) ltext))))
output-to-growl from any place. I use it to get notifications from org-mode.1. I need to mention, that long lines were split with
\ just to get proper formatting on the screen. In script, you need to combine them into one long line!
Subscribe to:
Posts (Atom)