diff options
author | Arun Isaac | 2022-12-25 00:49:24 +0000 |
---|---|---|
committer | Arun Isaac | 2022-12-25 23:33:04 +0000 |
commit | 3304bdae6d3df5ec0dd5b737743cbd2109d50423 (patch) | |
tree | e01cce84a1e6bb43f172dcb4db05f7aea018aa68 | |
parent | 3ff858a5fd78ee4b93af129149430bbd1b39a583 (diff) | |
download | tissue-3304bdae6d3df5ec0dd5b737743cbd2109d50423.tar.gz tissue-3304bdae6d3df5ec0dd5b737743cbd2109d50423.tar.lz tissue-3304bdae6d3df5ec0dd5b737743cbd2109d50423.zip |
web: themes: Add functional way to define methods.
* tissue/web/themes.scm: Import (srfi srfi-26).
(add-methods): New function.
-rw-r--r-- | tissue/web/themes.scm | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tissue/web/themes.scm b/tissue/web/themes.scm index f1a107c..21de09b 100644 --- a/tissue/web/themes.scm +++ b/tissue/web/themes.scm @@ -17,6 +17,7 @@ ;;; along with tissue. If not, see <https://www.gnu.org/licenses/>. (define-module (tissue web themes) + #:use-module (srfi srfi-26) #:use-module (oop goops) #:export (<search-page> search-page-uri @@ -27,7 +28,8 @@ search-page-matched-open-issues search-page-matched-closed-issues search-page-matched-documents - search-page-matched-commits)) + search-page-matched-commits + add-methods)) (define-class <search-page> () (uri #:getter search-page-uri #:init-keyword #:uri) @@ -39,3 +41,12 @@ (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)) |