The configuration of Collin Doering
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

331 lines
12KB

  1. // File: ~/.conkerorrc
  2. // Author: Collin J. Doering <rekahsoft@gmail.com>
  3. // Date: Mar 27, 2011
  4. // REKAHSOFT
  5. // the default page for new buffers.
  6. homepage = "http://www.duckduckgo.com";
  7. // load urls from the command line in new buffers instead of new windows.
  8. url_remoting_fn = load_url_in_new_buffer;
  9. // load download buffers in the background in the current window, instead of in new windows.
  10. download_buffer_automatic_open_target = OPEN_NEW_BUFFER_BACKGROUND;
  11. // save a keystroke when selecting a dom node by number.
  12. hints_auto_exit_delay = 500;
  13. hints_ambiguous_auto_exit_delay = 3000;
  14. // display properties of the current selected node during
  15. // the hints interaction.
  16. hints_display_url_panel = true;
  17. // default directory for downloads and shell commands.
  18. cwd = get_home_directory();
  19. //cwd.append("downloads");
  20. // set how conkeror will handle mime types
  21. external_content_handlers = {
  22. "*": "emacsclient -c",
  23. text: { "*": "emacsclient -c" },
  24. image: { "*": "feh --scale-down" },
  25. video: { "*": "mplayer" },
  26. audio: { "*": "mplayer" },
  27. // "x-scheme-handler/magnet": "transmission-remote -a",
  28. application: {
  29. pdf: "zathura",
  30. postscript: "zathura",
  31. "x-dvi": "zathura",
  32. "x-bittorrent": "transmission-remote -a"
  33. }
  34. };
  35. // TODO: magnet links do not work
  36. //set_protocol_handler("magnet", find_file_in_path("transmission-remote -a"));
  37. // use emacsclient as external editor.
  38. editor_shell_command = "emacsclient -c";
  39. // view source in external editor.
  40. view_source_use_external_editor = true;
  41. // Enable and configure some page modes
  42. // See: http://conkeror.org/PageModes
  43. require("page-modes/xkcd.js");
  44. page_mode_activate(xkcd_mode);
  45. xkcd_add_title = true; // insert alt text into the page
  46. require("page-modes/reddit.js");
  47. page_mode_activate(reddit_mode);
  48. reddit_end_behavior = "page";
  49. require("page-modes/duckduckgo.js");
  50. page_mode_activate(duckduckgo_mode);
  51. require("page-modes/youtube.js");
  52. page_mode_activate(youtube_mode);
  53. // *TODO* doesn't seem to be working
  54. // require("page-modes/google-search-results.js");
  55. // page_mode_activate(google_search_results_mode);
  56. require("page-modes/google-maps.js");
  57. page_mode_activate(google_maps_mode);
  58. require("page-modes/stackexchange.js");
  59. page_mode_activate(stackexchange_mode);
  60. require("page-modes/gmail.js");
  61. page_mode_activate(gmail_mode);
  62. require("page-modes/facebook.js");
  63. page_mode_activate(facebook_mode);
  64. // *TODO* sets j and k to pass through but I enjoy using them for quick scrolling..
  65. // require("page-modes/github.js");
  66. // page_mode_activate(github_mode);
  67. // use session module
  68. require("session.js");
  69. session_auto_save_auto_load = true;
  70. // Put history completion along side webjumps
  71. url_completion_use_history = true;
  72. url_completion_use_bookmarks = true;
  73. // Setup some handy web jumps
  74. define_webjump("wolframalpha", "http://www.wolframalpha.com/input/?i=%s");
  75. define_webjump("duckduckgo", "https://duckduckgo.com/?q=%s");
  76. // Create some shortcuts to the webjumps above
  77. webjumps.ddg = webjumps.duckduckgo
  78. webjumps.wa = webjumps.wolframalpha
  79. // START SECTION: thanks to http://conkeror.org/Webjumps
  80. function chickadee_completer (input, cursor_position, conservative) {
  81. var completions = [];
  82. var content = yield send_http_request(
  83. load_spec({uri: "http://api.call-cc.org/cdoc/ajax/prefix?q="+
  84. encodeURIComponent(input)}));
  85. if (content.responseText) {
  86. var parser = Cc["@mozilla.org/xmlextras/domparser;1"]
  87. .createInstance(Ci.nsIDOMParser);
  88. var doc = parser.parseFromString(content.responseText, "text/xml");
  89. var res = doc.getElementsByTagName("li")
  90. for (let i = 0, n = res.length; i < n; ++i) {
  91. completions.push(res[i].textContent);
  92. }
  93. }
  94. yield co_return(prefix_completer($completions = completions)
  95. (input, cursor_position, conservative));
  96. }
  97. define_webjump("chickadee",
  98. "http://api.call-cc.org/cdoc?q=%s&query-name=Lookup",
  99. $alternative = "http://api.call-cc.org/doc/",
  100. $completer = chickadee_completer);
  101. define_webjump("eggref4", "http://wiki.call-cc.org/eggref/4/%s",
  102. $alternative = "http://wiki.call-cc.org/chicken-projects/egg-index-4.html");
  103. define_webjump("srfi", function (i) {
  104. return "http://srfi.schemers.org/srfi-" + i + "/srfi-" + i + ".html";
  105. });
  106. define_webjump("emacswiki",
  107. "http://www.google.com/cse?cx=004774160799092323420%3A6-ff2s0o6yi"+
  108. "&q=%s&sa=Search&siteurl=emacswiki.org%2F",
  109. $alternative="http://www.emacswiki.org/");
  110. define_webjump("savannah", "https://savannah.gnu.org/search/?words=%s&type_of_search=soft");
  111. define_webjump("youtube", "http://www.youtube.com/results?search_query=%s&search=Search");
  112. // Do a duckduckgo search if a webjump is not recognized
  113. read_url_handler_list = [read_url_make_default_webjump_handler("duckduckgo")];
  114. // recognize urls a little diffently (allow one worded default webjumps)
  115. function possibly_valid_url (str) {
  116. return (/[\.\/:]/.test(str)) &&
  117. !(/\S\s+\S/.test(str)) &&
  118. !(/^\s*$/.test(str));
  119. }
  120. // setup tabs (see: http://conkeror.org/Tabs)
  121. require("new-tabs.js");
  122. // Register stylesheet used to theme new-tabs
  123. register_user_stylesheet("file:///home/collin/.conkeror.d/conkeror.css");
  124. // Setup favicon support (in the mode-line)
  125. require("favicon.js");
  126. add_hook("mode_line_hook", mode_line_adder(buffer_icon_widget), true);
  127. read_buffer_show_icons = true;
  128. // add loading-count and buffer-count widgets to the mode-line
  129. add_hook("mode_line_hook", mode_line_adder(loading_count_widget), true);
  130. add_hook("mode_line_hook", mode_line_adder(buffer_count_widget), true);
  131. // remove the clock from the mode-line
  132. remove_hook("mode_line_hook", mode_line_adder(clock_widget));
  133. // force scrolling bars so that incremental search (isearch) works and mousewheel scrolling
  134. function enable_scrollbars (buffer) {
  135. buffer.top_frame.scrollbars.visible = true;
  136. }
  137. add_hook("create_buffer_late_hook", enable_scrollbars);
  138. // Enable spellchecking of text boxes
  139. session_pref("layout.spellcheckDefault", 2);
  140. // Turn on password management in XUL runner
  141. session_pref("signon.rememberSignons", true);
  142. session_pref("signon.expireMasterPassword", false);
  143. session_pref("signon.SignonFileName", "signons.txt");
  144. Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager); // init
  145. // Some keybindings i like from firefox + pentadactyl, and luakit
  146. define_key(content_buffer_normal_keymap, "C-f", "buffer-next");
  147. define_key(content_buffer_normal_keymap, "C-b", "buffer-previous");
  148. define_key(content_buffer_normal_keymap, "j", "cmd_scrollLineDown");
  149. define_key(content_buffer_normal_keymap, "k", "cmd_scrollLineUp");
  150. define_key(content_buffer_normal_keymap, "J", "follow-new-buffer-background");
  151. define_key(default_global_keymap, "C-x C-b", "switch-to-buffer");
  152. // TODO: fix a bug in conkeror-git 120527.1.100.g7994dfa-1 where M-< is bound to scroll-top-left which is either
  153. // broken or is being depreciated? M-> uses cmd_scrollBottom and internally scroll-top-left uses cmd_scrollTop (then scrolls left).
  154. // Until this issue is fixed just use cmd_scrollTop for M-<
  155. define_key(content_buffer_normal_keymap, "M-<", "cmd_scrollTop");
  156. // Some code thanks to retroj on #conkeror@irc.freenode.net
  157. define_browser_object_class(
  158. "history-url", null,
  159. function (I, prompt) {
  160. check_buffer (I.buffer, content_buffer);
  161. var result = yield I.buffer.window.minibuffer.read_url(
  162. $prompt = prompt, $use_webjumps = false, $use_history = true, $use_bookmarks = false);
  163. yield co_return (result);
  164. },
  165. $hint = "choose url from history");
  166. interactive("find-url-from-history",
  167. "Find a page from history in the current buffer",
  168. "find-url",
  169. $browser_object = browser_object_history_url);
  170. interactive("find-url-from-history-new-buffer",
  171. "Find a page from history in the current buffer",
  172. "find-url-new-buffer",
  173. $browser_object = browser_object_history_url);
  174. function history_clear () {
  175. var history = Cc["@mozilla.org/browser/nav-history-service;1"]
  176. .getService(Ci.nsIBrowserHistory);
  177. history.removeAllPages();
  178. }
  179. interactive("history-clear",
  180. "Clear the history.",
  181. history_clear);
  182. define_variable("firebug_url",
  183. "http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js");
  184. function firebug (I) {
  185. var doc = I.buffer.document;
  186. var script = doc.createElement('script');
  187. script.setAttribute('type', 'text/javascript');
  188. script.setAttribute('src', firebug_url);
  189. script.setAttribute('onload', 'firebug.init();');
  190. doc.body.appendChild(script);
  191. }
  192. interactive("firebug", "open firebug lite", firebug);
  193. // use addblock plus extension; see: http://conkeror.org/AdblockPlus?highlight=%28adblock%29
  194. // AdblockPlus currently not working (Aug 25, 2014)
  195. require("extensions/adblockplus.js");
  196. // Disable whitelist (Causes extensions from unknown/unsigned sites to silently fail if not enabled!)
  197. //session_pref("xpinstall.whitelist.required", false);
  198. // Confirm quiting conkeror
  199. // See: http://conkeror.org/BreakingChanges
  200. add_hook("before_quit_hook",
  201. function () {
  202. var w = get_recent_conkeror_window();
  203. var result = (w == null) ||
  204. "y" == (yield w.minibuffer.read_single_character_option(
  205. $prompt = "Quit Conkeror? (y/n)",
  206. $options = ["y", "n"]));
  207. yield co_return(result);
  208. });
  209. // Proxy code below from: http://conkeror.org/Tips?highlight=%28proxy%29#Proxy_Settings
  210. // TODO: this proxy stuff still needs to be worked out (tor requires a SOCKS proxy)
  211. // set the proxy server for this session only
  212. proxy_server_default = "localhost";
  213. proxy_port_default = 80;
  214. function set_proxy_session (window, server, port) {
  215. if (server == "N") {
  216. session_pref('network.proxy.type', 0); //direct connection
  217. window.minibuffer.message("Direction connection to the internet enabled for this session");
  218. } else {
  219. if (server == "") server = proxy_server_default;
  220. if (port == "") port = proxy_port_default;
  221. session_pref('network.proxy.ftp', server);
  222. session_pref('network.proxy.gopher', server);
  223. session_pref('network.proxy.http', server);
  224. session_pref('network.proxy.socks', server);
  225. session_pref('network.proxy.ssl', server);
  226. session_pref('network.proxy.ftp_port', port);
  227. session_pref('network.proxy.gopher_port', port);
  228. session_pref('network.proxy.http_port', port);
  229. session_pref('network.proxy.socks_port', port);
  230. session_pref('network.proxy.ssl_port', port);
  231. session_pref('network.proxy.share_proxy_settings', true);
  232. session_pref('network.proxy.type', 1);
  233. window.minibuffer.message("All protocols using "+server+":"+port+" for this session");
  234. }
  235. }
  236. interactive("set-proxy-session",
  237. "set the proxy server for all protocols for this session only",
  238. function (I) {
  239. set_proxy_session(
  240. I.window,
  241. (yield I.minibuffer.read($prompt = "server ["+proxy_server_default+"] or N: ")),
  242. (yield I.minibuffer.read($prompt = "port ["+proxy_port_default+"]: ")));
  243. });
  244. // make hint numbers bigger; see: http://conkeror.org/Tips#Big_Hint_Numbers
  245. // register_user_stylesheet(
  246. // "data:text/css," +
  247. // escape(
  248. // "@namespace url(\"http://www.w3.org/1999/xhtml\");\n" +
  249. // "span.__conkeror_hint {\n"+
  250. // " font-size: 18px !important;\n"+
  251. // " line-height: 18px !important;\n"+
  252. // "}"));
  253. //TODO: consider something like below to darken pages
  254. function darken_page (I) {
  255. var styles='* { background: black !important; color: grey !important; }'+
  256. ':link, :link * { color: #4986dd !important; }'+
  257. ':visited, :visited * { color: #d75047 !important; }';
  258. var document = I.buffer.document;
  259. var newSS=document.createElement('link');
  260. newSS.rel='stylesheet';
  261. newSS.href='data:text/css,'+escape(styles);
  262. document.getElementsByTagName("head")[0].appendChild(newSS);
  263. }
  264. interactive("darken-page", "Darken the page in an attempt to save your eyes.",
  265. darken_page);