How to connect Emacs with Nyxt

Requirements in Emacs

Install sly. Using use-package:

(use-package sly
  :commands (sly sly-connect))

Or with package install:

(package-install 'sly)

Requirements in the system

Install nyxt...

sudo pacman -S nyxt

Close all nyxt instances.

pkill nyxt

Install SBCL

sudo pacman -S sbcl

Install [quicklisp] and check the signature validity against the public key in GnuPG servers.

curl -O
curl -O
gpg2 --receive-keys 307965AB028B5FF7
gpg2 --verify quicklisp.lisp.asc quicklisp.lisp

Load the lisp file with sbcl:

sbcl --load quicklisp.lisp

Inside the sbcl terminal run to start the installation procedure (copy paste the following code):


It will create the directory with all the package. The `ql:quickload ` function will download, install, and load the desired package.


Configure Nyxt

Write this at the end of ~/.config/nyxt/init.lisp

(load "~/quicklisp/setup.lisp")
(ql:quickload :slynk)
(define-command-global start-slynk (&optional (slynk-port *swank-port*))
  "Start a Slynk server that can be connected to, for instance, in
Emacs via SLY.
Warning: This allows Nyxt to be controlled remotely, that is, to execute
arbitrary code with the privileges of the user running Nyxt.  Make sure
you understand the security risks associated with this before running
this command."
  (slynk:create-server :port slynk-port :dont-close t :interface "")
  (echo "Slynk server started at port ~a" slynk-port))

Consider changing `:interface ` to `:interface ` to avoid opening ports on all interfaces.

Connect Emacs!

Run nyxt.


Press `M-x start-slynk ` to start the server.

Run `M-x sly-connect `, provide the host and port at the Emacs side (or run the following with C-c C-c):

(sly-connect "" "4006")

Controlling Nyxt

Functions can be redefined with `defun `.

Nyxt commands are under the package `nyxt:: `. For instance, the following command will open the manual.


Usually, nyxt::* is not required. The following command will open a new URL in the current buffer:

(buffer-load "about:blank")

Getting help

(describe #'buffer-load)

Nuevas funciones con HTML

(define-command my-html-data ()
  "Just open an example buffer"
    (with-current-html-buffer (buffer "*My help*" 'nyxt/help-mode:help-mode)
        (:style (style buffer))
        (:style (cl-css:css '(("#documentation .button"
                               :min-width "100px"))))
        (:h1 "Welcome to Nyxt :-)")
        (:p (:a :href "" ""))
        (:p (:a :class "button" :href (lisp-url `(help)) "Help"))
        (:p "This is a common example text."))))

This function is accessible via de URL lisp://(my-html-data)

Setting a slot

A slot works as class variables shared among instances (classes and instances are OOP simile). It can be setted with `#'define-configuration ` functions. As the name suggests, they are used as configurations variables because all instances are affected as soon as their values are modified.

The following example set a slot `prompter::filter-postprocessor ` with a lambda function as value (the function is the value). The slot is defined in the `user-new-url-or-search-source ` class (the name is not case sensitive).

(define-configuration USER-NEW-URL-OR-SEARCH-SOURCE
    (lambda (nyxt::suggestions nyxt::source nyxt::input)
      (declare (ignore nyxt::suggestions nyxt::source))
      (nyxt::input->queries nyxt::input :check-dns-p t :engine-completion-p nil)))))


Classes are the same as OOP, but instances can change its behaviour by changing the method and slot definitions.

That is the reason why slots are used as configuration too.

The following create an instance of a class `user-new-url-or-search-source `.

(make-instance 'user-new-url-or-search-source :actions an-action-list-here)