Wednesday, July 1, 2009

Moved

You can now find this blog at http://abesto.host22.com/. This will stay here for search engine and archival purposes as long as Google lets it stay. The FeedBurner address is now redirected to the new feed.

One can hardly call themselves a web developer (as in "developer of web-based applications" as opposed to "developer of the web in general") if they run a blog on a slightly hacked pre-made blog. Right? Right. That's what I thought you'd say. So, I created a basic site that I'll expand as needed.

The more useful posts and all the comments have been ported to the new site. That's it, I guess. This blog is now

CLOSED

Wednesday, May 20, 2009

nXhtml and Doxymacs

Update 2009-05-29: a simple fix makes doxymacs work with nXhtml and mumamo, courtesy of Lennart Borgman. This is required up to at least version 1.8.0 of doxymacs. Edit doxymacs.el or just redefine the function in your .emacs:

(defun doxymacs-font-lock ()                                                                   
  "Turn on font-lock for Doxygen keywords."                                                                                           
  ;; FIXME How do I turn *off* font-lock for Doxygen keywords?                                    
  (interactive)                                                                                                                                         
  (if (functionp 'font-lock-add-keywords)                                                                                         
      ;; Use new (proper?) font-lock-add-keywords function                                        
      ;;(font-lock-add-keywords nil doxymacs-doxygen-keywords)                             
      (font-lock-add-keywords major-mode doxymacs-doxygen-keywords)                                                                                     
    ;; Use old-school way                                                                         
    (let ((old (if (eq (car-safe font-lock-keywords) t)                                       
                 (cdr font-lock-keywords)                                                                                                                      
               font-lock-keywords)))                                                                                                                           
      (setq font-lock-keywords (append old doxymacs-doxygen-keywords)))))

nXhtml is very cool for writing code in HTML/PHP/JS/CSS/XSLT/... And you want to comment your code. Lately, that's been mostly PHP for me. The best Emacs-based solution seems to be Doxymacs. However, the two don't mix. nXhtml's mumamo-mode kills Doxymacs on major mode switches. Here's a quick solution:

(defun ensure-doxymacs-mode ()
    (doxymacs-mode 1)
  )
(add-hook 'php-mode-hook 'ensure-doxymacs-mode)

I also tried to get Doxymacs font-locking to work with some similar tricks, but that seems to require quite a lot more work. It just isn't seem to be worth it.

Sunday, May 3, 2009

Hardcore keyboard-only browsing

When it comes to going mouse-less on the computer, the best solution tends to be several different solutions mixed up (for me at least). In text editors, I use vim for quick edits of config files. I use Emacs for everything else, but with viper-mode. The vi/m keys are just so much more efficient.

Conkeror

Browser-wise I've been using Firefox+Vimperator for a while. A really nice combo, although it always felt somewhat slow. After a laptop crash and some updates, Vimperator gave me some strange issues, so I decided to give Conkeror a try. Conkeror is a stand-alone browser, giving the developers complete freedom to shape it. This means more features than Vimperator, which is "only" an extension - complete conversion, if you will - of Firefox. Most of the Firefox extensions work with Conkeror, with a list of what works and what doesn't here.

One of the nice things about Conkeror is hint classes. Vimperator has hints too, but AFAIK only for links. In case you haven't used either, here's what happens: you hit a key, and all the visible links get highlighted. Each link has a little number next to it that you can type to follow the link, or you can even type part of the link text.

Conkeror takes this one step further: you can do the same for example with images and embedded media by default. You can also define new hint classes with XPath selectors (and maybe even just regular expressions too, I haven't tried yet).

There's a whole bunch of similar goodness, see a list at the Conkeror wiki.

Vimperator-like keybindings

This is all fine as long as you have Emacs keybindings hard-wired into your hands. I don't - my first experience in the world of *nix editors was with Vim, and (maybe because of that) I like one keypress per command setups way too much. So, without further ado, I give you Vimperator-like keybindings for Conkeror. Just paste this into your ~/.conkerorrc

// Keybindings
var maps = Array(
    // Vimperator-like
    "j"   , "cmd_scrollLineDown",
    "k"   , "cmd_scrollLineUp",
    "h"   , "cmd_scrollLeft",
    "l"   , "cmd_scrollRight",
    "o"   , "find-url",
    "t"   , "find-url-new-buffer",
    "C-i" , "go-forward",
    "C-o" , "go-back",
    "C-n" , "buffer-next",
    "C-p" , "buffer-previous",
    "d"   , "kill-current-buffer",
    "/"   , "isearch-forward",
    // Eye guide
    "space", "eye-guide-scroll-down",
    "back_space", "eye-guide-scroll-up",
    // Vimperator-like eye guide :D
    "C-f" , "eye-guide-scroll-down",
    "C-b" , "eye-guide-scroll-up"
);

for (var i = 0; i < maps.length; i += 1)
    define_key(content_buffer_normal_keymap, maps[i], maps[i+1]);

The eye-guide mentioned in the snippet is one of the useful modules Conkeror comes with. When scrolling with the eye-guide-scroll-* command, Conkeror briefly highlights the portion of text that was visible before scrolling. This helps a lot when reading multi-page documents. After spending a morning customizing Conkeror, it seems preferable to Firefox.

Links

The Conkeror wiki: http://conkeror.org
A list of Conkeror modules: http://conkeror.org/Modules
My .conkerorrc at Github