From 0fbc39c2d8242abb69def2027d4e07ef1dbb838b Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Sun, 24 Mar 2013 13:42:20 +0100 Subject: [PATCH] Add clark-exists-p Prints `yes' when the url is found in the database, `no' otherwise. --- js/clark.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/js/clark.js b/js/clark.js index ade3683..5a5e98b 100644 --- a/js/clark.js +++ b/js/clark.js @@ -133,7 +133,32 @@ interactive("clark-find-url-new-buffer", "find-url-new-buffer", $browser_object = browser_object_clark_bookmark); +function clark_exists_p(I) { + check_buffer(I.buffer, content_buffer); + + let url_string = + load_spec_uri_string(load_spec(I.buffer.top_frame)); + let command = clark_program + ' exists "' + url_string + '"'; + var data = "", error = ""; + + result = yield shell_command( + command, + $fds = [{ output: async_binary_string_writer("") }, + { input: async_binary_reader(function (s) data += s || "") }, + { input: async_binary_reader(function (s) error += s || "") }] + ); + + if (error != "") + throw new Error("Error occurred with CLark: " + error); + + I.window.minibuffer.message(data); +} + +interactive("clark-exists-p", "Check to see if the current url" + + " exists in the database.", clark_exists_p); + define_keymap("clark_keymap"); define_key(clark_keymap, "a", "clark-add"); +define_key(clark_keymap, "e", "clark-exists-p"); provide("clark");