When no explicit browser object is given with a composable browser object, it will now compose with the default browser object, according to the command invoked.
For example the keys "T c" will now copy the text of a link, rather than giving the message "No object". --- Previously: http://thread.gmane.org/gmane.comp.mozilla.conkeror/1799/focus=1797 (But that had the obscure precedence rules slightly wrong.) --- modules/element.js | 31 ++++++++++++++++++++++++++++++- modules/interactive.js | 24 ------------------------ 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/modules/element.js b/modules/element.js index db7a82d..13f1385 100644 --- a/modules/element.js +++ b/modules/element.js @@ -288,8 +288,37 @@ interactive("browser-object-text", }, $prefix); +function get_browser_object (I) { + var obj = I.browser_object; + var cmd = I.command; + + // if there was no interactive browser-object, + // binding_browser_object becomes the default. + if (obj === undefined) { + obj = 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 === undefined)) + { + obj = cmd.browser_object; + } + // if we still have no browser-object, look for a page-mode + // default, or finally the command default. + if (obj === undefined) { + obj = (I.buffer && + I.buffer.default_browser_object_classes[cmd.name]) || + cmd.browser_object; + } + + return obj; +} + function read_browser_object (I) { - var browser_object = I.browser_object; + var browser_object = get_browser_object(I); if (browser_object === undefined) throw interactive_error("No browser object"); diff --git a/modules/interactive.js b/modules/interactive.js index 1e98ea1..ee891ac 100644 --- a/modules/interactive.js +++ b/modules/interactive.js @@ -104,30 +104,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 === undefined) { - 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 === undefined)) - { - 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 === undefined) { - I.browser_object = - (I.buffer && I.buffer.default_browser_object_classes[command]) || - cmd.browser_object; - } - handler = cmd.handler; try { -- 1.7.5.4 _______________________________________________ Conkeror mailing list [email protected] https://www.mozdev.org/mailman/listinfo/conkeror
