diff options
author | Tom Willemse | 2013-06-04 00:35:52 +0200 |
---|---|---|
committer | Tom Willemse | 2013-06-04 01:12:13 +0200 |
commit | 6c3dce90cb5896947a26f27432b41d180defe2b3 (patch) | |
tree | 17390aa445767d2b8e2a74fa0298c8ccdde241e1 | |
parent | baa9c5b70525f18349d2bc53887dc68193a5ce74 (diff) | |
download | clark-conkeror-6c3dce90cb5896947a26f27432b41d180defe2b3.tar.gz clark-conkeror-6c3dce90cb5896947a26f27432b41d180defe2b3.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'.
-rw-r--r-- | clark.js | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -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"); |