The composable browser object introduced in b1c194a
(browser-object-text: new composable browser object, bound to T,
2009-11-16) failed when no explicit browser object was given.  For
example the keys "T c" resulted in an error.

Determining the default browser object is now performed when the
object is read, which allows composition with the default, so that
those keys now work.
---

Moving the default handling from call_interactively (as is done here)
is the most straightforward fix, but perhaps doesn't respect the
abstraction boundaries.

The existing default handling was a little obscure; I think the order
in which to choose a default goes:

  - I.binding_browser_object;
  - I.command.browser_object, only if it's a literal, not a class
  - I.buffer.default_browser_object_classes
  - I.command.browser_object

The text of this patch depends on [[PATCH] Give a useful error message
when no browser object type is specified], but could easily be made
independent.
  
---
 modules/element.js     |   11 ++++++++++-
 modules/interactive.js |   24 ------------------------
 2 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/modules/element.js b/modules/element.js
index 6d24126..91a0bea 100644
--- a/modules/element.js
+++ b/modules/element.js
@@ -270,8 +270,17 @@ interactive("browser-object-text",
     },
     $prefix);
 
+function default_browser_object (I) {
+    return I.binding_browser_object ||
+        (!(I.command.browser_object instanceof browser_object_class) &&
+         I.command.browser_object) ||
+        (I.buffer &&
+         I.buffer.default_browser_object_classes[I.command.name]) ||
+        I.command.browser_object;
+}
+
 function read_browser_object (I, nullok) {
-    var browser_object = I.browser_object;
+    var browser_object = I.browser_object || default_browser_object(I);
     var result;
     if (browser_object == null) {
         if (nullok)
diff --git a/modules/interactive.js b/modules/interactive.js
index f5c3dd9..52e6377 100644
--- a/modules/interactive.js
+++ b/modules/interactive.js
@@ -101,30 +101,6 @@ function call_interactively (I, command) {
     }
 
     I.command = cmd;
-
-
-    // if there was no interactive browser-object,
-    // binding_browser_object becomes the default.
-    if (I.browser_object == null) {
-        I.browser_object = I.binding_browser_object;
-    }
-    // if the command's default browser object is a non-null literal,
-    // it overrides an interactive browser-object, but not a binding
-    // browser object.
-    if (cmd.browser_object != null &&
-        (! (cmd.browser_object instanceof browser_object_class)) &&
-        (I.binding_browser_object == null))
-    {
-        I.browser_object = cmd.browser_object;
-    }
-    // if we still have no browser-object, look for a page-mode
-    // default, or finally the command default.
-    if (I.browser_object == null) {
-        I.browser_object =
-            (I.buffer && I.buffer.default_browser_object_classes[command]) ||
-            cmd.browser_object;
-    }
-
     handler = cmd.handler;
 
     try {
-- 
1.6.5

_______________________________________________
Conkeror mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/conkeror

Reply via email to