In Emacs, Everything Looks Like a Service
This article debunks the common misconception of Emacs as an OS, instead positing it as a powerful client that can orchestrate services. It argues that Emacs's extensive Lisp libraries and dynamic nature allow it to treat virtually anything as a service. The post delves into technical examples, demonstrating how Emacs users can build sophisticated client behaviors directly within their editor.
The Lowdown
The article explores the idea that "In Emacs, Everything Looks Like a Service," challenging the popular notion of Emacs as a full operating system. Instead, it positions Emacs as a highly capable platform for orchestrating applications and utilities above the OS kernel, allowing users to build rich client-side functionalities directly within the editor.
- The author clarifies that while Emacs isn't an OS, its ability to interact with OS services and run external programs enables it to serve as a powerful orchestrator, facilitating a "living only in Emacs" workflow.
- It introduces the client-server model, breaking down client responsibilities into UI, Client Edge (communication), and Local Database, and demonstrates how Emacs's built-in and third-party libraries address each of these concerns.
- Specific Emacs Lisp libraries are highlighted, such as Minibuffers and Buffers for UI, URL and Socket for network communication, and JSON/XML for serialization, along with various data structures like Hash Tables and even SQLite for local data management.
- Emacs Lisp (Elisp) is presented as the cornerstone, a dynamic programming language that allows for high degrees of run-time improvisation and complex orchestration, integrating both Elisp functions and shell commands.
- A practical example is provided: an Elisp client for
wttr.in, a console-oriented weather service. The code snippets illustrate how to construct URLs, fetch and parse JSON responses, and display formatted weather reports in the mini-buffer. - The article also suggests a simpler alternative, where Emacs delegates heavy lifting to external command-line utilities (like a Python
weatherscript), effectively treating these scripts as services themselves.
Ultimately, the post aims to convince readers of Emacs's profound capability to integrate and manage diverse services, leveraging its high-level APIs and Elisp's dynamic nature to create a seamless, integrated computing environment.