Conkeror: Webjump Helper

0

I’ve finally picked up the Conkeror browser – the keyboard-centric browser that has Emacs like key bindings and is based upon the Firefox html engine – and it’s simply awesome! I hardly ever have to touch the mouse anymore when browsing the web. You should definitely check it out!

I’m not covering the ins and outs of the browser in this post, though. This article is only about Webjumps and an easier way to create them.

By default you need to add a define_webjump for each webjump that you create. Not bad if you only have a couple, but a real pain in the butt if you have hundreds. I solved this issue by defining my webjumps as a dictionary of objects, then passing that dictionary to a function I wrote called makeWebJumps which does what you’d expect – cycle over the dictionary and create each webjump.

Here’s the definition of the function:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/*
 * takes a list of objects and turns them into webjumps
 * spec is mandatory and can be a url or a function that returns a url, alt is optional
 */
makeWebJumps = function(listOfObjects) {
  for (var i = 0; i < listOfObjects.length; i++) {
    var myWebJumps = listOfObjects[i];
    for (key in myWebJumps) {
      if (!myWebJumps[key].hasOwnProperty('alt')) {
        define_webjump(key, myWebJumps[key].spec);
      } else {
        define_webjump(key, myWebJumps[key].spec, $alternative = myWebJumps[key].alt);
      }
    }
  }
}

And to see how I populate my dictionaries and use makeWebJumps check out the snippet below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
var baseWebJumps = {
  "wowhead":{spec:"http://www.wowhead.com/search?q=%s"},
  "homemail":{spec:"https://mail.google.com/mail/u/1/#inbox"},
  "yts":{spec:"http://yts.re/browse-movie/%s/720p/All/0/latest", alt:"http://yts.re/browse-movie/0/720p/All/0/latest"},
  "feedly":{spec:"https://feedly.com/index.html#my"},
  "localtrans":{spec:"http://192.168.0.102:12345"},
  "localplex":{spec:"http://192.168.0.102:32400/web"},
  "espnf":{spec:"http://games.espn.go.com/ffl/leagueoffice?leagueId=570639&seasonId=2014"},
  "cbsf":{spec:"http://2002scfl.football.cbssports.com/"},
  "cblog":{spec:"http://blog.coderscabal.org/"},
  "myreddit":{spec:"http://www.reddit.com/user/jmaelstrom/"}
}
 
makeWebJumps([baseWebJumps]);

You’ll notice the function actually takes an array of dictionaries. The reason being is that I like to keep my web jumps organized by category – because I’m kinda weird like that. Also notice the dictionary values are actually objects. spec is mandatory while alt is used if the webjump isn’t supplied an argument.

Pretty slick, eh? Well, not overly – but I find it useful anyway!

 

Emacs Configuration Management – Part I

0

I love Emacs – I use it for everything. Local file editing, remote file editing via Tramp, terminals, calendars, email, news groups, rss / atom feeds, reminders, time keeping, todo lists, document generation (from org-mode) – literally just about everything I can.

As you can imagine that amount of usability takes quite a bit of customization. Luckily, the Emacs community has done most of the heavy lifting. All that I have to manage is my own programmatic idiosyncrasies and – the init.el…

It became huge, and messy, and cumbersome. And like any good programmer it made me feel dirty – it needed organized and modularized. But again like any good coder – I didn’t want it to be manual. I wanted drop-in, auto-discover modularity that didn’t require any additional scripting.

Like most things coding (when you don’t know what you are doing) you start out on a quest to discover what’s available in the language of question for you to leverage. And that, to me, is the fun part – the acquisition of knowledge. The problem at hand is just a reason for you to dig deeper and learn – but I digress…

This post – like most of mine – is segmented. Mostly because I’m long-winded when discussing this material. However, I think this one is pretty good and you should come back to read the follow-ups. Why? Because of the snippet to follow and this explanation:

I currently have over 41 csutomization emacs .el files (1 or more for each mode / package) and my init.el file is simply:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
;; set up path helpers
(setq my-emacs-d "~/.emacs.d/")
(setq my-emacs-elpa (concat my-emacs-d "elpa/"))
(setq my-emacs-conf (concat my-emacs-d "emacs-conf/"))
(setq my-emacs-live (concat my-emacs-d "emacs-live/"))
(setq my-emacs-org (concat my-emacs-d "emacs-org/"))
(setq my-emacs-3p (concat my-emacs-d "third-party/"))
(setq my-site-file "~/site_conf.el")
 
;; load site file if it exists
(if (file-exists-p my-site-file) 
    (progn
      (load my-site-file)
      (find-file my-site-file))
)
 
;; load various configurations
(load (concat my-emacs-conf "configurations_config.el"))
 
;; will load and byte-compile my modular configurations
(my-load-configurations)

I can add a thousand configuration files – and my init.el never will get any larger. The key? My configurations_config.el – which isn’t as crazy as you’d think it would be. I like to think it’s a thing of beauty – but you can weigh in on my next post when we dig into it!