Calling org-remember from inside conkeror
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.
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);
});
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
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
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
Just tried your org-protocol code, it works great in Aquamacs, although I had to remove the -c argument. What’s -c for? It doesn’t exist in the Aquamacs emacsclient.
Is the TODO template really necessary? It seems to work fine without it…
Also, maybe you should update the actual blog post with the new code? So newbies don’t have to know how to replace the fancy ” symbols with ‘real’ string delimiters…
Kevin
October 1, 2009 at 1:46 pm
The -c tells emacsclient to create a new frame. That’s new in emacs 23. Maybe aquamacs is still based on 22.
The TODO template is not necessary. I just copy&pasted my config.
And jep, I’ll update the post.
Tassilo Horn
October 1, 2009 at 2:28 pm
ah, yes, Aquamacs is still based on 22, thanks for the info
Kevin
October 1, 2009 at 8:25 pm
FYI, as of 22 Sep, the name of the display_URI_string was changed to display_uri_string, breaking the above script.
justloop
October 7, 2009 at 2:39 am
Thanks for the hint! It’s updated above.
Tassilo
October 7, 2009 at 7:11 pm