Add Emacs org-protocol integration

This commit is contained in:
Tom Willemse 2016-11-24 21:40:52 +01:00
parent c06f101307
commit ec876cf254

View file

@ -98,3 +98,33 @@ Add the ~site-js/~ directory to the load path.
define_key(default_global_keymap, 'p', 'scuttle-post');
define_key(default_global_keymap, 'P', 'scuttle-post-link');
#+END_SRC
* Emacs integration
Using org-protocol we can add information from the page.
#+BEGIN_SRC js
function org_capture(url, title, selection, window) {
var cmd_str = 'emacsclient "org-protocol://capture://b/' + url + '/' + title + '/' + selection + '"';
if (window !== null) {
window.minibuffer.message('Issuing ' + cmd_str);
}
shell_command_blind(cmd_str);
}
function org_capture_command(I) {
var url = encodeURIComponent(I.buffer.display_uri_string);
var title = encodeURIComponent(I.buffer.document.title);
var selection = encodeURIComponent(I.buffer.top_frame.getSelection());
org_capture(url, title, selection, I.window);
}
interactive("org-capture",
"Clip url, title and selection to capture via org-protocol",
org_capture_command);
define_key(content_buffer_normal_keymap, "C-c b", "org-capture");
#+END_SRC