dotfiles/conkeror/.conkerorrc/init.org

3.6 KiB

Add commands to search through and open links from history.

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

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

Set the hints digits to the keys on my keyboard's home row, for easy access.

  hint_digits = "arstdhneio";

Add the search-engines/ directory to the opensearch load path.

  function add_to_opensearch_load_path(new_path) {
      if (new_path.startsWith('/')) {
          opensearch_load_paths.push(new_path);
      } else {
          let path = get_home_directory();
          path.append('.conkerorrc');
          path.append(new_path);

          opensearch_load_paths.push(path);
      }
  }

  add_to_opensearch_load_path('search-engines');

Add the site-js/ directory to the load path.

  function add_to_load_path(new_path) {
      if (new_path.startsWith('/')) {
          load_paths.push("file://" + new_path);
      } else {
          let path = get_home_directory();
          path.append('.conkerorrc');
          path.append(new_path);

          load_paths.push("file://" + path.path);
      }
  }

  add_to_load_path('site-js');

Scuttle

Load the scuttle module.

  require('scuttle');

Set the URL of my scuttle installation.

  scuttle_url = 'https://ryuslash.org/scuttle/';

Add the bookmarked widget to the mode line. This requires my customized version of Scuttle to be able to check if a buffer has been bookmarked or not.

  add_hook('mode_line_hook', mode_line_adder(scuttle_bookmarked_widget));

Set-up keybindings for posting to scuttle.

  define_key(default_global_keymap, 'p', 'scuttle-post');
  define_key(default_global_keymap, 'P', 'scuttle-post-link');

Emacs integration

Using org-protocol we can add information from the page.

  function org_capture(url, title, selection, window) {
      var cmd_str = 'emacsclient "org-protocol://capture://b/' + url + '/' + title + '/' + selection + '"';

      if (window !== null) {
          window.minibuffer.message('Issuing ' + cmd_str);
      }

      shell_command_blind(cmd_str);
  }

  function org_capture_command(I) {
      var url = encodeURIComponent(I.buffer.display_uri_string);
      var title = encodeURIComponent(I.buffer.document.title);
      var selection = encodeURIComponent(I.buffer.top_frame.getSelection());

      org_capture(url, title, selection, I.window);
  }

  interactive("org-capture",
              "Clip url, title and selection to capture via org-protocol",
              org_capture_command);

  define_key(content_buffer_normal_keymap, "C-c b", "org-capture");