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'.
This commit is contained in:
Tom Willemse 2013-06-04 00:35:52 +02:00
parent baa9c5b705
commit 6c3dce90cb

View file

@ -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");