diff --git a/NEWS b/NEWS
index 8f0b886e..278b3782 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
2008-XX-XX:
* version 2.0 (probably)
+ * IMPORTANT: Due to much improved autocompletion, changed default 'complete' option
+ value to 'sfl', listing intelligent Firefox location bar results. Removed possibility
+ to use 'h' in 'complete'.
* IMPORTANT: AlwaysHint modes were removed as they didn't make too
much sense with the new hint system
* IMPORTANT: command actions now take an args object, returned from
@@ -12,6 +15,7 @@
special versions for the old behavior
* IMPORTANT: renamed Startup and Quit autocmd events to VimperatorEnter and
VimperatorLeave respectively
+
* :buffers supports a filter now to only list buffers matching filter (vim
incompatible, but consistent with other commands)
* Favicon support in many places
diff --git a/content/bookmarks.js b/content/bookmarks.js
index fa63cc0c..ecc85207 100644
--- a/content/bookmarks.js
+++ b/content/bookmarks.js
@@ -550,47 +550,6 @@ function History() //{{{
const historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"]
.getService(Components.interfaces.nsINavHistoryService);
- // const History = new Struct("url", "title", "icon");
- // History.defaultValue("title", function () "[No Title]");
- // History.defaultValue("icon", function () bookmarks.getFavicon(this.url));
-
- var placesHistory;
- var cachedHistory = []; // add pages here after loading the initial Places history
-
- function load()
- {
- placesHistory = [];
-
- // no query parameters will get all history
- // XXX default sorting is... ?
- var options = historyService.getNewQueryOptions();
- var query = historyService.getNewQuery();
-
- // execute the query
- var result = historyService.executeQuery(query, options);
- var rootNode = result.root;
- rootNode.containerOpen = true;
- // iterate over the immediate children of this folder
- for (let i = 0; i < rootNode.childCount; i++)
- {
- var node = rootNode.getChild(i);
- // liberator.dump("History child " + node.itemId + ": " + node.title + " - " + node.type);
- if (node.type == node.RESULT_TYPE_URI) // just make sure it's a bookmark
- placesHistory.push({ url: node.uri, title: node.title, get icon() function() bookmarks.getFavicon(this.url) });
- }
-
- // close a container after using it!
- rootNode.containerOpen = false;
- }
-
- liberator.registerObserver("enter", function () {
- if (options["preload"])
- {
- // Forces a load, if not already loaded but wait 15sec
- // so that we don't load it at the same time as bookmarks
- setTimeout(function() { liberator.callFunctionInThread(null, load); }, 15000);
- }
- });
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// MAPPINGS ////////////////////////////////////////////////
@@ -736,77 +695,57 @@ function History() //{{{
return {
- load: function() { load(); }, // temporary only, for performance testing
- get: function (filter)
+ get: function (filter, maxItems)
{
- if (!placesHistory)
- load();
+ let items = [];
- if (!filter)
- return cachedHistory.concat(placesHistory);
- return completion.cached("history", filter, function () cachedHistory.concat(placesHistory),
- "filterURLArray");
- },
+ // no query parameters will get all history
+ let query = historyService.getNewQuery();
+ query.searchTerms = filter;
- // the history is automatically added to the Places global history
- // so just update our cached history here
- add: function (url, title)
- {
- let filter = function (h) h[0] != url;
+ let options = historyService.getNewQueryOptions();
+ options.sortingMode = options.SORT_BY_DATE_DESCENDING;
+ if (maxItems > 0)
+ options.maxResults = maxItems;
- // don't let cachedHistory grow too large
- if (placesHistory && cachedHistory.length > 1000)
+ // execute the query
+ let root = historyService.executeQuery(query, options).root;
+ root.containerOpen = true;
+ for (let i = 0; i < root.childCount; i++)
{
- placesHistory = cachedHistory.concat(placesHistory);
- placesHistory = placesHistory.filter(filter);
- cachedHistory = [];
+ let node = root.getChild(i);
+ if (node.type == node.RESULT_TYPE_URI) // just make sure it's a bookmark
+ items.push({ url: node.uri, title: node.title, get icon() function() bookmarks.getFavicon(node.uri) });
}
- else
- cachedHistory = cachedHistory.filter(filter);
+ root.containerOpen = false; // close a container after using it!
- cachedHistory.unshift({ url: url, title: title, get icon() function() bookmarks.getFavicon(this.url) });
- return true;
+ return items;
},
- // TODO: better names?
- // and move to buffer.?
+ // TODO: better names and move to buffer.?
stepTo: function (steps)
{
- var index = getWebNavigation().sessionHistory.index + steps;
-
+ let index = getWebNavigation().sessionHistory.index + steps;
if (index >= 0 && index < getWebNavigation().sessionHistory.count)
- {
getWebNavigation().gotoIndex(index);
- }
else
- {
liberator.beep();
- }
},
goToStart: function ()
{
- var index = getWebNavigation().sessionHistory.index;
-
+ let index = getWebNavigation().sessionHistory.index;
if (index == 0)
- {
- liberator.beep();
- return;
- }
+ return liberator.beep(); // really wanted?
getWebNavigation().gotoIndex(0);
},
goToEnd: function ()
{
- var index = getWebNavigation().sessionHistory.index;
- var max = getWebNavigation().sessionHistory.count - 1;
-
- if (index == max)
- {
- liberator.beep();
- return;
- }
+ let index = getWebNavigation().sessionHistory.index;
+ if (index == getWebNavigation().sessionHistory.count - 1)
+ return liberator.beep();
getWebNavigation().gotoIndex(max);
},
@@ -814,7 +753,7 @@ function History() //{{{
// if openItems is true, open the matching history items in tabs rather than display
list: function (filter, openItems)
{
- var items = this.get(filter);
+ var items = this.get(filter, 1000);
if (items.length == 0)
{
if (filter.length > 0)
@@ -828,7 +767,6 @@ function History() //{{{
if (openItems)
return liberator.open([i[0] for each (i in items)], liberator.NEW_TAB);
- // TODO: is there a faster way to limit to max. 1000 items?
let list = template.bookmarks("title", items);
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
}
diff --git a/content/completion.js b/content/completion.js
index 7c40c5e8..189c8e68 100644
--- a/content/completion.js
+++ b/content/completion.js
@@ -164,7 +164,7 @@ function Completion() //{{{
let orig = obj;
if (obj.wrappedJSObject)
obj = obj.wrappedJSObject;
- compl.push([v for (v in this.iter(obj)) if (v[0] in orig || orig[v[0]])])
+ compl.push([v for (v in this.iter(obj)) if (v[0] in orig)])
// And if wrappedJSObject happens to be available,
// return that, too.
if (orig.wrappedJSObject)
@@ -1063,30 +1063,33 @@ function Completion() //{{{
let keywords = bookmarks.getKeywords();
let engines = this.filter(keywords.concat(bookmarks.getSearchEngines()), filter, false, true);
- let generate = function () {
- let hist = history.get();
- let searches = [];
- for (let [, k] in Iterator(keywords))
- {
- if (k.keyword.toLowerCase() != keyword.toLowerCase() || k.url.indexOf("%s") == -1)
- continue;
- let [begin, end] = k.url.split("%s");
- for (let [, h] in Iterator(hist))
- {
- if (h.url.indexOf(begin) == 0 && (!end.length || h.url.substr(-end.length) == end))
- {
- let query = h.url.substring(begin.length, h.url.length - end.length);
- searches.push([decodeURIComponent(query.replace("+", "%20")),
- <>{begin}{query}{end}>,
- k.icon]);
- }
- }
- }
- return searches;
- }
- let searches = this.cached("searches-" + keyword, args, generate, "filter", [false, true]);
- searches = searches.map(function (a) (a = a.concat(), a[0] = keyword + " " + a[0], a));
- return [0, searches.concat(engines)];
+ // NOTE: While i like the result of the code, due to the History simplification
+ // that code is too slow to be here. We might use a direct Places History query instead for better speed
+ // let generate = function () {
+ // let hist = history.get();
+ // let searches = [];
+ // for (let [, k] in Iterator(keywords))
+ // {
+ // if (k.keyword.toLowerCase() != keyword.toLowerCase() || k.url.indexOf("%s") == -1)
+ // continue;
+ // let [begin, end] = k.url.split("%s");
+ // for (let [, h] in Iterator(hist))
+ // {
+ // if (h.url.indexOf(begin) == 0 && (!end.length || h.url.substr(-end.length) == end))
+ // {
+ // let query = h.url.substring(begin.length, h.url.length - end.length);
+ // searches.push([decodeURIComponent(query.replace("+", "%20")),
+ // <>{begin}{query}{end}>,
+ // k.icon]);
+ // }
+ // }
+ // }
+ // return searches;
+ // }
+ // let searches = this.cached("searches-" + keyword, args, generate, "filter", [false, true]);
+ // searches = searches.map(function (a) (a = a.concat(), a[0] = keyword + " " + a[0], a));
+ // return [0, searches.concat(engines)];
+ return [0, engines];
},
// XXX: Move to bookmarks.js?
@@ -1260,8 +1263,6 @@ function Completion() //{{{
completions = completions.concat(this.searchEngineSuggest(filter, suggestEngineAlias)[1]);
else if (c == "b")
completions = completions.concat(bookmarks.get(filter));
- else if (c == "h")
- completions = completions.concat(history.get(filter));
else if (c == "l" && completionService) // add completions like Firefox's smart location bar
{
historyCache = [];
diff --git a/content/events.js b/content/events.js
index bb113aef..7a918115 100644
--- a/content/events.js
+++ b/content/events.js
@@ -517,10 +517,6 @@ function Events() //{{{
let url = doc.location.href;
let title = doc.title;
- // update history
- if (url && liberator.has("history"))
- history.add(url, title);
-
// mark the buffer as loaded, we can't use buffer.loaded
// since that always refers to the current buffer, while doc can be
// any buffer, even in a background tab
diff --git a/locale/en-US/options.txt b/locale/en-US/options.txt
index a84c2d0d..98340df0 100644
--- a/locale/en-US/options.txt
+++ b/locale/en-US/options.txt
@@ -218,26 +218,20 @@ ____
|\'cpt'| |\'complete'|
-||'complete' 'cpt'|| charlist (default: sfbh)
+||'complete' 'cpt'|| charlist (default: sfl)
____
Items which are completed at the [c]:[tab]open[c] prompt. Available items:
`---`--------------------------------------------------------------------------------
*s* Search engines and keyword URLs
*f* Local files
-*b* Bookmarks
-*h* History
*l* Firefox location bar entries (bookmarks and history sorted in an intelligent way)
+*b* Bookmarks
*S* Suggest engines
-------------------------------------------------------------------------------------
The order is important, so [c]:set complete=bs[c] would list bookmarks first,
-and then any available quick searches. Add "sort" to the 'wildoptions' option
-if you want all entries sorted. If 'wildoptions' contains "auto", "b" and "h"
-are not available for performance reasons but you can use "l" to achieve
-a similar effect. On the other hand "l" does not yet work, when 'wildoptions'
-does NOT contain "auto".
-
+and then any available quick searches.
____