Tassilo’s Blog

The personal blog of Tassilo Horn

Calling org-remember from inside conkeror

with 3 comments

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):

(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.

Written by Tassilo Horn

November 14, 2008 at 11:30 am

3 Responses

Subscribe to comments with RSS.

  1. Hi!

    Great Setup, thank you!
    One question, though:

    If I get it right, pressing C-c C-c should file away the note and delete the frame created to write the note. But the (delete-frame nil t) is not executed here after pressing C-c C-c. Any idea, why?

    org 6.27a
    emacs-snapshot 23.0.91.1

    Memnon

    June 20, 2009 at 11:32 pm

  2. No, sorry, but I don’t use that snippet anymore. Now I use org-protocol which contains a handler for remember. With that you only need a template on the emacs side like this:

    (setq org-remember-templates
    ‘((”TODO” ?t “* TODO %?\n (created: %U)\n %i\n %a”)
    (”BROWSER” ?w “* %:description :browser:\n (created: %U)\n\n %c\n\n %i”)))

    This is the new conkeror part:

    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);
    });

    Bye!

    Tassilo

    June 20, 2009 at 11:40 pm

  3. Ah, nice ;)
    Same problem, I have to press C-x 5 0 after I filed the note away with C-c C-c. Mhh… Nice little problem for my first elisp steps. I will solve it, eventually.
    Thank god so many people provide their snippets to learn from :) .
    Thanks again!

    Memnon

    June 21, 2009 at 1:38 am


Leave a Reply