diff options
author | Tom Willemse | 2013-11-03 21:21:21 +0100 |
---|---|---|
committer | Tom Willemse | 2013-11-03 21:21:21 +0100 |
commit | 5c6cd059e8395d7f24d4b199e59c8c2f562dc438 (patch) | |
tree | 2e108e0724b5f5248de11c515312fa8c7c04ab4c /.conkerorrc/init.js | |
parent | cca8771d855a3c8ba67bcb43a45967d9e4b6dd15 (diff) | |
download | dotfiles-5c6cd059e8395d7f24d4b199e59c8c2f562dc438.tar.gz dotfiles-5c6cd059e8395d7f24d4b199e59c8c2f562dc438.zip |
New stow hierarchy
Diffstat (limited to '.conkerorrc/init.js')
-rw-r--r-- | .conkerorrc/init.js | 315 |
1 files changed, 0 insertions, 315 deletions
diff --git a/.conkerorrc/init.js b/.conkerorrc/init.js deleted file mode 100644 index 520ef04..0000000 --- a/.conkerorrc/init.js +++ /dev/null @@ -1,315 +0,0 @@ -require("content-policy.js"); -require("favicon"); -require("session"); - -load_paths.push("file:///usr/local/clark/share/conkeror/modules/"); -load_paths.push("file:///home/slash/projects/cdispass/"); -theme_load_paths.push("/home/slash/.conkerorrc/themes/"); - -require("clark"); -require("cdispass"); - -define_browser_object_class( - "history-url", null, - function (I, prompt) { - check_buffer(I.buffer, content_buffer); - var result = yield I.buffer.window.minibuffer.read_url( - $prompt = prompt, $use_webjumps = false, $use_history = true, - $use_bookmarks = false, $sort_order = 'date_descending' - ); - yield co_return(result); - } -); - -function ext_title_format(window) { - return '(' + get_current_profile() +') ' - + window.buffers.current.description; -} - -function oni_add_sheet(css) { - let (sheet = get_home_directory()) { - sheet.append(".conkerorrc"); - sheet.append("styles"); - sheet.append(css); - register_user_stylesheet(make_uri(sheet)); - }; -} - -function oni_before_quit_func() { - var w = get_recent_conkeror_window(); - var result = (w == null) || - "y" == (yield w.minibuffer.read_single_character_option( - $prompt="Quit Conkeror? (y/n)", - $options=["y", "n"])); - yield co_return(result); -} - -function oni_block_flash(content_type, content_location) { - var Y = content_policy_accept, N = content_policy_reject; - var action = ({ "youtube.com": Y } - [content_location.host] || N); - - if (action == N) - dumpln("blocked flash: " + content_location.spec); - - return action; -} - -function oni_escape(str) { - return str.replace(/(["$`])/g, '\\$1'); -} - -function oni_org_store_link(I) { - var cmd_str = 'emacsclient \"org-protocol://store-link://' - + encodeURIComponent(I.buffer.display_uri_string) + '/' - + encodeURIComponent(I.buffer.document.title) + '\"'; - - if (I.window != null) { - window.minibuffer.message('Issuing ' + cmd_str); - } - - shell_command_blind(cmd_str); -} -interactive("org-store-link", - "Stores [[url][title]] as org link and copies url to emacs " - + "kill ring", - oni_org_store_link); - -interactive("find-url-from-history", - "Find a page from history in the current buffer", - "find-url", - $browser_object = browser_object_history_url); -interactive("find-url-from-history-new-buffer", - "Find a page from history in a new buffer", - "find-url-new-buffer", - $browser_object = browser_object_history_url); - -define_webjump("emacswiki", - "https://duckduckgo.com/?q=%s+site%3Aemacswiki.org", - $alternative="http://www.emacswiki.org"); -define_webjump("php", - "http://www.php.net/manual-lookup.php?pattern=%s&scope=quickref", - $alternative="http://www.php.net"); -define_webjump("python", - "http://docs.python.org/search.html?q=%s&check_keywords=yes&area=default", - $alternative="http://www.python.org"); -define_webjump("ddg", - "https://duckduckgo.com/?q=%s", - $alternative="https://duckduckgo.com"); -define_webjump("metal-archives", - "http://www.metal-archives.com/search?searchString=%s&type=band_name", - $alternative="http://www.metal-archives.com"); -define_webjump("djangodocs", - "https://docs.djangoproject.com/search/?q=%s&release=5", - $alternative="https://docs.djangoproject.com/"); -define_webjump("google", - "https://duckduckgo.com?q=!google%%20%s"); -define_webjump("github", - "https://github.com/search?q=%s&type=Everything&repo=&langOverride=&start_value=1", - $alternative="https://github.com"); -define_webjump("mdn", - "https://developer.mozilla.org/en-US/search?q=%s", - $alternative="https://developer.mozilla.org/"); -define_webjump("monsterhunter", - "http://monsterhunter.wikia.com/wiki/index.php?search=%s&fulltext=Search", - $alternative="http://monsterhunter.wikia.com/"); -// Archlinux -define_webjump("arch/wiki", - "https://wiki.archlinux.org/index.php?search=%s", - $alternative="https://wiki.archlinux.org"); -define_webjump("arch/aur", - "https://aur.archlinux.org/packages.php?O=0&K=%s&do_Search=Go", - $alternative="https://aur.archlinux.org"); -define_webjump("arch/packages", - "https://www.archlinux.org/packages/?sort=&q=%s&limit=50", - $alternative="https://packages.archlinux.org"); - -/// Chickadee -// From http://conkeror.org/Webjumps -function chickadee_completer (input, cursor_position, conservative) { - var completions = []; - var content = yield send_http_request( - load_spec({uri: "http://api.call-cc.org/cdoc/ajax/prefix?q="+ - encodeURIComponent(input)})); - if (content.responseText) { - var parser = Cc["@mozilla.org/xmlextras/domparser;1"] - .createInstance(Ci.nsIDOMParser); - var doc = parser.parseFromString(content.responseText, "text/xml"); - var res = doc.getElementsByTagName("li"); - for (let i = 0, n = res.length; i < n; ++i) { - completions.push(res[i].textContent); - } - } - yield co_return(prefix_completer($completions = completions) - (input, cursor_position, conservative)); -} -define_webjump("chickadee", - "http://api.call-cc.org/cdoc?q=%s&query-name=Lookup", - $alternative = "http://api.call-cc.org/doc/", - $completer = chickadee_completer); -/// /Chickadee - -// content_policy_bytype_table.object = oni_block_flash; -cwd = make_file("/home/slash/downloads/"); -hint_digits = "arstdhneio"; -read_buffer_show_icons = true; -title_format_fn = ext_title_format; -url_remoting_fn = load_url_in_new_buffer; -session_auto_save_auto_load = true; - -define_key(content_buffer_normal_keymap, "C-x C-b", "switch-to-buffer"); -define_key(content_buffer_normal_keymap, "C-y", "paste-url-new-buffer"); -define_key(content_buffer_normal_keymap, "H", "find-url-from-history"); -define_key(content_buffer_normal_keymap, "h", "find-url-from-history-new-buffer"); -define_key(default_base_keymap, "C-x f", "follow-new-buffer"); -define_key(content_buffer_normal_keymap, "b", clark_keymap); -define_key(content_buffer_text_keymap, "C-c d", "dispass-and-submit"); - -add_hook("before_quit_hook", oni_before_quit_func); -add_hook("content_policy_hook", content_policy_bytype); -add_hook("mode_line_hook", mode_line_adder(buffer_count_widget)); -add_hook("mode_line_hook", mode_line_adder(buffer_icon_widget), true); -add_hook("mode_line_hook", mode_line_adder(clark_bookmarked_widget), true); -add_hook("mode_line_hook", mode_line_adder(downloads_status_widget)); - -remove_hook("download_added_hook", open_download_buffer_automatically); - -hints_minibuffer_annotation_mode(true); -theme_load("yoshi"); - -external_content_handlers.set("application/pdf", "zathura"); -external_content_handlers.set("application/vnd.ms-excel", "libreoffice"); - -var gh_url = "http://github.com/"; -function read_url_github_ad_command_handler(input) -{ - var m = /^gh\s+@(\S+)(?:\s+((?:un)?follow))?/.exec(input); - if (m) { - if (m[2]) - return gh_url + "users/follow?target="; - return gh_url + m[1]; - } - - return null; -} - -function read_url_github_my_command_handler(input) -{ - var m = /^gh\s+my\s+(dashboard|issues|notifications|profile|pulls|stars)/.exec(input); - - if (m) { - switch (m[1]) { - case "dashboard": - case "notifications": - case "stars": - return gh_url + m[1]; - case "issues": - case "pulls": - return gh_url + "dashboard/" + m[1]; - case "profile": - return gh_url + "settings/" + m[1]; - } - } - - return null; -} - -function read_url_github_repo_command_handler(input) -{ - var m = /^gh\s+(\S+\/\S+)(?:\s+(\#\d+|\@\S+|issues|pulls|wiki|graphs|network|admin)(?:\s+(\#\d+|new))?)?$/.exec(input); - - if (m) { - repo_url = gh_url + m[1] + "/"; - - switch (m[2]) { - case "issues": - issues_url = repo_url + m[2] + "/"; - - if (m[3]) { - if (m[3][0] == '#') - return issues_url + m[3].substring(1); - else if (m[3] == "new") - return issues_url + m[3]; - else - break; - } - - return issues_url; - case "pulls": - case "wiki": - case "graphs": - case "network": - case "admin": - return repo_url + m[2]; - default: - // Still need watch and unwatch - if (m[2]) { - if (m[2][0] == '#') - return repo_url + "issues/" + m[2].substring(1); - else if (m[2][0] == '@') - return repo_url + "tree/" + m[2].substring(1); - else - break; - } - - return repo_url; - } - } - - return null; -} - -function read_url_github_command_handler(input) -{ - return read_url_github_ad_command_handler(input) - || read_url_github_my_command_handler(input) - || read_url_github_repo_command_handler(input); -} - -function read_url_local_port_handler(input) -{ - var m = /^lh (\d{1,5})(?:\s+([a-zA-Z0-9%/]+))?$/.exec(input), - rv = null; - - if (m) { - rv = "http://localhost:" + m[1]; - - if (m[2]) - rv += "/" + m[2]; - } - - return rv; -} - -read_url_handler_list = [read_url_local_port_handler, - read_url_github_command_handler]; - -// Mozrepl -let (mozrepl_init = get_home_directory()) { - mozrepl_init.appendRelativePath(".mozrepl-conkeror.js"); - session_pref('extensions.mozrepl.initUrl', make_uri(mozrepl_init).spec); -}; - -// if ('@hyperstruct.net/mozlab/mozrepl;1' in Cc) { -// let mozrepl = Cc['@hyperstruct.net/mozlab/mozrepl;1'] -// .getService(Ci.nsIMozRepl); -// if (!mozrepl.isActive()) -// mozrepl.start(4242); -// } - -register_user_stylesheet( - "data:text/css," + - escape( - "@namespace url(\"http://www.w3.org/1999/xhtml\");\n" + - "span.__conkeror_hint {\n" + - " font-family: \"Envy Code R\" !important;\n" + - " font-size: 12px !important;\n" + - " line-height: 12px !important;\n" + - " padding: 0 2px !important;\n" + - "}" - ) -); - -oni_add_sheet("github.css"); -oni_add_sheet("help.css"); -oni_add_sheet("git-scm.css"); |