emacs-module: Utilities to write Emacs dynamic modules

[ apache, foreign, foreign-binding, library ] [ Propose Tags ] [ Report a vulnerability ]

This package provides a full set of bindings to emacs-module.h that allows to develop Emacs modules in Haskell. Bindings are based on Emacs 28 version of the interface and thus should work in all subsequent versions of Emacs, but will now work with earlier versions.

For pointers on how to write minimal Emacs module, please refer to tutorial https://github.com/sergv/emacs-module/blob/master/Tutorial.md.

Entry point: Emacs.Module module.


[Skip to Readme]

Flags

Manual Flags

NameDescriptionDefault
call-stacks

Enable call stacks

Disabled
assertions

Enable runtime assertions

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1, 0.1.1, 0.1.1.1, 0.2, 0.2.1, 0.2.1.1
Change log Changelog.md
Dependencies base (>=4.16 && <5), bytestring, deepseq, exceptions, filepath (>=1.5), monad-control, monad-interleave (>=0.2), mtl (>=2.3), os-string, prettyprinter (>=1.7), prettyprinter-combinators, primitive, template-haskell, text (>=2), transformers-base, tuples-homogenous-h98, vector (>=0.13), void [details]
Tested with ghc ==9.2.8, ghc ==9.4.7, ghc ==9.6.3, ghc ==9.8.1, ghc ==9.10.1
License Apache-2.0
Author Sergey Vinokurov
Maintainer Sergey Vinokurov <serg.foo@gmail.com>
Category Foreign, Foreign binding
Home page https://github.com/sergv/emacs-module
Source repo head: git clone https://github.com/sergv/emacs-module.git
Uploaded by SergeyVinokurov at 2024-05-16T22:45:09Z
Distributions LTSHaskell:0.2.1, NixOS:0.2.1, Stackage:0.2.1
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 3296 total (34 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2024-05-16 [all 1 reports]

Readme for emacs-module-0.2.1.1

[back to package description]

A Haskell package for writing Emacs modules

Why would anyone want to write Emacs modules in Haskell?

Emacs Lisp is not a young language and can go quite a long way, but it has a couple of issues that are not going to be solved any time soon:

  • It’s dynamically typed which makes refactoring large extensions a pain

  • It’s intepreted and is quite slow. It might be argued that editors don’t need much computing power, but from time to time computation-intensive tasks do occur. For example, fuzzy matching provided by the cool flx.el package and used by great ivy.el package to quickly find things.

  • Somewhat related to the previous point, there’s virtually no support for parallelising computations. There’re adavances on adding threads to Emacs lisp, but this only provides concurrency, but no parallelism.

    Haskell is well known for solving points 1 and 3 outlined above. For me it also solves point 2 by providing enough performance and adding parallelism on top of it.

    If you think this might be a good idea and would like to see what this package can do for you, you can look at part of my emacs config that uses this package to implement things like

    • Rewrite of flx.el that leverages parallelism
    • Fast search across filesystem
    • Concurrrent grep reimplementation (somewhat dubious since things like ripgrep exist)

FAQ

How do I start writing my own extensions?

See tutorial at https://github.com/sergv/emacs-module/blob/master/Tutorial.md.

Also check out this package’s tests.

What about Windows?

It works, Cabal can build a dll for you.

The haskell-emacs aims to address the same problem - writing Emacs extensions in Haskell, but uses different approach. It seems to use some kind of marshalling scheme to make Emacs data available in Haskell with a caveat that not all Emacs types can be converted (e.g. buffers cannot be typically serialised). Presumably, an extension built with this project will look like an executable that reads sexps from stdin and produces output on stdout. Or, possibly, as a daemon process that communicates with Emacs over network.

This project is a bit different. It wraps Emacs C API for writing new extensions that can manipulate Emacs values directly, without marhsalling. In this approach, an extension will look like a shared library/dll that can be loaded by standard emacs with (load "/tmp/libmy-ext.so").

Supported GHC versions

Tested with GHC 9.2, 9.4, 9.6, 9.8.