diff --git a/contrib/python/hooks.py b/contrib/python/hooks.py index 0d4151ac..a4726e49 100644 --- a/contrib/python/hooks.py +++ b/contrib/python/hooks.py @@ -46,7 +46,7 @@ dumbprefixes = { "sd" : "http://www.slashdot.org/" } -def goto_url_hook(url, current_url): +def goto_url_hook(url): """Rewrite a URL that was entered in a "Go to URL" dialog box. This function should return a URL for ELinks to follow, or None if @@ -55,8 +55,6 @@ def goto_url_hook(url, current_url): Arguments: url -- The URL provided by the user. - current_url -- The URL of the document being viewed, or None if no - document is being viewed. """ if url in dumbprefixes: @@ -136,13 +134,12 @@ class goto_url_in_new_tab: """Prompter that opens a given URL in a new tab.""" def __init__(self): """Prompt for a URL.""" - self.current_location = elinks.current_url() elinks.input_box("Enter URL", self._callback, title="Go to URL") def _callback(self, url): """Open the given URL in a new tab.""" if 'goto_url_hook' in globals(): # Mimic the standard "Go to URL" dialog by calling goto_url_hook(). - url = goto_url_hook(url, self.current_location) or url + url = goto_url_hook(url) or url if url: elinks.open(url, new_tab=True) # The elinks.bind_key() function can be used to create a keystroke binding diff --git a/doc/python.txt b/doc/python.txt index baf81357..a5225150 100644 --- a/doc/python.txt +++ b/doc/python.txt @@ -44,7 +44,7 @@ FUNCTIONS url -- The URL of the link. - goto_url_hook(url, current_url) + goto_url_hook(url) Rewrite a URL that was entered in a "Go to URL" dialog box. This function should return a URL for ELinks to follow, or None if @@ -53,8 +53,6 @@ FUNCTIONS Arguments: url -- The URL provided by the user. - current_url -- The URL of the document being viewed, or None if no - document is being viewed. pre_format_html_hook(url, html) Rewrite the body of a document before it's formatted. diff --git a/src/scripting/python/hooks.c b/src/scripting/python/hooks.c index 23a07f07..9ff63df1 100644 --- a/src/scripting/python/hooks.c +++ b/src/scripting/python/hooks.c @@ -15,7 +15,6 @@ #include "main/event.h" #include "protocol/uri.h" #include "scripting/python/core.h" -#include "session/location.h" #include "session/session.h" #include "util/memory.h" #include "util/string.h" @@ -64,28 +63,7 @@ script_hook_url(va_list ap, void *data) python_ses = ses; - /* - * Historical note: The only reason the goto and follow hooks are - * treated differently is to maintain backwards compatibility for - * people who already have a goto_url_hook() function in hooks.py - * that expects a second argument. If we were starting over from - * scratch, we could treat the goto and follow hooks identically and - * simply pass @url as the sole argument in both cases; the Python - * code for the goto hook no longer needs its @current_url argument - * since it could instead determine the current URL by calling the - * Python interpreter's elinks.current_url() function. - */ - if (!strcmp(method, "goto_url_hook")) { - unsigned char *current_url = NULL; - - if (python_ses && have_location(python_ses)) - current_url = struri(cur_loc(ses)->vs.uri); - - result = PyObject_CallMethod(python_hooks, method, "ss", *url, - current_url); - } else { - result = PyObject_CallMethod(python_hooks, method, "s", *url); - } + result = PyObject_CallMethod(python_hooks, method, "s", *url); if (!result || !replace_with_python_string(url, result)) alert_python_error();