152 lines
5.9 KiB
JavaScript
152 lines
5.9 KiB
JavaScript
require("favicon");
|
|
|
|
theme_load_paths.push("/home/slash/.conkerorrc/themes/");
|
|
|
|
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 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_escape(str) {
|
|
return str.replace(/(["$`])/g, '\\$1');
|
|
}
|
|
|
|
function oni_linkwave_add(I) {
|
|
check_buffer(I.buffer, content_buffer);
|
|
let url =
|
|
load_spec_uri_string(load_spec(I.buffer.top_frame));
|
|
let title = escape(yield I.minibuffer.read(
|
|
$prompt = "name (required): ",
|
|
$initial_value = I.buffer.title));
|
|
let tags = escape(yield I.minibuffer.read(
|
|
$prompt = "tags (space delimited): "));
|
|
let description = escape(yield I.minibuffer.read(
|
|
$prompt = "extended description: "));
|
|
let command =
|
|
'/home/slash/development/projects/linkwave/src/linkwave "'
|
|
+ url + '" "' + title + '" "' + description + '"';
|
|
I.window.minibuffer.message(command);
|
|
}
|
|
interactive("linkwave-add", "Bookmark the page in linkwave",
|
|
oni_linkwave_add);
|
|
|
|
function oni_linkwave_add_link(I) {
|
|
bo = yield read_browser_object(I);
|
|
let url = load_spec_uri_string(
|
|
load_spec(encodeURIComponent(bo)));
|
|
check_buffer(I.buffer, content_buffer);
|
|
let title = escape(yield I.minibuffer.read(
|
|
$prompt = "name (required): ",
|
|
$initial_value = bo.textContent));
|
|
let tags = escape(yield I.minibuffer.read(
|
|
$prompt = "tags (space delimited): "));
|
|
let description = escape(yield I.minibuffer.read(
|
|
$prompt = "extended description: "));
|
|
let command =
|
|
'/home/slash/development/projects/linkwave/src/linkwave "'
|
|
+ url + '" "' + title + '" "' + description + '"';
|
|
let result = yield shell_command(command);
|
|
|
|
if (!result)
|
|
I.window.minibuffer.message('Added to linkwave');
|
|
else
|
|
I.window.minibuffer.message('Couldn\'t add to linkwave');
|
|
}
|
|
interactive("linkwave-add-link", "Bookmark the a link in linkwave",
|
|
oni_linkwave_add_link);
|
|
|
|
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",
|
|
"http://www.google.com/cse?cx=004774160799092323420%3A6-ff2s0o6yi&q=%s",
|
|
$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-arhives.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");
|
|
// 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");
|
|
|
|
cwd = make_file("/home/slash/downloads/");
|
|
url_remoting_fn = load_url_in_new_buffer;
|
|
read_buffer_show_icons = true;
|
|
hint_digits = "arstdhneio";
|
|
|
|
define_key(content_buffer_normal_keymap, "h",
|
|
"find-url-from-history-new-buffer");
|
|
define_key(content_buffer_normal_keymap, "H",
|
|
"find-url-from-history");
|
|
define_key(default_base_keymap, "C-x f", "follow-new-buffer");
|
|
|
|
add_hook("before_quit_hook", oni_before_quit_func);
|
|
add_hook("mode_line_hook", mode_line_adder(buffer_count_widget, true));
|
|
add_hook("mode_line_hook", mode_line_adder(buffer_icon_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("naquadah");
|