diff options
| author | 2013-06-04 00:35:52 +0200 | |
|---|---|---|
| committer | 2013-06-04 01:12:13 +0200 | |
| commit | 9e6199a5aa54b8ef2af1999981cafa0becb3049e (patch) | |
| tree | 3fa7f08236f670eb048e59f291388b55eebe0ed7 /js | |
| parent | 9badf67e274837d0e8a1af5554717dc94fa8bbcf (diff) | |
| download | clark-9e6199a5aa54b8ef2af1999981cafa0becb3049e.tar.gz clark-9e6199a5aa54b8ef2af1999981cafa0becb3049e.zip | |
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'.
Diffstat (limited to 'js')
| -rw-r--r-- | js/clark.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/js/clark.js b/js/clark.js index 80eff5d..72c9ee4 100644 --- a/js/clark.js +++ b/js/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"); |
