 filterCompleter = (args, port) ->
   queryTerms = if (args.query == "") then [] else args.query.split(" ")
   completers[args.name].filter(queryTerms, (results) -> port.postMessage({ id: args.id, results: results }))
-
-#
-# Used by everyone to get settings from local storage.
-#
-getSettingFromLocalStorage = (setting) ->
-  if (localStorage[setting] != "" && !localStorage[setting])
-    defaultSettings[setting]
-  else
-    localStorage[setting]
 
 getCurrentTimeInSeconds = -> Math.floor((new Date()).getTime() / 1000)
 

    chrome.tabs.getSelected(null, (tab) ->
      chrome.tabs.sendRequest(tab.id,
        { name: "toggleHelpDialog", dialogHtml: helpDialogHtml(), frameId:frameId }))

# Selects a tab before or after the currently selected tab.
# - direction: "next", "previous", "first" or "last".

  selectSpecificTab: selectSpecificTab,
  refreshCompleter: refreshCompleter

# Convenience function for development use.
window.runTests = -> open(chrome.extension.getURL('test_harnesses/automated.html'))

#
# Begin initialization.
#
Commands.clearKeyMappingsAndSetDefaults()

if Settings.has("keyMappings")
  Commands.parseCustomKeyMappings(Settings.get("keyMappings"))

populateValidFirstKeys()
populateSingleKeyCommands()
if shouldShowUpgradeMessage()
  sendRequestToAllTabs({ name: "showUpgradeNotification", version: currentVersion })

# Ensure that openTabs is populated when Vimium is installed.
chrome.windows.getAll({ populate: true }, (windows) ->
  for window in windows
    for tab in window.tabs
      updateOpenTabs(tab)
      createScrollPositionHandler = ->
        (response) -> updateScrollPosition(tab, response.scrollX, response.scrollY) if response?
      chrome.tabs.sendRequest(tab.id, { name: "getScrollPosition" }, createScrollPositionHandler()))
