From 6c3dce90cb5896947a26f27432b41d180defe2b3 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 4 Jun 2013 00:35:52 +0200 Subject: Add random command This command simply prints a random URL. A tag may be specified to limit the search to that tag. In the Conkeror module this command immediately loads the random bookmark in the current buffer. - js/clark.js: If `error' is empty, return the value of `data'. This makes it easier for some commands to use the result of the command. Add `clark-random' to `clark_keymap'. --- clark.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/clark.js b/clark.js index 80eff5d..72c9ee4 100644 --- a/clark.js +++ b/clark.js @@ -264,6 +264,22 @@ function clark_set_tags(I) { interactive("clark-set-tags", "Replace the tags for the bookmark of" + " the current URL.", clark_set_tags); +function clark_random(I) +{ + check_buffer(I.buffer, content_buffer); + + let tag = yield I.minibuffer.read($prompt="tag: "); + let command = clark_program + ' random'; + if (tag != "") + command += ' ' + tag; + + let result = yield clark_shell_command(command); + + if (result) + I.buffer.load(result); +} +interactive("clark-random", "Open a random bookmark", clark_random); + function clark_shell_command(command) { let data = "", error = ""; @@ -278,11 +294,12 @@ function clark_shell_command(command) )}] ); - yield co_return(error == ""); + yield co_return(error == "" && data); } define_keymap("clark_keymap"); +define_key(clark_keymap, "#", "clark-random"); define_key(clark_keymap, "?", "clark-exists-p"); define_key(clark_keymap, "a", "clark-add"); define_key(clark_keymap, "A", "clark-add-link"); -- cgit v1.2.3-54-g00ecf