changes
authorJoerg Jaspert <joerg@debian.org>
Thu, 11 Apr 2013 20:56:29 +0000 (22:56 +0200)
committerJoerg Jaspert <joerg@debian.org>
Thu, 11 Apr 2013 20:56:29 +0000 (22:56 +0200)
.conkerorrc/basics.js
.conkerorrc/bookmark-manipulate.js [new file with mode: 0644]
.conkerorrc/browser-relationship.js [new file with mode: 0644]
.conkerorrc/flashblock.js [new file with mode: 0644]
.conkerorrc/functions.js
.conkerorrc/hide-minibuffer.js [new file with mode: 0644]
.conkerorrc/keybindings.js
.conkerorrc/modeline.js
.conkerorrc/themeblack.js [new file with mode: 0644]
.conkerorrc/ua.js [new file with mode: 0644]

index 657b00c..43856a1 100644 (file)
@@ -14,6 +14,19 @@ let (mozrepl_init = get_home_directory()) {
 //allow for 'contrib' stuff
 load_paths.unshift("chrome://conkeror-contrib/content/");
 
+// One (or some?) of these enables hardware acceleration. Don't know which
+// user_pref('layers.acceleration.draw-fps', true);
+user_pref('webgl.prefer-native-gl', true);
+user_pref('layers.offmainthreadcomposition.animate-opacity', true);
+user_pref('layers.offmainthreadcomposition.animate-transform', true);
+// https://wiki.mozilla.org/Blocklisting/Blocked_Graphics_Drivers#Intel_cards
+user_pref('layers.acceleration.force-enabled', true);
+user_pref('webgl.force-enabled', true);
+user_pref('webgl.msaa-force', true);
+user_pref('gfx.filter.nearest.force-enabled', true);
+// H264
+user_pref('stagefright.force-enabled', true);
+
 // the default page for new buffers.
 homepage = "about:blank";
 
@@ -30,6 +43,7 @@ require("session.js");
 require("block-content-focus-change.js");
 require("daemon.js");
 require("dom-inspector.js");
+require("suggest-file-name.js");
 
 // Auto load the auto-save session when conkeror starts
 session_auto_save_auto_load = true;
@@ -49,7 +63,7 @@ url_completion_use_history = true; // should work since bf05c87405
 url_completion_use_bookmarks = true;
 
 // use emacs as editor
-editor_shell_command = "emacsclient -c";
+editor_shell_command = "emacsclient -a -t";
 
 require("github.js");
 require("newsblur.js");
@@ -245,3 +259,13 @@ define_key(content_buffer_normal_keymap, "* q", "browser-object-tinyurl");
 
 /// open remote url in new tab not new frame
 url_remoting_fn = load_url_in_new_buffer;
+
+if ('@eff.org/https-everywhere;1' in Cc) {
+  interactive("https-everywhere-options-dialog",
+              "Open the HTTPS Everywhere options dialog.",
+              function (I) {
+                window_watcher.openWindow(
+                  null, "chrome://https-everywhere/content/preferences.xul",
+                  "", "chrome,titlebar,toolbar,centerscreen,resizable", null);
+              });
+}
diff --git a/.conkerorrc/bookmark-manipulate.js b/.conkerorrc/bookmark-manipulate.js
new file mode 100644 (file)
index 0000000..cbe6433
--- /dev/null
@@ -0,0 +1,30 @@
+// bookmark url
+
+define_browser_object_class(
+    "bookmarks", 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 = false, $use_bookmarks = true);
+        yield co_return (result);
+    },
+    $hint = "choose from Bookmarks");
+
+define_key(content_buffer_normal_keymap, "* b", "browser-object-bookmarks");
+
+// remove a bookmark
+
+interactive("bookmark-remove", "Remove a bookmark",
+            function bookmark_remove (I) {
+                var spec = yield read_browser_object(I);
+                var uri_string = load_spec_uri_string(spec);
+                try {
+                    var items = nav_bookmarks_service.getBookmarkIdsForURI(make_uri(uri_string), {});
+                    for (i in items) {
+                        nav_bookmarks_service.removeItem(items[i]);
+                    }
+                } catch (e) {}
+            },
+            $browser_object = browser_object_bookmarks
+           );
+
diff --git a/.conkerorrc/browser-relationship.js b/.conkerorrc/browser-relationship.js
new file mode 100644 (file)
index 0000000..f434dad
--- /dev/null
@@ -0,0 +1,28 @@
+
+// next/previous relationship
+require("follow-relationship.js");
+browser_relationship_patterns[RELATIONSHIP_NEXT] =
+    [/^next$/i,
+     /\u4E0B\u4E00\u9875/, //下一页 unicode
+     /\xCFC2\xD2BB\xD2B3/, //下一页 gbk
+     /\u4E0B\u4E00\u5F20/, //下一张 unicode
+     /\xCFC2\xD2BB\xD5C5/, //下一张 gbk
+     new RegExp("^>$","i"),
+     new RegExp("^(>>|»)$","i"),
+     new RegExp("^(>|»)","i"),
+     new RegExp("(>|»)$","i"),
+     new RegExp("\\bnext","i")
+    ];
+
+browser_relationship_patterns[RELATIONSHIP_PREVIOUS] =
+    [/^(prev|previous)$/i,
+     /\u4E0A\u4E00\u9875/, //上一页 unicode
+     /\xC9CF\xD2BB\xD2B3/, //上一页 gbk
+     /\u4E0A\u4E00\u5F20/, //上一张 unicode
+     /\xC9CF\xD2BB\xD5C5/, //上一张 gbk
+     new RegExp("^<$","i"),
+     new RegExp("^(<<|«)$","i"),
+     new RegExp("^(<|«)","i"),
+     new RegExp("(<|«)$","i"),
+     new RegExp("\\bprev|previous\\b","i")
+    ];
diff --git a/.conkerorrc/flashblock.js b/.conkerorrc/flashblock.js
new file mode 100644 (file)
index 0000000..dc765f5
--- /dev/null
@@ -0,0 +1,6 @@
+// load stylesheets in ./css
+
+let (sheet = get_home_directory()) {
+    sheet.appendRelativePath(".conkerorrc/stylesheets/flashblock.css");
+    register_user_stylesheet(make_uri(sheet));
+}
\ No newline at end of file
index 9b2398b..4134df7 100644 (file)
@@ -86,3 +86,42 @@ interactive("set-proxy-type", "Change the proxy type or turn proxies off",
     user_pref("network.proxy.type", proxytype);
   }
 );
+
+var minibuffer_history_file = make_file("~/.conkerorrc/.minibuffer-history.json");
+
+function save_minibuffer_history () {
+    var mr_json = Cc["@mozilla.org/dom/json;1"]
+        .createInstance(Ci.nsIJSON);
+    var str = mr_json.encode(minibuffer_history_data);
+    write_text_file(minibuffer_history_file, str);
+}
+
+function load_minibuffer_history () {
+    var mr_json = Cc["@mozilla.org/dom/json;1"]
+        .createInstance(Ci.nsIJSON);
+    var data = mr_json.decode(read_text_file(minibuffer_history_file));
+    minibuffer_history_data = data;
+}
+
+// From technomancy
+interactive("toggle-stylesheets",
+            "Toggle whether conkeror uses style sheets (CSS) for the " +
+            "current buffer. It is sometimes useful to turn off style " +
+            "sheets when the web site makes obnoxious choices.",
+            function(I) {
+              var s = I.buffer.document.styleSheets;
+              for (var i = 0; i < s.length; i++)
+                s[i].disabled = !s[i].disabled;
+            });
+
+let(st_on = false) {
+  function toggle_custom_stylesheet(str) {
+    if (!st_on) {
+      register_user_stylesheet(str);
+    } else {
+      unregister_user_stylesheet(str);
+    };
+    st_on = !st_on;
+  };
+};
+
diff --git a/.conkerorrc/hide-minibuffer.js b/.conkerorrc/hide-minibuffer.js
new file mode 100644 (file)
index 0000000..68960e8
--- /dev/null
@@ -0,0 +1,60 @@
+///
+/// Auto-hide Minibuffer
+///
+
+var minibuffer_autohide_timer = null;
+var minibuffer_autohide_message_timeout = 3000; //milliseconds to show messages
+var minibuffer_mutually_exclusive_with_mode_line = true;
+
+function hide_minibuffer (window) {
+    window.minibuffer.element.collapsed = true;
+    if (minibuffer_mutually_exclusive_with_mode_line && window.mode_line)
+        window.mode_line.container.collapsed = false;
+}
+
+function show_minibuffer (window) {
+    window.minibuffer.element.collapsed = false;
+    if (minibuffer_mutually_exclusive_with_mode_line && window.mode_line)
+        window.mode_line.container.collapsed = true;
+}
+
+add_hook("window_initialize_hook", hide_minibuffer);
+// for_each_window(hide_minibuffer); // initialize existing windows
+
+
+var old_minibuffer_restore_state = (old_minibuffer_restore_state ||
+                                    minibuffer.prototype._restore_state);
+minibuffer.prototype._restore_state = function () {
+    if (minibuffer_autohide_timer) {
+        timer_cancel(minibuffer_autohide_timer);
+        minibuffer_autohide_timer = null;
+    }
+    if (this.current_state)
+        show_minibuffer(this.window);
+    else
+        hide_minibuffer(this.window);
+    old_minibuffer_restore_state.call(this);
+};
+
+var old_minibuffer_show = (old_minibuffer_show || minibuffer.prototype.show);
+minibuffer.prototype.show = function (str, force) {
+    var w = this.window;
+    show_minibuffer(w);
+    old_minibuffer_show.call(this, str, force);
+    if (minibuffer_autohide_timer)
+        timer_cancel(minibuffer_autohide_timer);
+    minibuffer_autohide_timer = call_after_timeout(
+        function () { hide_minibuffer(w); },
+        minibuffer_autohide_message_timeout);
+};
+
+var old_minibuffer_clear = (old_minibuffer_clear || minibuffer.prototype.clear);
+minibuffer.prototype.clear = function () {
+    if (minibuffer_autohide_timer) {
+        timer_cancel(minibuffer_autohide_timer);
+        minibuffer_autohide_timer = null;
+    }
+    if (! this.current_state)
+        hide_minibuffer(this.window);
+    old_minibuffer_clear.call(this);
+};
index 4d1daa7..85800ba 100644 (file)
@@ -112,3 +112,8 @@ define_key(read_buffer_keymap, "C-S-tab", "minibuffer-complete-previous");
 define_key(default_global_keymap, "A-return", "switch-to-recent-buffer");
 define_key(read_buffer_keymap, "A-return", "minibuffer-complete");
 define_key(read_buffer_keymap, "A-S-return", "minibuffer-complete-previous");
+
+// - History Search
+define_key(content_buffer_normal_keymap, "h", "find-url-from-history-new-buffer");
+define_key(content_buffer_normal_keymap, "H", "find-url-from-history");
+
index 937b71a..516862d 100644 (file)
@@ -8,12 +8,13 @@ mode_line_add_buttons(standard_mode_line_buttons, true);
 
 // we'd like to see the # of buffers being loaded 
 // favicons hook
-//add_hook("mode_line_hook", mode_line_adder(buffer_icon_widget), true);
+add_hook("mode_line_hook", mode_line_adder(buffer_icon_widget), true);
 add_hook("mode_line_hook", mode_line_adder(loading_count_widget), true);
 add_hook("mode_line_hook", mode_line_adder(buffer_count_widget), true);
 add_hook("mode_line_hook", mode_line_adder(loading_count_widget), true);
 add_hook("mode_line_hook", mode_line_adder(buffer_count_widget), true);
-
+add_hook("mode_line_hook", mode_line_adder(zoom_widget));
+add_hook("mode_line_hook", mode_line_adder(downloads_status_widget));
 
 // we don't need a clock
 remove_hook("mode_line_hook", mode_line_adder(clock_widget));
diff --git a/.conkerorrc/themeblack.js b/.conkerorrc/themeblack.js
new file mode 100644 (file)
index 0000000..ff02641
--- /dev/null
@@ -0,0 +1,213 @@
+/* ---------------------------
+Make sure you press K to activate dark theme
+color-theme based on @scottjad
+------------------------------ */
+
+// - Stylesheet
+// register_user_stylesheet(
+//    make_css_data_uri(["#minibuffer, .mode-line {font-family: Droid Sans; font-size: 12px;}",
+//                     "#minibuffer-prompt {background: black; color: #93e0e3;}"],
+//                    $namespace = XUL_NS));
+
+
+//register_user_stylesheet(
+//    make_css_data_uri(
+//        ["select,option,input { color: #bbb !important; background-color: #333 !important; }"+
+//         "code, pre { font-family: DejaVu Sans Mono !important; "+
+//         "font-size: 12px !important; }"+
+//         "span.__conkeror_hint {"+
+//         " line-height: 14px !important;"+
+//         ' font-family: Droid !important; '+
+//         ' padding: 1px !important;'+
+         // ' font-weight: normal !important;'+
+         // ' color: green !important; '+
+//         " font-size: 10px !important;"+
+//         "}\n"]));
+
+// toggle dark mode, adapted from philjackson's darken function
+color_theme_toggle = {};
+
+function global_color_theme(name, key, styles) {
+    interactive_cmd = "toggle-" + name + "-mode";
+    color_theme_toggle[name] = false;
+    interactive(interactive_cmd, "",
+                function (I) {
+                    if (color_theme_toggle[name]) {
+                        for(x in styles) {
+                            unregister_user_stylesheet(styles[x]);
+                        }
+
+                        color_theme_toggle[name] = false;
+                    } else {
+                        for(x in styles) {
+                            register_user_stylesheet(styles[x]);
+                        }
+                        color_theme_toggle[name] = true;
+                    }
+                });
+    define_key(default_global_keymap, key, interactive_cmd);
+}
+
+global_color_theme(
+    "dark", "K",
+    [make_css_data_uri(
+        ['*:not(img) {'+
+         // 'h1, h2, p, a, div, span, table, td, th tr, ul, li, strong, input, select, textarea, body {'+
+         'font-style: normal !important;'+ // italics is hard to read with gohu
+         'background: #303030 !important;'+
+         'color: #cccccc !important; '+
+         'text-shadow: 0px 0px 0px black !important;'+ // fix ugly shadows
+         'letter-spacing: 0 !important;'+ // don't scrunch words
+         // '*:not(img) { background: #262626 !important; '+
+         // 'color: #f6f3e8 !important; '+
+         // 'color: #686868 !important; '+
+         'font-family: Droid Sans !important; '+
+          'font-size: 10pt !important; '+
+         '-moz-border-bottom-colors: #444 #444 !important; '+
+         '-moz-border-top-colors: #444 #444 !important; '+
+         '-moz-border-right-colors: #444 #444 !important; '+
+         '-moz-border-left-colors: #444 #444 !important; '+
+         'box-shadow: 0 0 0 black !important; '+
+         '-moz-box-shadow: 0 0 0 black !important; '+
+         'border-color: #444 !important; '+
+         'text-decoration: none !important;'+
+         // inventing on principles
+         // 'color: #abb1ad !important; '+
+         // 'background: #454545 !important;'+
+         ' }',
+         'p { line-height: 100% !important; }',
+         'code, pre, code *, pre * { color: #f6f3e8 !important; background-color: #353535 !important; }',
+         ':link, :link * { color: #8ac6f2 !important}',
+         ':visited, :visited * { color: #95e454 !important}',
+         'h1,h2,h3,h4,h5,h6 { color: white !important}',
+         '.literallink:link { color: #3afdff !important; background-color: #008b8b !important; text-decoration: none !important}',
+         '.literallink:visited { color: #ff57fd !important; background-color: darkmagenta !important; text-decoration: none !important}' ,
+         'em { background-color: #444444 !important;}',
+         // form elements
+         'input:focus, textarea:focus { '+
+         // + 'color: #dd4ca7 !important; '
+         // 'background-color: blue !important; '+
+         // 'border-color: red !important; '+
+         'border: solid 1px red !important; '+
+         // 'background-image: -moz-linear-gradient(top left, #5b9602 0%, #334502 100%) !important; '+
+         ' }',
+         // submit button
+         'input[type="submit"]:hover { }',
+         'input[type="submit"]:focus { }',
+
+         // youtube html5 player
+         'div#watch-video-container *, div#video-player-html5 * { background-color: transparent !important; }',
+
+         // brown
+         // '*:not(img) { color: #eeddcc !important; '+
+         // 'background: #472d1e !important; }',
+         // ':link, :link * { color: #66bbff !important}',
+         // ':visited, :visited * { color: #aabb00 !important}',
+         // 'h1,h2,h3,h4,h5,h6 { color: #aa8866 !important}',
+         // 'code, pre, code *, pre * { color: #ba9 !important; background-color: #1c1008 !important; }',
+
+         'span.__conkeror_hint {'+
+         // 'background-color: #104e8b !important;'+
+         'color: white !important;'+
+         // + 'font-family: GohuFont !important;'
+         // + 'line-height: 14px !important;'
+         'font-size: 14px !important;'+
+         '}'
+         ], $url_prefixes = ["http", "about"]),
+
+     make_css_data_uri(
+         ['em { background-color: #444444 !important;}'
+         ], $url_prefixes = ["http://www.google.com/reader"]),
+
+     make_css_data_uri(
+         ['.vh { color: white; '+
+          'background-color: #444 !important;}',
+          '.TC { border-width: 0px !important; }', // remove extra lines on inbox
+          '.xY { height: 10pt !important; }', // keep message list from being too tall
+          // '.oZ-jd,.hF,.hG,', // old cursor class
+          'div.ar, div.as { display: none !important; }', // hide labels
+          'td.bAIpgd.aAotqb, td.PF.xY.PE { background: red !important;}', // make cursor red
+
+          // 'div.tk3N6e-Jo-qE2ISc { display: none !important;}', // checkbox unchecked
+          // 'div.T-Jo-Jp { display: visible !important; color: blue !important }', // checkbox checked
+          // 'tr.x7 { background-color: blue !important }', // checkbox checked
+          // 'div.oZ-x3 { display: none !important; }', // hide checkbox
+
+          'div.gs { margin-left: 0px !important; }', // message spacing from avatar
+          'div.X9rihb { display: none !important; }', // avatar
+          'div.J-J5-Ji { }', // search box
+          'div.no { none !important; }', // top bar with gmail and search box
+          'td.GcwpPb-uq0Mrf { display: none !important; }', // search button
+          '.im { color: #99968b !important;}', // quoted text
+          'span.hP { color: #ff5996 !important;}', // subject: message view title
+          'span.h4 { color: #777 !important;}', // show quoted text link
+          '.gG { color: #777 !important;}', // show details header names
+          '.nr { color: #8ac6f2 !important;}',
+          // hide
+          'table.Bs tr td.Bu:nth-child(3),'+ // side area (ads etc)
+          // '.gB table,'+ // reply and forward buttons
+          '.hj,'+ // popout, print, etc buttons
+          '.D,'+ // button bar
+          'table.hX,'+ // tags on top of message view
+          '.av,'+ // tags in message list
+          '.T8uMgc,'+ // chat area
+          '.VP5otc-U4m8q,'+ // bottom button bar
+          '.l2,.ov,'+ // bottom info
+          '#gb'+ // google bar
+          ' { display: none !important;}'
+         ], $domains = "mail.google.com"),
+
+     make_css_data_uri(
+         [':link img { border: dashed 1px #008b8b !important; margin: 5px !important; }',
+          ':visited img { border: dashed 1px darkmagenta !important; margin: 5px !important; }'
+         ], $domains = ["bbs.archlinux.org",
+                        "crunchbanglinux.org"]),
+
+     make_css_data_uri(
+         ['#entries { padding-left: 5px !important; padding-right: 5px !important; }', // don't add padding on left side
+          'div#current-entry div.card { border: solid 2px #8968cd !important;} ',
+          'div#current-entry div.card:-moz-window-inactive { border-color: #777 ! important; }',
+          '#message-area-container { display: none !important; }',
+          "#message-area-container div.goog-inline-block { display: none !important: }",
+          "div.section-minimize { display: none !important; }",
+          '.entry { background-color: #444 !important; }',
+          // hide
+          '#viewer-footer, '+ // next prev buttons
+          '#chrome-header, '+ // tag name, expanded/list
+          '#viewer-header-container, '+ // showing new items, mark and folder buttons
+          '#top-bar,'+ // logo and search
+          "#lhn-recommendations,"+ // explore sidebar
+          "#lhn-friends,"+ // followers sidebar
+          "#overview-selector,"+ // home
+          "#your-items-tree-container,"+ // your stuff, shared items
+          "#trends-selector,"+ // trends
+          "#directory-selector,"+ // browse for stuff
+          ".entry-actions,"+ // browse for stuff
+          "#gb,"+ // google bar
+          '#title-and-status-holder,'+ // all items, sort by
+          '.card-actions,'+ // social links
+          '#scroll-filler-recs-message'+ // no more articles message
+          '{ display: none !important;}'
+         ], $url_prefixes = ["http://www.google.com/reader",
+                             "https://www.google.com/reader"]),
+
+     make_css_data_uri(
+         [".current { border: solid 2px #8968cd !important; }"+
+          "td.default { border :solid 2px transparent !important; }"+
+          ".current-comment > td.default { border: solid 2px #8968cd !important; }"
+         ], $domains = ["news.ycombinator.com"]),
+
+     make_css_data_uri(
+         ['.k { font-weight: bold !important }', // keyword
+          'a, h1, code, pre {text-shadow: 0px 0px 0px black !important; }', // ugly shadows
+          // named builtin? .nb named function .nf
+          // commented cause gh's clojure highlighting marks lots of the code with this
+          // '.nv { color: #ff5996 !important } ', // function name/variable name
+          '.nv { color: #aaa !important } ', // function name/variable name
+          '.s { color: #95e454 !important } ', // string
+          '.c1 { color: #99968b !important; '+
+          'font-style: normal !important; }', // comment
+          '.x { background-color: #666666 !important }', // added/deleted portion
+          '.gi, .gi .x { color: #1AFF84 !important }', // inserted line
+          '.gd, .gd .x { color: #ff0080 !important }' // deleted line
+         ], $domains = "github.com")]);
diff --git a/.conkerorrc/ua.js b/.conkerorrc/ua.js
new file mode 100644 (file)
index 0000000..d660ac7
--- /dev/null
@@ -0,0 +1,22 @@
+// user agent switcher
+// source: https://github.com/technomancy/dotfiles/blob/master/.conkerorrc
+//
+ var user_agents = { "conkeror": "Mozilla/5.0 (X11; Linux x86_64; rv:8.0.1) " +
+                    "Gecko/20100101 conkeror/1.0pre",
+                  "chromium": "Mozilla/5.0 (X11; U; Linux x86_64; en-US) " +
+                    "AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63" +
+                    " Safari/534.3",
+                  "firefox": "Mozilla/5.0 (X11; Linux x86_64; rv:8.0.1) " +
+                  "Gecko/20100101 Firefox/8.0.1",
+                  "android": "Mozilla/5.0 (Linux; U; Android 2.2; en-us; " +
+                  "Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like " +
+                  "Gecko) Version/4.0 Mobile Safari/533.1"};
+                           
+  var agent_completer = prefix_completer($completions = Object.keys(user_agents));
+ interactive("user-agent", "Pick a user agent from the list of presets",
+            function(I) {
+                var ua = (yield I.window.minibuffer.read(
+                    $prompt = "Agent:",
+                    $completer = agent_completer));
+                set_user_agent(user_agents[ua]);
+            });