2021-11-16, updated: 2024-03-12

Tested with Nyxt 2.2.2.

Tags: lisp, philosophy.

How can I make Emacs my web browser?

How can I make Emacs my web browser?

By Pedro Delfino

The original idea

In the beginning of 2017, Nyxt was founded. By then, the project (initially named nEXT (from n Extensions)) was born from a pain: the impossibility of having a good Emacs experience while using the Internet.

Nyxt was forged as an answer to this problem. As a consequence, Nyxt shares multiple similarities with Emacs. Moreover, beyond the initial idea, Nyxt has always been built by programmers using Emacs as their main text editors. Naturally, this creates an unconscious influence on how a person sees the (computing) world which endorses Emacs weight on Nyxt's code and design.

I am not a founder of Nyxt. When I was introduced to the project, I only had had brief exposure to Lisp- more specifically- to Racket. I also had had a brief exposure to Emacs (trying it for less than an hour, and seeing other people using it). But, it was too light, as any Emacs experienced user would point out.

When I started working on Nyxt, Emacs became my main tool. It was funny to realize the similarities between the two. Sometimes, I would see a feature in Emacs and, then, something similar in Nyxt. Other times, the opposite happened. The first time I saw a Helm buffer, I thought Oh, that looks similar to Nyxt's prompt-buffer. Which is chronologically incorrect :)

If I could go back in time, as a newcomer, it would have been awesome to read an article pointing out the similarities between the two projects. This could be a good read for newcomers to either Nyxt and/or the Emacs universe. So, let's do it!

The Creation of Adam, Michelangelo - 1512

Ethos

Let's begin with philosophy: both projects take a stance in the free and open-source movement. Licenses are just part of the equation. A community driven by tinkering and hackability is what makes freedom real, and contributions so rich.

Also, Nyxt and Emacs take a different approach than Unix. Instead of doing one thing and doing it well, Nyxt and Emacs share a core foundation built upon extensibility. They are designed to be introspected, changed, and hacked on the fly.

User Experience and Vocabulary

The User Experience of Nyxt and Emacs is similar in many ways. Even the vocabulary is suchlike - including the oddness. Thus, users are presented with uncommon words such as buffers. Secondly, even though the user can use the mouse, both of them are keyboard-driven desktop applications.

Furthermore, it must be highlighted the likeness of their interfaces. In both cases, there is a message-area, a status area, and a main focus on the screen (the buffer). In Emacs parlance, that is the mini-buffer, the mode-line, and the buffer, respectively.

With regard to the User Interface's components, Nyxt's prompt-buffer deserves special attention due to its resemblance to popular Emacs' packages such as Helm, and Ivy. They are optional packages, but their popularity makes choosing one of them almost mandatory.

Value proposition

What is Emacs proud to offer? According to the GNU Emacs manual:

Emacs is the extensible, customizable, self-documenting, real-time display editor.

Well, ditto for Nyxt. The official web page presents the following definition:

Nyxt: the hacker's power-browser.

Quickly analyze, navigate, and extract information from the Internet. Nyxt is fully hackable — all of its source code can be introspected, modified, and tweaked to your exact specification.

Note that they do not use an but the as a definite article. You can see the ambition here :D

Both programs are made as tools for tinkerers. This is the main reason people will probably love (or hate) them.

A concrete point to illustrate this aspect is the fact that their settings are mainly controlled via configuration files written in fully general-purpose programming languages. More specifically, languages from the Lisp family! You simply cannot get more flexible, introspectable, and powerful than that :)

Unlike Nyxt and Emacs, most text editors and browsers only offer buttons and a Graphic User Interface (GUI) for settings definitions. Nyxt and Emacs also offer a point and click interface. But even the best GUI design is incomparable to the power of a .lisp or .elisp file.

Architecture

According to the book Mastering Emacs (Peterson, Mickey - 2015), the buffer is the data structure of Emacs. All commands act on buffers. And not on an internal data structure as some people might think. The same for Nyxt.

Elisp, in Emacs, and Common Lisp, for Nyxt, also guarantee the introspectability of their objects. Thus, both applications are self-documented and it's possible to change things on the fly.

You can redefine functions because, at its core, Emacs is "just" a Lisp interpreter that happens to load code-editing facilities. In parallel, something similar can be said about Nyxt, since it can be framed as a (Common) Lisp interpreter that happens to load web browsing facilities.

As a consequence, any functions you create are going to be treated the same way as built-in functions. You can even use Emacs to execute elisp, modifying Emacs as it runs, or using the lisp-repl in Nyxt to tweak Nyxt itself.

This live hackability allows both tools to be dynamically self-documented. As you tweak your configuration files, the descriptions of functions and bindings will also be updated - without even restarting.

Technically inclined people

Programmers are famous for igniting flame wars around which tool is the best. Although the quality debate causes divergence, there is a consensus that Emacs is not an easy tool. The same can be said about Nyxt.

Point and click text editors and web browsers have less steep learning curves. However, from this "problem" arises a positive side-effect: the users tend to be technically inclined - for real. And you can learn a lot by simply being part of this community.

Vim as a subset

Another tool frequently used by power users as a text editor is Vim. In order to welcome Vim aficionados, it is possible to have a Vim experience in Emacs with Evil-mode. The same is possible in Nyxt with vi-mode. Evil is a cooler name, though - we must admit.

As you can see, Emacs and Nyxt treat Vim as a subset. And there is no reason to be angry about this affirmative. It is a technical fact :)

The road ahead

As stated by Eric S. Raymond,

Every good work of software starts by scratching a developer’s personal itch.

I'm not sure if Nyxt already qualifies as good work of software, but it definitely started as a developer's personal itch.

Finally, after all this notorious synergy, a question arises: If Nyxt has so many similarities to Emacs and if Emacs has a vibrant ecosystem of extensions and packages, why not build Nyxt as an Emacs package instead of a solo application?

Well, I asked myself that very question a couple of times and the answer to it deserves it's own article. Stay tuned and may the power of Nyxt be with you!


Did you enjoy this article? Register for our newsletter to receive the latest hacker news from the world of Lisp and browsers!