Skip to content

Instantly share code, notes, and snippets.

@nyameko
Created December 12, 2016 08:24
Show Gist options
  • Save nyameko/55fb083492bd27d5000b991659f5128b to your computer and use it in GitHub Desktop.
Save nyameko/55fb083492bd27d5000b991659f5128b to your computer and use it in GitHub Desktop.

Credits

Org Tangle javascript file

Stack Exchange Org Tangle Source Question Using Emacs org-mode babel to tangle the source blocks and create a javascript file.

Run C-c C-c on the #+KEYWORD to trigger scanning of the buffer special code blocks and updating the information. i.e. once must run it on the line with #+PROPERTY: tangle key-word to refresh local setup.

Finally tangle the entire file with C-c C-v t

Default debugging test to ensure everything

dumpln("hello, world!");

Temporary Proxy

Will need to have this automated eventually, or rather must finalize Raspberry Pi Remote Proxy Ham, or use Proxy PAC File

// proxy_server_default = "proxy.name.com";
// proxy_port_default = 80;

Suppress Errors by default

kmicu from the IRC #conkeror channel

user_pref("javascript.options.showInConsole", false);
user_pref("devtools.errorconsole.deprecation_warnings", false);
user_pref("datareporting.healthreport.logging.consoleEnabled", false);
// user_pref("datareporting.healthreport.logging.consoleLevel", "Warn");
user_pref("datareporting.healthreport.logging.consoleLevel", "Error");
// user_pref("datareporting.healthreport.logging.dumpLevel", "Debug");
user_pref("browser.dom.window.dump.enabled", false);
user_pref("javascript.options.strict", false);
user_pref("extensions.logging.enabled", false);
user_pref("services.sync.log.logger.addonutils", "Error");
user_pref("services.sync.log.logger.engine.addons", "Error");

Session, Style and Appearance

Theme and Homepage

Allow for contrib stuff

var themes = "~/.conkerorrc/theme";
load_paths.unshift("chrome://conkeror-contrib/content");
theme_load_paths.unshift(themes);
theme_unload("default");
theme_load("conkeror-theme-zenburn");

// Learn something new everyday
homepage = "http://en.wikipedia.org/wiki/Special:Random";

Open New Buffers in Background, Instead of New Windows

When opening URLs from GNU Emacs, open them in new buffer. And open new buffers in the background

require ("new-tabs.js");
require ("clicks-in-new-buffer.js");
url_remoting_fn = load_url_in_new_buffer;

Session and History Settings

Enable auto save session and make it load automatically on startup. h

require("session.js");
session_auto_save_auto_load = true;
session_pref('browser.history_expire_days', 60);

Disable Password Manager

Use keypass instead

// This is the default anyway
//session_pref("signon.rememberSignons", false);

BUSY Modeline

Widgets

Disable clock widget, and enable all others

require("mode-line.js");

remove_hook("mode_line_hook", mode_line_adder(clock_widget));

add_hook("mode_line_hook", mode_line_adder(buffer_icon_widget), true);
add_hook("mode_line_hook", mode_line_adder(current_buffer_name_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));

Favicon

Activate the favicon widget within the modeline, for displaying favicons anywhere

require("favicon.js");
add_hook("mode_line_hook", mode_line_adder(buffer_icon_widget), true);
read_buffer_show_icons = true;

Hinting

Hinting number associated with follow command. Number 0 refers to current URL. And hints-quote-next permits entry of number character as search refinement text.

c 0copy the current URL
C-u f 0open background buffer with the current URL
x 0open current document with an external program
C-q “num”hints-quote-next

Display the URL of a link in hints mode as well as any information about the currently selected link. Uncomment the line below to enable home-row letters as hint digits

hints_display_url_panel = true;
hints_minibuffer_annotation_mode(true);
//hint_digits="asdfghjkl";

Nyan Cat in Modeline

Default Zoom Level

function my_zoom_set (buffer) {
    browser_zoom_set(buffer, true, 150);
    browser_zoom_set(buffer, false, 100);
}
add_hook('create_buffer_late_hook', my_zoom_set);

Downloads and External Programs

The following settings are for Handling Downloads, Torrent Files and Various Mime Types in Conkeror

Downloads

Set the default download directory and don’t use a new window for downloads

cwd = get_home_directory();
cwd.append("Downloads");
download_buffer_automatic_open_target=OPEN_NEW_BUFFER_BACKGROUND;

To stop a download buffer from ever opening automatically, uncomment the following

remove_hook("download_added_hook", open_download_buffer_automatically);

External Emacsclient Editor

Copy Selection to Emacs Kill-Ring

Tips - Conkeror.org

interactive(
    "ekr_cmd_copy",
    "Copy the selection to the clipboard and the Emacs kill ring",
    function (I) {
        call_interactively(I, "cmd_copy")
        var cc = read_from_x_primary_selection();
        cc = cc.replace(/([^\\]*)\\([^\\]*)/g, "$1\\\\$2");
        cc = cc.replace('"', '\\"', "g");
        cc = cc.replace("'", "'\\''", "g");
        var ecc = "emacsclient -e '(kill-new \"" + cc + "\")' > /dev/null";
        shell_command_blind(ecc);
    }
);
undefine_key(caret_keymap,"M-w");
define_key(caret_keymap,"M-w", "ekr_cmd_copy");
undefine_key(content_buffer_normal_keymap,"M-w");
define_key(content_buffer_normal_keymap,"M-w", "ekr_cmd_copy");
undefine_key(special_buffer_keymap,"M-w");
define_key(special_buffer_keymap,"M-w", "ekr_cmd_copy");
undefine_key(text_keymap,"M-w");
define_key(text_keymap,"M-w", "ekr_cmd_copy");

Org-Mode Integration

orgmode.org org-protocol, emacs-fu, puntoblogspot(well-after-month-of-no-activity-in-this) oremacs my

Connect to the existing Emacs session when view source code

// editor_shell_command = "emacsclient -c -a emacs";
editor_shell_command = "emacsclient -c -a \"\"";
view_source_use_external_editor = true;

// org-protocol

// simplified, neater wrapper function

function org_capture_wrapper (url, title, selection, window, cmd_str) {
    if (window != null) {
        window.minibuffer.message('Issuing ' + cmd_str);
    }
    shell_command_blind(cmd_str);
}
function org_capture (url, title, selection, window) {
    var cmd_str =
            'emacsclient \"org-protocol://capture:/w/'+url+'/'+title+'/'+selection+'\"';
    org_capture_wrapper(url,title,selection,window,cmd_str);
}
function org_store_link (url, title, window) {
    var cmd_str =
            'emacsclient \"org-protocol:/store-link:/'+url+'/'+title+'\"';
    if (window != null) {
        window.minibuffer.message('Issuing ' + cmd_str);
    }
    shell_command_blind(cmd_str);
}
function org_capture_journal (url, title, selection, window) {
    var cmd_str = 'emacsclient \"org-protocol://capture:/j/'+url+'/'+title+'\"';
    if (window != null) {
        window.minibuffer.message('Issuing ' + cmd_str);
    }
    shell_command_blind(cmd_str);
}
function org_capture_kaizen (url, title, selection, window) {
    var cmd_str = 'emacsclient \"org-protocol://capture:/k/'+url+'/'+title+'\"';
    if (window != null) {
        window.minibuffer.message('Issuing ' + cmd_str);
    }
    shell_command_blind(cmd_str);
}
function org_capture_emacs (url, title, selection, window) {
    var cmd_str = 'emacsclient \"org-protocol://capture:/e/'+url+'/'+title+'\"';
    if (window != null) {
        window.minibuffer.message('Issuing ' + cmd_str);
    }
    shell_command_blind(cmd_str);

}
function org_capture_devenv (url, title, selection, window) {
    var cmd_str = 'emacsclient \"org-protocol://capture:/d/'+url+'/'+title+'\"';
    if (window != null) {
        window.minibuffer.message('Issuing ' + cmd_str);
    }
    shell_command_blind(cmd_str);

}
function org_capture_code (url, title, selection, window) {
    var cmd_str = 'emacsclient \"org-protocol://capture:/p/'+url+'/'+title+'\"';
    if (window != null) {
        window.minibuffer.message('Issuing ' + cmd_str);
    }
    shell_command_blind(cmd_str);

}
function org_capture_course (url, title, selection, window) {
    var cmd_str = 'emacsclient \"org-protocol://capture:/c/'+url+'/'+title+'\"';
    if (window != null) {
        window.minibuffer.message('Issuing ' + cmd_str);
    }
    shell_command_blind(cmd_str);

}
function org_capture_monopoly (url, title, selection, window) {
    var cmd_str = 'emacsclient \"org-protocol://capture:/m/'+url+'/'+title+'\"';
    if (window != null) {
        window.minibuffer.message('Issuing ' + cmd_str);
    }
    shell_command_blind(cmd_str);

}
interactive("org-capture", "Clip URL, title and selection to capture via org-protocol",
            function (I) {
                org_capture(encodeURIComponent(I.buffer.display_uri_string),
                                 encodeURIComponent(I.buffer.document.title),
                                 encodeURIComponent(I.buffer.top_frame.getSelection()),
                                 I.window);
            });
interactive("org-store-link", "Stores [[url][title]] as org link and copies url to emacs kill ring",
            function (I) {
                org_store_link(encodeURIComponent(I.buffer.display_uri_string),
                               encodeURIComponent(I.buffer.document.title),
                               I.window);
            });
interactive("org-capture-journal", "Journal",
            function (I) {
                org_capture_journal(encodeURIComponent(I.buffer.display_uri_string),
                                 encodeURIComponent(I.buffer.document.title),
                                 encodeURIComponent(I.buffer.top_frame.getSelection()),
                                 I.window);
            });
interactive("org-capture-kaizen", "Kaizen - Self Enlightenment",
            function (I) {
                org_capture_kaizen(encodeURIComponent(I.buffer.display_uri_string),
                                 encodeURIComponent(I.buffer.document.title),
                                 encodeURIComponent(I.buffer.top_frame.getSelection()),
                                 I.window);
            });
interactive("org-capture-emacs", "Emacs",
            function (I) {
                org_capture_emacs(encodeURIComponent(I.buffer.display_uri_string),
                                 encodeURIComponent(I.buffer.document.title),
                                 encodeURIComponent(I.buffer.top_frame.getSelection()),
                                 I.window);
            });
interactive("org-capture-devenv", "Development Environment",
            function (I) {
                org_capture_devenv(encodeURIComponent(I.buffer.display_uri_string),
                                 encodeURIComponent(I.buffer.document.title),
                                 encodeURIComponent(I.buffer.top_frame.getSelection()),
                                 I.window);
            });
interactive("org-capture-code", "Programming and Code",
            function (I) {
                org_capture_code(encodeURIComponent(I.buffer.display_uri_string),
                                 encodeURIComponent(I.buffer.document.title),
                                 encodeURIComponent(I.buffer.top_frame.getSelection()),
                                 I.window);
            });
interactive("org-capture-course", "Chow Course",
            function (I) {
                org_capture_course(encodeURIComponent(I.buffer.display_uri_string),
                                 encodeURIComponent(I.buffer.document.title),
                                 encodeURIComponent(I.buffer.top_frame.getSelection()),
                                 I.window);
            });
interactive("org-capture-monopoly", "Monopolize the 1%",
            function (I) {
                org_capture_monopoly(encodeURIComponent(I.buffer.display_uri_string),
                                 encodeURIComponent(I.buffer.document.title),
                                 encodeURIComponent(I.buffer.top_frame.getSelection()),
                                 I.window);
            });

BUSY Automatically Associate Files Types

Pdf Files

content_handlers.set("application/pdf", content_handler_open_default_viewer);
external_content_handlers.set("application/pdf", "evince");

Office Documents

external_content_handlers.set(
    "application/vnd.ms-excel",
    "libreoffice"
);
external_content_handlers.set(
    "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
    "libreoffice"
);
external_content_handlers.set(
    "application/vnd.openxmlformats-officedocument.presentationml.presentation",
    "libreoffice"
);
external_content_handlers.set(
    "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
    "libreoffice"
);

Magnet Links and Torrent Files

//set_protocol_handler("magnet", find_file_in_path("deluge-gtk"));
//content_handlers.set("application/x-bittorrent", content_handler_open);
//external_content_handlers.set("application/x-bittorrent", "deluge-gtk");
content_handlers.set("application/x-bittorrent", content_handler_save);

Emacs mu4e Mail Handler

set_protocol_handler("mailto", make_file("~/bin/handle-mailto"));

Extensions

Disable extension compatibility checking, Allow installation of extensions from any source and Enable security updates

session_pref('extensions.checkCompatibility', false);
session_pref("xpinstall.whitelist.required", false);
user_pref("extensions.checkUpdateSecurity", true);

Firebug

/*define_variable("firebug_url",
    "http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js");*/
define_variable("firebug_url",
    "http://getfirebug.com/releases/lite/1.4/firebug-lite.js");

function firebug (I) {
    var doc = I.buffer.document;
    var script = doc.createElement('script');
    script.setAttribute('type', 'text/javascript');
    script.setAttribute('type', firebug_url);
    script.setAttribute('type', 'firebug.init();');
    doc.body.appendChild(script);
}
interactive("firebug", "open firebug lite", firebug);

Https-Everywhere

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);
                });
}

Adblock-Plus

require("adblockplus");

Page-Modes

require("reddit");
require("gmail");
require("feedly");
require("twitter");

Sqlite Manager

Needs the sqlitemanager xpi installed

interactive("sqlite-manager",
            "Open SQLite Manager window.",
            function (I) {
                make_chrome_window('chrome://SQLiteManager/content/sqlitemanager.xul');
            });

Webjumps

  • NEED TO TEST MODE ACTIVATION *

See Conkeror Webjumps List

Bookmarks and Smartlinks can be navigated using g, for by the short string representing the webjump. In addition, SmartLinks can be suffix with additional string parameters that are passed to the webjump URL string with the %s parameter replaced by the string.

URL Completion

Use completion system for - bookmarks, webjumps and the minibuffer. Separate functions to call history url completion

url_completion_use_history = false;
url_completion_use_bookmarks = true;
url_completion_use_webjumps = true;
minibuffer_auto_complete_default = true;

Separate history from webjumps and bookmarks. h and H are used to find a URL from history in current buffer and in a new buffer respectively.

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);
        yield co_return (result);
    });

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_key(content_buffer_normal_keymap, "h", "find-url-from-history-new-buffer");
define_key(content_buffer_normal_keymap, "H", "find-url-from-history");

Make duckduckgo webjump the default action

read_url_handler_list = [read_url_make_default_webjump_handler("duckduckgo")];

Local Webjumps

define_webjump("mikrotik", "http://192.168.88.1");
define_webjump("netgear", "http://192.168.88.2");

General Technical Queries

Will need to add scopius / journal search entry Use V to vote on questions on StackExchange, StackOVerflow, ServerFault, SuperUser, etc

define_webjump("linux-questions","http://www.linuxquestions.org/questions/");
define_webjump("gmane", "http://gmane.org/find.php?list=%s");
// define_webjump("gwene", "http://gwene.org/",
//                $post_data = [['name', 'url'], ['value', '%s']],
//                $alternative = "http://gwene.org");
define_webjump("gwene",
    function (term) {
        return load_spec(
            { uri: "http://gwene.org/",
              post_data: make_post_data([['url', term]]) });
    },
    $alternative = "http://gwene.org");
define_webjump("hackernews", "http://searchyc.com/%s", $alternative = "http://news.ycombinator.com/");
define_webjump("slashdot", "http://slashdot.org/search.pl?query=%s");
define_webjump("stackexchange", "http://stackexchange.com/search?q=%s", $alternative = "http://stackexchange.com/");
define_webjump("stackoverflow", "http://stackoverflow.com/search?q=%s", $alternative = "http://stackoverflow.com/");
define_webjump("superuser", "http://superuser.com/search?q=%s", $alternative = "http://superuser.com/");
// free eBooks
define_webjump("gutenberg",
    function (term) {
        return load_spec(
            { uri: "http://www.gutenberg.org/ebooks/search/",
              post_data: make_post_data([['query', term]]) });
    },
    $alternative = "http://www.gutenberg.org/");

Reddit

See reddit mode Provides reddit mode cursor

BindingReddit_KeymapDescription
jreddit-nextMove cursor to next reddit entry or comment
Jreddit-next-parent-comment
kreddit-prev
Kreddit-prev-parent-comment
hreddit-open-comments
,reddit-vote-up
.reddit-vote-down
define_webjump("reddit", "http://www.reddit.com/search?q=%s", $alternative = "http://www.reddit.com/");
define_webjump("reddit/subreddit", "http://www.reddit.com/r/%s");

Unix / Linux

define_webjump("stackexchange/linux", "http://unix.stackexchange.com/search?q=%s", $alternative="http://unix.stackexchange.com");

Arch Linux

define_webjump("arch/forums", "http://bbs.archlinux.org");
define_webjump("arch/wiki", "http://wiki.archlinux.org/index.php?search=%s");
define_webjump("arch/aur", "http://aur.archlinux.org/packages.php?O=0&K=%s");
define_webjump("arch/packages",
               "https://www.archlinux.org/packages/?sort=&q=%s&limit=50",
               $alternative="https://packages.archlinux.org");

Distrowatch

define_webjump("distrowatch", "http://distrowatch.com/table.php?distribution=%s");

Programming

Emacs

define_webjump("emacswiki", "https://www.emacswiki.org/search?q=%s", $alternative="https://www.emacswiki.org/");
define_webjump("marmalade", "http://marmalade-repo.org/packages?q=%s");

Git

Use github-mode to install fallthrough bindings for github’s keyboard shortcuts as well as the following:

BindingDescription
?github-keyboard-shortcuts
sgithub-focus-site-search
/github-focus-issues-search
//require("github");
define_webjump("github", "http://github.com/search?q=%s&type=Everything");

Bash

define_webjump("bashfaq", "http://mywiki.wooledge.org/BashFAQ?action=fullsearch&context=180&value=%s&fullsearch=Text",
               $alternative = "http://mywiki.wooledge.org/BashFAQ");
define_webjump("cmdlinefu",
               function(term) {
                   return 'http://www.commandlinefu.com/commands/matching/' +
                       term.replace(/[^a-zA-Z0-9_\-]/g, '')
                       .replace(/[\s\-]+/g, '-') +
                       '/' + btoa(term);
               },
               $alternative = "http://www.commandlinefu.com/");

Common Lisp

define_webjump("clhs",
               "http://www.xach.com/clhs?q=%s",
               $alternative = "http://www.lispworks.com/documentation/HyperSpec/Front/index.htm");
define_webjump("cliki", "http://www.cliki.net/admin/search?words=%s");

Perl

define_webjump("perldoc", "http://perldoc.perl.org/search.html?q=%s");
define_webjump("cpan", "http://search.cpan.org/search?query=%s&mode=all");
define_webjump("metacpan", "https://metacpan.org/search?q=%s");

Python

define_webjump("python", "http://docs.python.org/search.html?q=%s");
define_webjump("python3", "http://docs.python.org/3/search.html?q=%s", $alternative = "http://docs.python.org/3/search.html");

LaTeX

define_webjump("ctan/desc", "http://www.ctan.org/search/?search=%s&search_type=description");
define_webjump("ctan/file", "http://www.ctan.org/search/?search=%s&search_type=filename");
define_webjump("ctan/pack", "http://www.ctan.org/search/?search=%s&search_type=id");
define_webjump("ctan", "http://www.ctan.org/search/?search=%s&search_type=description&search_type=filename&search_type=id");
define_webjump("stackexchange/tex", "http://tex.stackexchange.com/search?q=%s", $alternative="http://tex.stackexchange.com");

Search Engine

Google

//require("google-maps");
//require("page-modes/google-maps.js");
define_webjump("google/za", "https://www.google.co.za/webhp?#q=%s&tbs=ctr:countryZA&cr=countryZA", $alternative="https://www.google.co.za/");
define_webjump("google/image", "https://www.google.com/images?q=%s&safe=off", $alternative = "https://www.google.com/imghp?as_q=&safe=off");
define_webjump("google/translate", "https://translate.google.com/translate_t#auto|en|%s");
define_webjump("google/scholar", "https://scholar.google.com/scholar?q=%s", $alternative = "https://scholar.google.com");
define_webjump("google/maps", "https://www.google.com/maps/place/%s", $alternative = "https://maps.google.com")

Urban Dictionary

define_webjump("urban", "http://www.urbandictionary.com/define.php?term=%s");

Web Of Science

define_webjump("webofscience", "http://apps.webofknowledge.com/");

Scopus

define_webjump("scopus", "https://www.scopus.com/");

Torrents, Usenet, Streams and Direct

1337x.to

define_webjump("1337x", "https://www.1337x.to/srch?search=%s");

Wikipedia

require("page-modes/wikipedia.js");
//wikipedia_webjumps_format = "wp-%s"; // controls the webjump names. default "wikipedia-%s"
define_wikipedia_webjumps("en"); // For English
//require("wikipedia-didyoumean");

Banking and Shopping

FNB

define_webjump("fnb", "https://www.fnb.co.za");

Amazon

define_webjump("amazon", "https://www.amazon.com/s/?url=search-alias%3Daps&field-keywords=%s", $alternative = "https://www.amazon.com/");

PriceCheck, eBucks and TakeAlot

define_webjump("pricecheck", "https://www.pricecheck.co.za/search?search=%s", $alternative = "https:/www.pricecheck.co.za/");
define_webjump("takealot/deals", "http://www.takealot.com/deals", $alternative = "https:/www.takealot.com/");
define_webjump("takealot", "http://www.takealot.com/all/?qsearch=%s&_sb=1&_dt=all&_r=1", $alternative = "https:/www.takealot.com/");
define_webjump("ebucks", "https://www.ebucks.com/web/shop/categorySelected.do?catId=291707128", $alternative = "https://www.ebucks.com/web/shop/shopHome.do")

Entertainment & Blogs

htxt

define_webjump("htxt", "http://www.htxt.co.za/");

LastFM

lastfm_user = "your username here";
define_webjump("lastfm", "http://www.last.fm/user/" + lastfm_user);
define_webjump("lastfm-music", "http://www.last.fm/search?m=all&q=%s");
define_webjump("lastfm-event", "http://www.last.fm/events/search?search=1&q=%s");
define_webjump("lastfm-tag", "http://www.last.fm/search?m=tag&q=%s");
define_webjump("lastfm-user", "http://www.last.fm/users?m=search&type=un&q=%s");
define_webjump("lastfm-group", "http://www.last.fm/users/groups?s_bio=%s");
define_webjump("lastfm-label", "http://www.last.fm/search?m=label&q=%s");

Rotten Tomatoes

define_webjump("rottentomatoes", "http://www.rottentomatoes.com/search/?search=%s");

xkcd

require("xkcd");
xkcd_add_title = true;

Youtube

define_webjump("youtube", "http://www.youtube.com/results?search_query=%s&search=Search");

Wordpress

define_webjump("wordpress", "http://wordpress.org/search/%s");

Remove Unused Webjumps

var unused_webjumps = ['answers', 'creativecommons', 'lucky', 'yahoo'];

for (var i=0; i<unused_webjumps.length; i++) {
    delete webjumps[unused_webjumps[i]];
}

Keyboard and Interface

Ignore Caps Lock

key_bindings_ignore_capslock = true;

Unbind Arrow Keys

undefine_key(content_buffer_normal_keymap, "up", "cmd_scrollLineUp");
undefine_key(content_buffer_normal_keymap, "down", "cmd_scrollLineDown");
undefine_key(content_buffer_normal_keymap, "left", "cmd_scrollLeft");
undefine_key(content_buffer_normal_keymap, "right", "cmd_scrollRight");

Buffer Tab Navigation

Make “l” open link in buffer background, and “M-f” and “M-b” are next and previous buffer respectively.

//define_key(content_buffer_normal_keymap, "C-u f", "follow-new-buffer-background");
undefine_key(content_buffer_normal_keymap, "l", "back");
define_key(content_buffer_normal_keymap, "l", "follow-new-buffer-background");
define_key(content_buffer_normal_keymap, "M-f", "buffer-next");
define_key(content_buffer_normal_keymap, "M-b", "buffer-previous");

Bind 1-0 Number Keys to Switch to Buffers 1-10

function define_switch_buffer_key (key, buf_num) {
    define_key(default_global_keymap, key,
               function (I) {
                   switch_to_buffer(I.window,
                                    I.window.buffers.get_buffer(buf_num));
               });
}
for (let i = 0; i < 10; ++i) {
    define_switch_buffer_key(String((i+1)%10), i);
}

Client Redirects

Mechanism by which Conkeror can automatically perform a defined redirection on configured urls and url patterns. I.e. used to ”skip” intermediary webpages when browsing and go straight to the content you want

require("client-redirect");

define_client_redirect(name, transform…); name - string naming redirect transform… - may be function or RegEx

Google Images

Skips “/imgres” page at Google Images

define_client_redirect("google-images",
                       function (uri) {
                           return /(images|www)\.google\.com$/.test(uri.host)
                               && uri.filePath == "/imgres"
                               && regexp_exec(/imgurl=([^&]+)/, uri.query, 1);
                       });

Imgur

define_client_redirect("imgur",
                       build_url_regexp($domain = "imgur", $path = /.*/),
                       function (m) {
                           return m[0].replace("//", "//i.")+".jpg";
                       });

Eye-Guide Scrolling

require('eye-guide.js');
define_key(content_buffer_normal_keymap, "space", "eye-guide-scroll-down");
define_key(content_buffer_normal_keymap, "back_space", "eye-guide-scroll-up");

Conkeror Goto-Buffer and Switch to Buffer List By Access Time

Source

interactive("rgc-goto-buffer", "Switches to buffer (tab number)",
            function rgc_switch_to_buffer(I){
                var buff = yield I.minibuffer.read( $prompt = "Tab number?:");
                switch_to_buffer(I.window, I.window.buffers.get_buffer(buff-1));
            });
interactive("switch-to-recent-buffer",
            "Prompt for a buffer and switch to it, displaying the list in last-visited order.",
            function (I) {
                switch_to_buffer(
                    I.window,
                    (yield I.minibuffer.read_buffer(
                        $prompt = "Switch to buffer:",
                        $buffers = I.window.buffers.buffer_history,
                        $default = (I.window.buffers.count > 1 ?
                                    I.window.buffers.buffer_history[1] :
                                    I.buffer))));
            });
define_key(content_buffer_normal_keymap, "M-g M-g", "rgc-goto-buffer");
define_key(content_buffer_normal_keymap, "C-x C-b", "switch-to-recent-buffer");

Confirm Quit / Kill Window

add_hook("window_before_close_hook",
         function () {
             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);
         });

Restore Killed Buffer URL

var kill_buffer_original = kill_buffer_original || kill_buffer;

var killed_buffer_urls = [];

kill_buffer = function (buffer, force) {
    if (buffer.display_uri_string) {
        killed_buffer_urls.push(buffer.display_uri_string);
    }

    kill_buffer_original(buffer,force);
};

interactive("restore-killed-buffer-url", "Loads URL from a previously killed buffer",
            function restore_killed_buffer_url (I) {
                if (killed_buffer_urls.length !== 0) {
                    var url = yield I.minibuffer.read(
                        $prompt = "Restore killed url:",
                        $completer = new all_word_completer($completions = killed_buffer_urls),
                        $default_completion = killed_buffer_urls[killed_buffer_urls.length - 1],
                        $auto_complete = "url",
                        $auto_compete_initial = true,
                        $auto_complete_delay = 0,
                        $require_match = true);

                    load_url_in_new_buffer(url);
                } else {
                    I.window.minibuffer.message("No killed buffer urls");
                }
            });

Clear Conkeror History

function history_clear () {
    var history = Cc["@mozilla.org/browser/nav-history-service;1"].getService(Ci.nsIBrowserHistory);
    history.removeAllPages();
}

interactive("history-clear", "Clear all history",
            history_clear);

Reload Conkeror.rc Config

Bind this to C-c r

interactive("reload-config", "Reload conkerorrc",
            function(I) {
                load_rc();
                I.window.minibuffer.message("config reloaded");
            });
define_key(default_global_keymap, "C-c r", "reload-config");

User Agent

User-agent is a string of text that browsers use to identify themselves to websites when making request.

Firefox Compat Mode

session_pref("general.useragent.compatMode.firefox", true);

Per-Site User-Agent-Policy

This is to try to mitigate Malformed webpages

require("user-agent-policy");

user_agent_policy.define_policy("default",
                                user_agent_firefox(),
                                "images.google.com",
                                build_url_regexp($domain = /(.*\.)?google/, $path = /images|search\?tbm=isch/),
                                "plus.google.com");

user_agent_policy.define_policy("firefoxcompatmode",
                                "Mozilla/5.0 (X11; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0 conkeror/1.0pre1",
                               "de.eurosport.yahoo.com")

User Agent Switcher

/*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]);
            });
*/

Reopen Closed Tabs

var my_killed_buffers = new Array();
// Save the URL of the current buffer before closing it.
interactive("my_save_url_then_kill_buffer",
            "Push URL of current buffer onto stack before closing it",
            function(I) {
                if(my_killed_buffers.length == 10){
                    my_killed_buffers.shift();
                    // Only store 10 most recently killed entries
                }
                my_killed_buffers.push(I.buffer.document.URL);
                kill_buffer(I.buffer);
            });
// Redefine kill buffer key
undefine_key(default_global_keymap, "q");
define_key(default_global_keymap, "q", "my_save_url_then_kill_buffer");
interactive("my_restore_last_killed_buffer",
            "Pop URL of last killed buffer from stack and open in new buffer.",
            function(I){
                if(my_killed_buffers.length > 0){
                    load_url_in_new_buffer(
                        my_killed_buffers[my_killed_buffers.length - 1], I.window);
                    my_killed_buffers.pop();
                }
            });
define_key(default_global_keymap, "Q", "my_restore_last_killed_buffer");

Org-Protocol

define_key(content_buffer_normal_keymap, "C-c c w", "org-capture");
define_key(content_buffer_normal_keymap, "C-c c l", "org-store-link");
define_key(content_buffer_normal_keymap, "C-c c j", "org-capture-journal");
define_key(content_buffer_normal_keymap, "C-c c k", "org-capture-kaizen");
define_key(content_buffer_normal_keymap, "C-c c e", "org-capture-emacs");
define_key(content_buffer_normal_keymap, "C-c c d", "org-capture-devenv");
define_key(content_buffer_normal_keymap, "C-c c p", "org-capture-code");
define_key(content_buffer_normal_keymap, "C-c c c", "org-capture-course");
define_key(content_buffer_normal_keymap, "C-c c m", "org-capture-monopoly");

Duplicate Buffers

interactive("duplicate-buffer", "Duplicate buffer",
            function (I) {
                browser_object_follow(I.buffer, OPEN_NEW_BUFFER, I.buffer.current_uri.spec);
            });
define_key(content_buffer_normal_keymap, "M-D", "duplicate-buffer");

Selection Searches Using Webjump Shortcuts

function create_selection_search(webjump, key) {
    interactive(webjump+"-selection-search",
                "Search " + webjump + " with selection contents",
                "find-url-new-buffer",
                $browser_object = function (I) {
                    return webjump + " " + I.buffer.top_frame.getSelection();}
               );
    interactive("prompted-"+webjump+"-search", null,
                function (I) {
                    var term = yield I.minibuffer.read_url($prompt = "Search "+webjump+":",
                                                           $initial_value = webjump+" ",
                                                           $select = false);
                    browser_object_follow(I.buffer, FOLLOW_DEFAULT, term);
                });
    define_key(content_buffer_normal_keymap, key.toUpperCase(), webjump + "-selection-search");
    define_key(content_buffer_normal_keymap, key, "prompted-" + webjump + "-search");
}
create_selection_search("google", "o");
create_selection_search("wikipedia", "w");
create_selection_search("duckduckgo", "d");
create_selection_search("amazon", "a");
create_selection_search("youtube", "y");

Completion of Configuration test

Comand Line Verification that configuration loaded successfully.

Do we make it to the end?

dumpln("Conkerror.rc Parsed Successfully...");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment