22; ;;; SPDX-License-Identifier: BSD-3-Clause
33
44(nyxt :define-package :nyxt/mode/blocker
5- (:documentation " Package for `blocker-mode', mode to block requests for listed hosts.
5+ (:documentation " Package for `blocker-mode', mode to block requests for hosts.
66`blocker-mode' relies on:
77- `hostlist' as the hostlist representation.
88- `*default-hostlist*' as the most reliable hostlist.
@@ -49,9 +49,10 @@ See the `hostlist' class documentation."
4949
5050(export-always ' *default-hostlist*)
5151(defparameter *default-hostlist*
52- (make-instance ' hostlist
53- :url (quri :uri " https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" )
54- :base-path #p " hostlist-stevenblack.txt" )
52+ (make-instance
53+ ' hostlist
54+ :url (quri :uri " https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" )
55+ :base-path #p " hostlist-stevenblack.txt" )
5556 " Default hostlist for `blocker-mode'." )
5657
5758(define-mode blocker-mode ()
@@ -69,7 +70,8 @@ Example:
6970
7071\( define-mode my-blocker-mode (nyxt/mode/blocker:blocker-mode)
7172 \" Blocker mode with custom hosts from `*my-blocked-hosts*'.\"
72- ((nyxt/mode/blocker:hostlists (list *my-blocked-hosts* nyxt/mode/blocker:*default-hostlist*))))
73+ ((nyxt/mode/blocker:hostlists
74+ (list *my-blocked-hosts* nyxt/mode/blocker:*default-hostlist*))))
7375
7476\( define-configuration :buffer
7577 ((default-modes (append '(my-blocker-mode) %slot-default%))))
@@ -102,14 +104,17 @@ internal programming APIs."
102104 (hooks :remove-hook (request-resource-hook (buffer mode))
103105 ' request-resource-block)))
104106
105- (defmethod files :write-file ((profile nyxt-profile) (hostlist hostlist) &key destination)
107+ (defmethod
108+ files :write-file ((profile nyxt-profile) (hostlist hostlist) &key destination)
106109 " Write the downloaded hostlist to disk.
107110This is the raw downloaded content and not the serialized parsed content.
108111This gives more integrity guarantees to the user and allows external manipulation."
109112 (unless (uiop :emptyp (files :url-content hostlist))
110- (alex :write-string-into-file (files :url-content hostlist) destination :if-exists :supersede )))
113+ (alex :write-string-into-file (files :url-content hostlist) destination
114+ :if-exists :supersede )))
111115
112- (defmethod files :deserialize ((profile nyxt-profile) (hostlist hostlist) raw-content &key )
116+ (defmethod
117+ files :deserialize ((profile nyxt-profile) (hostlist hostlist) raw-content &key )
113118 (flet ((empty-line? (line)
114119 (< (length line) 2 ))
115120 (comment? (line)
@@ -151,6 +156,9 @@ This is an acceptable handler for `request-resource-hook'."
151156 (mapcar #' closer-mop:slot-definition-name
152157 (closer-mop :class-slots (class-of object)))))
153158
154- (define-command update-hostlists (&optional (blocker-mode (find-submode ' nyxt/mode/blocker:blocker-mode (current-buffer))))
159+ (define-command
160+ update-hostlists
161+ (&optional (blocker-mode
162+ (find-submode ' nyxt/mode/blocker:blocker-mode (current-buffer))))
155163 " Forces update for all the hostlists of `blocker-mode'."
156164 (clrhash (blocked-hosts blocker-mode)))
0 commit comments