diff --git a/NEWS b/NEWS index 32a709ad..b728b370 100644 --- a/NEWS +++ b/NEWS @@ -1,10 +1,12 @@
 2008-06-xx:
     * version 1.2
+    * :bdelete accepts an optional argument now
     * renamed some :autocmd, mainly BrowserStartup -> Startup and BrowserExit -> Quit
     * don't pass any ctrl- or alt- prefixed keys to firefox in insert mode
     * keywords in :open  have higher priority than local files now
     * add :set online to control the "work offline" menu item
+    * many small bug fixes
 
 2008-06-03:
     * version 1.1
diff --git a/content/liberator.js b/content/liberator.js
index 57c8dfbb..e42d7659 100644
--- a/content/liberator.js
+++ b/content/liberator.js
@@ -787,6 +787,8 @@ const liberator = (function () //{{{
             if (cancelQuit.data)
                 return;
 
+            liberator.autocommands.trigger("Quit", "");
+
             // notify all windows that an application quit has been granted.
             os.notifyObservers(null, "quit-application-granted", null);
 
@@ -918,11 +920,12 @@ const liberator = (function () //{{{
                     if (option.setter && !option.hasChanged)
                         option.reset();
                 }
+
+                liberator.autocommands.trigger("Startup", "");
             }, 0);
 
             liberator.statusline.update();
 
-            liberator.autocommands.trigger("Startup", "");
             liberator.log(liberator.config.name + " fully initialized", 1);
         },
 
diff --git a/content/tabs.js b/content/tabs.js
index 4043f12a..5ff9525a 100644
--- a/content/tabs.js
+++ b/content/tabs.js
@@ -260,8 +260,43 @@ liberator.Tabs = function () //{{{
         "Delete current buffer",
         function (args, special, count)
         {
-            liberator.tabs.remove(getBrowser().mCurrentTab, count > 0 ? count : 1, special, 0);
-        });
+            if (args)
+            {
+                args = args.toLowerCase();
+                var removed = 0;
+                var match;
+                if (match = args.match(/^(\d+):?/))
+                {
+                    liberator.tabs.remove(liberator.tabs.getTab(parseInt(match[1], 10) - 1));
+                    removed = 1;
+                }
+                else
+                {
+                    var browsers = getBrowser().browsers;
+                    for (let i = browsers.length - 1; i >= 0; i--)
+                    {
+                        var title = browsers[i].contentTitle.toLowerCase() || "";
+                        var uri = browsers[i].currentURI.spec.toLowerCase();
+                        var host = browsers[i].currentURI.host.toLowerCase();
+
+                        if (host.indexOf(args) >= 0 || uri == args ||
+                            (special && (title.indexOf(args) >= 0 || uri.indexOf(args) >= 0)))
+                        {
+                            liberator.tabs.remove(liberator.tabs.getTab(i));
+                            removed++;
+                        }
+                    }
+                }
+
+                if (removed > 0)
+                    liberator.echo(removed + " fewer tab(s)");
+                else
+                    liberator.echoerr("E94: No matching tab for " + args);
+            }
+            else // just remove the current tab
+                liberator.tabs.remove(getBrowser().mCurrentTab, count > 0 ? count : 1, special, 0);
+        },
+        { completer: function (filter) { return liberator.completion.buffer(filter); } });
 
     liberator.commands.add(["tab"],
         "Execute a command and tell it to output in a new tab",
diff --git a/locale/en-US/tabs.txt b/locale/en-US/tabs.txt
index fed55e3c..0bbcb1a9 100644
--- a/locale/en-US/tabs.txt
+++ b/locale/en-US/tabs.txt
@@ -1,9 +1,23 @@
 HEADER
 
 |tabs| +
-
 Tabs are used to be able to view many web pages at the same time...
 
+
+section:Closing{nbsp}tabs[closing-tabs]
+
+|:tabc| |:tabclose| |:bun| |:bunload| |:bw| |:bwipeout| |:bd| |:bdelete|
+||:[count]bd[elete][!] [arg]|| +
+________________________________________________________________________________
+Delete current buffer (=tab). Count is supported, [c]:2bd[c] removes two tabs
+and the one to the right is selected.
+
+When used with [arg], remove all tabs which contain [arg] in the hostname. 
+[!] forces this command to also search for [arg] in the full URL and also
+the title of the tab. Use with care.
+________________________________________________________________________________
+
+
 TO BE WRITTEN...
 
 
diff --git a/locale/en-US/various.txt b/locale/en-US/various.txt
index 4c93859b..aa0cf6a3 100644
--- a/locale/en-US/various.txt
+++ b/locale/en-US/various.txt
@@ -760,15 +760,6 @@ The special version [c]:back![c] goes to the beginning of the browser history.
 ________________________________________________________________________________
 
 
-|:tabc| |:tabclose| |:bun| |:bunload| |:bw| |:bwipeout| |:bd| |:bdelete|
-||:[count]bd[elete][!]|| +
-________________________________________________________________________________
-Delete current buffer (=tab). Count is supported, [c]:2bd[c] removes two tabs
-and the one to the right is selected. Do [c]:bdelete![c] to select the tab to
-the left after removing the current tab.
-________________________________________________________________________________
-
-
 |:beep|
 ||:beep||
 ________________________________________________________________________________