1 ;;; Bare interface to C code
4 (define-module (elinks internal)
5 :export (goto-url-hooks
12 ;;; GOTO-URL-HOOKS: Each hook is called in turn with a single argument
13 ;;; (a URL string). Each may return one of:
15 ;;; a string to visit the returned url
17 ;;; #f to continue with the next hook
19 ;;; If no hooks return a string or empty list, the default action is
20 ;;; to visit the original URL passed.
22 (define goto-url-hooks (make-hook 1))
24 (define (%goto-url-hook url)
25 (%call-hooks-until-truish goto-url-hooks
30 ;;; FOLLOW-URL-HOOKS: Each hook is called in turn with a single
31 ;;; argument (a URL string). Each may return one of:
33 ;;; a string to visit the returned url
35 ;;; #f to continue with the next hook
37 ;;; If no hooks return a string or empty list, the default action is
38 ;;; to visit the original URL passed.
40 (define follow-url-hooks (make-hook 1))
42 (define (%follow-url-hook url)
43 (%call-hooks-until-truish follow-url-hooks
48 ;;; PRE-FORMAT-HTML-HOOKS:
50 (define pre-format-html-hooks (make-hook 2))
51 (define (%pre-format-html-hook url html)
52 (%call-hooks-until-truish pre-format-html-hooks
53 (lambda (h) (h url html))
58 (define get-proxy-hooks (make-hook 1))
59 (define (%get-proxy-hook url)
60 (%call-hooks-until-truish get-proxy-hooks
67 (define quit-hooks (make-hook))
70 (run-hook quit-hooks))
73 ;;; Helper: calls hooks one at a time until one of them returns
75 (define (%call-hooks-until-truish hooks caller default)
76 (let lp ((hs (hook->list hooks)))