How to customize the list of blocked hosts?

Hi guys,

I am trying to customize the list of the blocked hosts. blocker-mode docstring shows an example (I love examples inside documentation, by the way :innocent: ).

It states that:

To customize the list of blocked hosts, set the `hostlists' slot.
See the `hostlist' class documentation.

Example:

\(defvar *my-blocked-hosts*
  (nyxt/blocker-mode:make-hostlist
   :hosts '(\"platform.twitter.com\"
            \"syndication.twitter.com\"
            \"m.media-amazon.com\")))

\(define-mode my-blocker-mode (nyxt/blocker-mode:blocker-mode)
  \"Blocker mode with custom hosts from `*my-blocked-hosts*'.\"
  ((nyxt/blocker-mode:hostlists (list *my-blocked-hosts* nyxt/blocker-mode:*default-hostlist*))))

\(define-configuration buffer
  ((default-modes (append '(my-blocker-mode) %slot-default%))))"

Ok. I am doing the following on SLIME. First, just certify what is the precise host I would like to block:

NYXT> (quri:uri-host (url (current-buffer)))
"paulgraham.com"

Then, following the tutorial:

NYXT> (defvar *my-blocked-hosts*
  (nyxt/blocker-mode:make-hostlist
   :hosts '(\"paulgraham.com\")))
*MY-BLOCKED-HOSTS*

NYXT> (define-mode my-blocker-mode (nyxt/blocker-mode:blocker-mode)
 ((nyxt/blocker-mode:hostlists (list *my-blocked-hosts* nyxt/blocker-mode:*default-hostlist*))))
<WARN> [23:14:11] The define-mode definition for MY-BLOCKER-MODE doesn't have a documentation string.
WARNING: Command MY-BLOCKER-MODE doesn't have a documentation string
#<COMMAND MY-BLOCKER-MODE {1002C94C2B}>

NYXT> (define-configuration buffer
  ((default-modes (append '(my-blocker-mode) '()))))
WARNING:
   redefining DEFAULT-MODES :AROUND (#<STANDARD-CLASS NYXT:USER-BUFFER>) in DEFMETHOD
#<STANDARD-CLASS NYXT:USER-BUFFER>

OK. After all this:

1 - I am able to see my-blocked-mode as one of the options in the prompt-buffer;

2 - After choosing it, it is enabled in the status bar;

3 - Unfortunately, I can normally access http://paulgraham.com/ . I was expecting that my-blocker-mode would block the web page from loading. I can refresh the page multiple times having the mode enabled with the behavior persisting.

Not sure if this is a bug. I guess I just did something wrong. Thus, I will not provide a full recipe yet with all that information.

I am doing this on commit id 45bda8c0 (7 hours ago).

Did I miss something?

Thanks!

@jmercouris helped me out during a live meeting. The problem was that I did not create a new buffer!

Currently, this configuration tweak does not work for the current buffer.

2 Likes

There was another problem which is the \ in:

\"paulgraham.com\"

Emacs automatically introduced them. But they need to be removed.

@pedro-delfino what’s this about a live meeting? :open_mouth:

I have a weekly meeting with John. We work together :slight_smile: