Saturday, September 27, 2008

MSN on Linux

Update (2008/11/20): Added the Pidgin music-tracker plugin to the comparison table.

I use Linux. Probably no surprise there. I also use IMs. However, I'm Hungarian, and currently in a community of more-or-less complete tech illiterate people. No offense meant: without them, there wouldn't be even a slight chance of getting a job in IT. Anyway, these friends of mine use *shudder* MSN - or Windows Live Messenger, as it likes being called lately. So, I needed an MSN client on Linux.

My criteria (in order of descending importance):
  • It must work
  • It must allow grouping contacts in the contact list
  • It must support tabbed chat windows
  • It should be reasonably fast
  • It should handle MSN Live! colored nicks (preferably color the nicks, optionally just remove the tags)
  • Showing music I'm listening to is nice.

The two main competitors are aMSN and Pidgin. Other clients of note are MSN Web Messenger, meebo (both web-based) and some clients using the same backend as Pidgin - see here.

aMSN

The aMSN project aims to build an MSN clone for Linux, and is making quite good progress. I've used it for quite a while, even hacked up an (80% functional) script to fetch current song info from Banshee 1. All in all it's a mature project. My main problems are temporary hangups and that it's generally slow. Also, written in TCL/TK, it doesn't integrate nicely with the desktop.

Pidgin

Pidgin is a modular, multi-protocol IM client. As such, it's main focus isn't MSN, but support for it is quite complete, especially from 2.5 on. There's a forked MSN protocol backend at Google Code called msn-pecan. I haven't tried it myself. My main issue here is that I can't find a way to set my personal message. A little plus is that it integrates nicely with Gnome (I don't know about KDE, I guess it must be OK if the deps are met).

Update 23/02/2009: To set the personal message, just select a status (like available). A text entry widget appears below the status selection combobox. That's where the personal message goes.

Side-by-side

aMSN Criteria Pidgin
Check Works Check
Check Group contacts Check
Check Tabbed chats Check
Sluggish Fast Check
With Colored Nicks plugin
Background color not supported
MSN Live! colored nicks With Pidgin Plus! plugin
Fails in some cases
Gradients not supported
With Music plugin Show current song Several plugins, music-tracker works fine for me.

All in all, I find the responsiveness of Pidgin more important than the feature-completeness of aMSN - and Pidgin's quickly gaining ground in this aspect as well. Also, Pidgin's written in C, which I'm way more familiar with than TCL/TK.
YMMV.

Tuesday, September 23, 2008

Emacs usecases 4 - Blogging 2

Previous in series: 3 - LaTeX

In this post I wrote about how to use Emacs for blogging. That's nice in itself, but there's some stuff needed when editing blog posts. Thus, blog.el:

;;;###autoload
(defun blog-init ()
  (interactive)
  (html-mode)
  (auto-fill-mode)
  (ispell-change-dictionary "american" t)
  (flyspell-mode)
)

Another improvement is adding the .blog file extension to the It's All Text Firefox extension. Last thing is associating it with our little init function. This took some googling, but the solution, in .emacs:

(autoload 'blog-init "blog")
---SNIP---
(push '("\\.blog\\'" . blog-init) auto-mode-alist)

Another degree of perfection reached by Emacs.

Sunday, September 14, 2008

Emacs usecases 3 - LaTeX

Previous in series: 2 - Blogging
Next in series: 4 - Blogging 2

Sorry about the delay, this week was quite busy at school. Anyway, here comes nothing.
Yup, nothing. You just download and install AUCTeX and you're set. No lengthy tutorials on how to do what this time, the AUCTeX docs cover everything (see here). preview-latex is included, which highlights your LaTeX file. It does the job perfectly out of the box - as does AUCTeX, for that matter. Anyway, you also have the preview-latex docs.

One thing I needed and wasn't provided by AUCTeX is word counting. Of course someone already wrote a minor mode for that: word-count. Usage is pretty straight-forward: M-x word-count-mode adds the word count to the status line. You can count words in a region or from a point in the buffer.

my-latex-init.el, auto-loaded:

;;;###autoload
(defun my-latex-init ()
  (tex-pdf-mode)  ;; I want PDF by default
  (flyspell-mode) ;; Spellchecking on the fly
  (word-count-mode)
  (auto-fill-mode)
)
  

Friday, September 5, 2008

Emacs usecases 2 - Blogging

Previous in series: 1 - Python
Next in series: 3 - LaTeX

Note: The URL incorrectly says "emacs-usecases-3-blogging" instead of 2, due to a typo. I don't think there's a way to change that now, sorry.

I know I promised a post about Emacs and LaTeX, but I just stumbled upon some incredibly cool stuff.
Writing long blog posts is tiring. Especially in a tiny textbox. I decided to find something more comfortable. As usual, people considerably more creative and skilled than me already created everything I need.
So. You want to edit text. What's the tool for the job? Yeah, you guessed it, a text editor. And with the It's All Text! add-on for Firefox, you can do just that. Edit text with your favorite text editor. For me, that's Emacs right now. You get to choose what extension you want for the temp file, which of course fires up the appropriate major mode.

What I also want while writing posts is spell-checking. Guess what - Emacs has that, too. First off, you have M-x ispell, which cycles through all the words not in the current dictionary and offers corrections. If you, like me, post in different languages in different places, you must use the right dictionary for the right language. M-x ispell-change-dictionary solves that problem.
Want all the unknown words highlighet in red and underlined while writing? Try M-x flyspell-mode. Now you see what words are thought wrong by ispell. To ask for suggestions for a certain word move the cursor over the word and hit M-$. This opens a minibuffer-like thing on top of the current buffer, with suggestions and a number corresponding to each word. Just press the number you want, and you're done.

Pedantic stuff: now I can use auto-fill-mode and M-q to make lines 80 chars long. I hope this will make the source of the posts nicer. Yeah, I care about that... That's the pedantic part.

Thursday, September 4, 2008

Emacs usecases 1 - Python

Previous in series: 0 - Intro
Next in series: 2 - Blogging

Disclaimer: This is pretty basic and verbose stuff. If you use Emacs to develop Python regularly, take a look at the links below. Most of the rest is probably old news to you.

Update: I forgot to mention that you can run an instance of pdb (Python Debugger) inside Emacs with M-x pdb. It lets you step through the code and keeps the cursor in the code buffer at the current line being executed. You can also use pdb to execute arbitrary Python statements while the program is paused.

There's a recent post on this blog on how VIM is the ultimate Python IDE. I have to say, after two weeks of using Emacs for editing exclusively, that Emacs is just way too feature-rich compared to VIM. There's a dedicated Python major-mode (yup, you guessed it, python-mode), provided in python.el. Then there's the inferior-python-mode, for running the Python interpreter inside Emacs. And of course you still have all the power of Emacs (some of which I probably still don't know about).

The Emacs wiki lists some possible problems, but I found the python-mode distributed with Emacs 22 to work flawlessly. Some other links you may find useful:

python-mode

Indentation in Python is very important, so it's worth noting that Emacs handles Python indentation extremely gracefully. It's worth to note that the tab character means eight spaces to Python. However, python-mode defaults to spaces-only, 4 spaces per level indentation, the Python standard. When you ask Emacs to make a new, indented line, it checks what level of indentation you really need. In most cases that's just the same as on the current line, but lines ending with a colon are indented one level deeper, while a return reduces the depth. Of course you have smart tabs, meaning that deleting an indentation doesn't remove one space, but a whole level of indentation. Additionally the Tab key doesn't increase indentation, and doesn't insert a tab character, but instead cycles the current line through the available indentation levels, showing information about the level in the minibuffer.

There are several useful shortcuts available when editing Python code. You can explore most of them via the menu *shudder* so I'm not going to list them all here. Other than the usual C-j the only one I use regularly is C-c C-c, which compiles the current buffer - evaluates it, to be accurate. It does so in an inferior Python process, which takes us to...

inferior-python-mode

Having the ability to run a Python interpreter inside Emacs is pretty useful in itself - you don't have to switch between windows to test that new piece of code. But it's better than just that. When you evaluate a buffer with C-c C-c (or a region, for that matter), it gets sent straight to the inferior Python process. You can directly access everything in the evaluated file in the interpreter. That's great for testing new functionality.
When things break, they break gracefully: if there's a problem during the evaluation, you get the same messages you would get when running the code. If you want hyperlinks to the position of the error, you can compile with mode-compile (see the intro for setting it up, my-generic.el in particular).

That's it for today. Watch this space for an Emacs + LaTeX post soon :)

Wednesday, September 3, 2008

Emacs usecases 0 - Intro

Next in series: 1 - Python

No more VIM for me. I tried out Emacs for a few days and I absolutely love it. It's got all the features I need, some features I don't need, and numerous features I didn't even know I needed. Also, with elisp, you can make it do whatever you want it to do.
This n-part series will describe the things I use Emacs for at the moment (where n is expected to be in the interval [2; 10]).

DotEmacs

My setup is based on this post. The .emacs file loads or autoloads third-party scripts and my own files.

Autoload
Define a function as available from a file, possibly with a help string, to be loaded from disk only if and when the function is called. This makes startup faster, but can introduce lags when the file is first loaded.

The .emacs.d directory contains everything Emacs-related. My own scripts are here, and third-party scripts are in .emacs.d/lisp. My own customizations are split into two parts. One, my-generic.el, is loaded on startup. It contains everything I want loaded on startup. The rest are stuff for certain modes. For example, my-python-init.el is loaded when the Python mode is started. (Done with hooks.)

My .emacs:
;; Based on McGeary's init: http://www.emacsblog.org/2007/10/07/declaring-emacs-bankruptcy/

;; paths
(add-to-list 'load-path (expand-file-name "~/.emacs.d"))
(add-to-list 'load-path (expand-file-name "~/.emacs.d/lisp"))

;; Third-party stuff
(require 'doremi-cmd)


;; Preferences
(load "my-generic")

;; Autoload hook functions
(autoload 'my-python-init "my-python-init")
(autoload 'my-ruby-init "my-ruby-init")
(autoload 'my-latex-init "my-latex-init")

;; Hooks
;; (add-hook 'python-mode-hook 'my-python-init)

(add-hook 'LaTeX-mode-hook 'my-latex-init)
(add-hook 'ruby-mode-hook 'my-ruby-init)

;; Customize
(custom-set-variables
'(inhibit-splash-screen t)
 '(nuke-trailing-whitespace-in-hooks (quote (write-file-hooks mail-send-hook)) nil (nuke-trailing-whitespace)))
(custom-set-faces
 )

An example of what the autoloaded files look like is provided below. They'll all be discussed in the post related to their mode.

my-python-init.el:
;;;###autoload
(defun my-python-init ()
    ;; Python must always be indented, so why not bind Return to that?
    (local-set-key "\r" 'newline-and-indent)
)

Also, my-generic.el:
(load "toggle-fullscreen")

(color-theme-ld-dark)  ;; Nice, dark, easy on the eyes
(tool-bar-mode -1)     ;; No toolbar, thanks
(set-default 'fill-column 80) ;; 80. standard. good.
(setq visible-bell t);; Can't go beeping around at midnight, now can I?
(toggle-fullscreen)  ;; Start maximized


(setq-default indent-tabs-mode nil)  ;; I always want spaces instead of tabs

(global-set-key "\C-x\C-m" 'execute-extended-command)  ;; for M-x
(global-set-key "\C-w" 'backward-kill-word)  ;; instead of backspacing

(global-set-key "\C-x\C-k" 'kill-region)  ;; rebind kill-region

(setq default-tab-width 4)

;; mode-compile
(autoload 'mode-compile "mode-compile"
"Command to compile current buffer file based on the major mode" t)
(global-set-key "\C-cc" 'mode-compile)
(autoload 'mode-compile-kill "mode-compile"

"Command to kill a compilation launched by `mode-compile'" t)
(global-set-key "\C-ck" 'mode-compile-kill)
(setq mode-compile-expert-p t)

And finally toggle-fullscreen.el:
;; Maximizes the window; Found on the Ubuntu forums.
(defun toggle-fullscreen ()
  (interactive)
  (x-send-client-message nil 0 nil "_NET_WM_STATE" 32
                         '(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0))
  (x-send-client-message nil 0 nil "_NET_WM_STATE" 32
                         '(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
)
Btw, the listings were made by the Emacs command "htmlize-file".