Archive for November, 2008

I use Carsten Dominik’s great emacs package org-mode for project planning, appointments and TODOs (org-mode homepage). One cool feature is that it integrates nicely with the remember package. So when an idea comes into my mind I need to remember for later, I hit M-x org-remember RET which presents me a buffer with a custom template, I type my note and hit C-c C-c. The note is filed then and the buffer is gone, so there’s really no interruption.

One cool thing is that org-remember automatically inserts a link to the “thing” you had open when adding the note. This “thing” could be a info buffer, a mail, a usenet article, an image,…

I thought it would be nice to use that facility to make TODO-bookmarks like “TODO read that great blog entry!” from inside my browser conkeror. And so I did.

Here’s the emacs side of the code (put it in your ~/.emacs):

(setq org-remember-templates 
      '(
        ;; lot of other templates...
        ("TODO"    ?t "* TODO %?
  :PROPERTIES:
  :created: %U
  :link: %a
  :END:
  %i")))

(defun th-org-remember-conkeror (url)
  (interactive "s")
  (org-remember nil ?t)
  (save-excursion
    (insert "\n\n  [[" url "]]"))
  (local-set-key (kbd "C-c C-c")
         (lambda ()
           (interactive)
           (org-ctrl-c-ctrl-c)
           (delete-frame nil t))))

And that’s the conkeror side (put it in your ~/.conkerorrc):

function org_remember(url, window) {
    var cmd_str = 'emacsclient -c --eval \'(th-org-remember-conkeror "' + url + '")\'';
    if (window != null) {
    window.minibuffer.message('Issuing ' + cmd_str);
    }
    shell_command_blind(cmd_str);
}

interactive("org-remember", "Remember the current url with org-remember",
        function (I) {
        org_remember(I.buffer.display_URI_string, I.window);
        });

This code may require emacs 23, I’m not too sure. What you need in every case is a running emacs server, so that you can connect to it with emacsclient.

UPDATE: Now I use org-protocol instead of something home-brewn.

Here’s the updated code for your ~/.conkerorrc. On the emacs side nothing is needed anymore.

function org_remember(url, title, text, window) {
    var eurl = encodeURIComponent(url);
    var etitle = encodeURIComponent(title);
    var etext = encodeURIComponent(text);
    var cmd_str = "emacsclient -c org-protocol://remember://" + eurl + "/" + etitle + "/" + etext; 
    window.minibuffer.message("Issuing " + cmd_str);
    shell_command_blind(cmd_str);
}

interactive("org-remember", "Remember the current url with org-remember",
        function (I) {
          org_remember(I.buffer.display_uri_string,
                       I.buffer.document.title,
                       I.buffer.top_frame.getSelection(),
                       I.window);
        });