diff --git a/AUTHORS b/AUTHORS index c8142cb0..cd4e3695 100644 --- a/AUTHORS +++ b/AUTHORS @@ -12,6 +12,7 @@ Inactive/former developers: * Viktor Kojouharov (Виктор Кожухаров) Patches (in no special order): + * Dominik Meister (:b# support) * Konstantin Stepanov (:%foo support, :tabduplicate) * Lukas Mai * Guido Van Hoecke diff --git a/Donators b/Donators index 8d036375..af7dcb26 100644 --- a/Donators +++ b/Donators @@ -2,6 +2,7 @@ Note: If you don't wish to appear on this list when making a donation, please tell me. 2008: +* John Lusth * Thomas Svensen * Ryan McBride * Brian Clark diff --git a/NEWS b/NEWS index 846a0744..7add9d80 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ generous donation which made this behavior possible) * IMPORTANT: ctrl-x/a never take possible negative URLs into account, it was just too unpredictable + * add :b# to select the alternate buffer * add :tabduplicate command * new 'urlseparator' option for specifying the regexp used to split the arg to :open, :tabopen and :winopen diff --git a/content/bookmarks.js b/content/bookmarks.js index 3a791436..834eaf96 100644 --- a/content/bookmarks.js +++ b/content/bookmarks.js @@ -383,53 +383,22 @@ liberator.Bookmarks = function () //{{{ return keywords; }, - // if @param engineName is null, it uses the default search engine + // full search string including engine name as first word in @param text + // if @param useDefSearch is true, it uses the default search engine // @returns the url for the search string // if the search also requires a postData, [url, postData] is returned - getSearchURL: function (text, engineName) + getSearchURL: function (text, useDefsearch) { var url = null; - var postData = null; - if (!engineName) - engineName = liberator.options["defsearch"]; + var aPostDataRef = {}; + var searchString = (useDefsearch? liberator.options["defsearch"] + " " : "") + text; - // we need to make sure our custom alias have been set, even if the user - // did not :open once before - this.getSearchEngines(); + url = getShortcutOrURI(searchString, aPostDataRef); + if (url == searchString) + url = null; - // first checks the search engines for a match - var engine = searchService.getEngineByAlias(engineName); - if (engine) - { - if (text) - { - var submission = engine.getSubmission(text, null); - url = submission.uri.spec; - postData = submission.postData; - } - else - url = engine.searchForm; - } - else // check for keyword urls - { - if (!keywords) - load(); - - for (var i in keywords) - { - if (keywords[i][0] == engineName) - { - if (text == null) - text = ""; - url = keywords[i][2].replace(/%s/g, encodeURIComponent(text)); - break; - } - } - } - - // if we came here, the engineName is neither a search engine or URL - if (postData) - return [url, postData]; + if (aPostDataRef && aPostDataRef.value) + return [url, aPostDataRef.value]; else return url; // can be null }, diff --git a/content/tabs.js b/content/tabs.js index adcf1ccc..6afb1745 100644 --- a/content/tabs.js +++ b/content/tabs.js @@ -238,26 +238,7 @@ liberator.Tabs = function () //{{{ liberator.mappings.add([liberator.modes.NORMAL], ["", ""], "Select the alternate tab", - function () - { - if (liberator.tabs.alternate == null || liberator.tabs.getTab() == liberator.tabs.alternate) - { - liberator.echoerr("E23: No alternate page"); - return; - } - - // NOTE: this currently relies on v.tabs.index() returning the - // currently selected tab index when passed null - var index = liberator.tabs.index(liberator.tabs.alternate); - - // TODO: since a tab close is more like a bdelete for us we - // should probably reopen the closed tab when a 'deleted' - // alternate is selected - if (index == -1) - liberator.echoerr("E86: Buffer does not exist"); // TODO: This should read "Buffer N does not exist" - else - liberator.tabs.select(index); - }); + function () { liberator.tabs.selectAlternateTab(); }); } /////////////////////////////////////////////////////////////////////////////}}} @@ -748,10 +729,9 @@ liberator.Tabs = function () //{{{ switchTo: function (buffer, allowNonUnique, count, reverse) { if (buffer == "") - { return; - } - else if (buffer != null) + + if (buffer != null) { // store this command, so it can be repeated with "B" lastBufferSwitchArgs = buffer; @@ -764,6 +744,12 @@ liberator.Tabs = function () //{{{ allowNonUnique = lastBufferSwitchSpecial; } + if (buffer == "#") + { + liberator.tabs.selectAlternateTab(); + return; + } + if (!count || count < 1) count = 1; if (typeof reverse != "boolean") @@ -829,6 +815,29 @@ liberator.Tabs = function () //{{{ return newTab; }, + selectAlternateTab: function () + { + if (liberator.tabs.alternate == null || liberator.tabs.getTab() == liberator.tabs.alternate) + { + liberator.echoerr("E23: No alternate page"); + return; + } + + // NOTE: this currently relies on v.tabs.index() returning the + // currently selected tab index when passed null + var index = liberator.tabs.index(liberator.tabs.alternate); + + // TODO: since a tab close is more like a bdelete for us we + // should probably reopen the closed tab when a 'deleted' + // alternate is selected + if (index == -1) + liberator.echoerr("E86: Buffer does not exist"); // TODO: This should read "Buffer N does not exist" + else + liberator.tabs.select(index); + + return; + }, + // TODO: when restarting a session FF selects the first tab and then the // tab that was selected when the session was created. As a result the // alternate after a restart is often incorrectly tab 1 when there diff --git a/content/util.js b/content/util.js index 1abb3d2f..189b9737 100644 --- a/content/util.js +++ b/content/util.js @@ -285,40 +285,27 @@ liberator.util = { //{{{ // strip each 'URL' - makes things simpler later on urls[url] = urls[url].replace(/^\s+/, "").replace(/\s+$/, ""); - // first check if it is an existing local file but NOT a search url/keyword - // NOTE: the test for being a file is done first, because it's faster than getSearchURL - var file = liberator.io.getFile(urls[url]); - if (file.exists() && file.isReadable() && !liberator.bookmarks.getSearchURL("", urls[url])) - { - urls[url] = file.path; - continue; - } - // if the string doesn't look like a valid URL (i.e. contains a space // or does not contain any of: .:/) try opening it with a search engine // or keyword bookmark - if (liberator.has("bookmarks") && (/\s/.test(urls[url]) || !/[.:\/]/.test(urls[url]))) + if (/\s/.test(urls[url]) || !/[.:\/]/.test(urls[url])) { - var matches = urls[url].match(/^(\S+)(?:\s+(.+))?$/); - var alias = matches[1]; - var text = matches[2] || null; - // TODO: it would be clearer if the appropriate call to // getSearchURL was made based on whether or not the first word was // indeed an SE alias rather than seeing if getSearchURL can // process the call usefully and trying again if it fails - much // like the comments below ;-) - // check if the first word is a search engine - var searchURL = liberator.bookmarks.getSearchURL(text, alias); + // check for a search engine match in the string + var searchURL = liberator.bookmarks.getSearchURL(urls[url], false); if (searchURL) { urls[url] = searchURL; continue; } - else // the first word was not a search engine, search for the whole string in the default engine + else // no search engine match, search for the whole string in the default engine { - searchURL = liberator.bookmarks.getSearchURL(urls[url], null); + searchURL = liberator.bookmarks.getSearchURL(urls[url], true); if (searchURL) { urls[url] = searchURL; @@ -327,6 +314,13 @@ liberator.util = { //{{{ } } + var file = liberator.io.getFile(urls[url]); + if (file.exists() && file.isReadable()) + { + urls[url] = file.path; + continue; + } + // if we are here let Firefox handle the url and hope it does // something useful with it :) } diff --git a/locale/en-US/various.txt b/locale/en-US/various.txt index 283565c0..04237abc 100644 --- a/locale/en-US/various.txt +++ b/locale/en-US/various.txt @@ -682,6 +682,8 @@ If argument is neither a full URL nor an index but uniquely identifies a buffer, it is selected. With [!] the next buffer matching the argument is selected, even if it cannot be identified uniquely. Use [m]b[m] as a shortcut to open this prompt. + +If argument is #, the alternate buffer will be selected (see [m][m]). ________________________________________________________________________________