From bdc092231eaf6dd1cd226d0bd6c6f429e21057e6 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sun, 22 Jan 2023 22:30:13 +0000 Subject: web: Deprecate add-methods. Functionally setting generic functions (like add-methods does) doesn't work since methods can still refer to the old generic function. The future of generic functions in the theming system is in doubt. It must be rethought out carefully. * tissue/web/themes.scm (add-methods): Delete function. * tissue/web/themes/default.scm (default-theme): Replace add-methods! with add-method. --- tissue/web/themes.scm | 14 ++------------ tissue/web/themes/default.scm | 7 ++++--- 2 files changed, 6 insertions(+), 15 deletions(-) (limited to 'tissue') diff --git a/tissue/web/themes.scm b/tissue/web/themes.scm index 21de09b..648d4d5 100644 --- a/tissue/web/themes.scm +++ b/tissue/web/themes.scm @@ -1,5 +1,5 @@ ;;; tissue --- Text based issue tracker -;;; Copyright © 2022 Arun Isaac +;;; Copyright © 2022, 2023 Arun Isaac ;;; ;;; This file is part of tissue. ;;; @@ -28,8 +28,7 @@ search-page-matched-open-issues search-page-matched-closed-issues search-page-matched-documents - search-page-matched-commits - add-methods)) + search-page-matched-commits)) (define-class () (uri #:getter search-page-uri #:init-keyword #:uri) @@ -41,12 +40,3 @@ (matched-closed-issues #:getter search-page-matched-closed-issues #:init-keyword #:matched-closed-issues) (matched-documents #:getter search-page-matched-documents #:init-keyword #:matched-documents) (matched-commits #:getter search-page-matched-commits #:init-keyword #:matched-commits)) - -(define (add-methods generic . methods) - "Add @var{methods} to @var{generic} function. This is purely -functional and operates on a copy of @var{generic}. It does not mutate -@var{generic}." - (let ((clone (shallow-clone generic))) - (for-each (cut add-method! generic <>) - methods) - clone)) diff --git a/tissue/web/themes/default.scm b/tissue/web/themes/default.scm index 7ab8c89..10732ee 100644 --- a/tissue/web/themes/default.scm +++ b/tissue/web/themes/default.scm @@ -1,5 +1,5 @@ ;;; tissue --- Text based issue tracker -;;; Copyright © 2022 Arun Isaac +;;; Copyright © 2022, 2023 Arun Isaac ;;; ;;; This file is part of tissue. ;;; @@ -113,10 +113,11 @@ theme. @var{title} is the title to use in the head of the HTML. @var{css} is a URI to a CSS stylesheet to link to. If it is @code{#f}, no stylesheet is linked to." - (add-methods render-sxml + (add-method! render-sxml (make #:specializers (list ) - #:procedure (make-head-renderer title css)))) + #:procedure (make-head-renderer title css))) + render-sxml) (define-method (render-sxml (page )) "Return SXML for @var{page}, a @code{}." -- cgit v1.2.3