An introduction to the Emacs Reader
Divyá - IRC: divya, Website: https://www.phimulambda.org Mastodon: https://mathstodon.xyz/@divyaranjan, divya@subvertising.org
Format: 35-min talk ; Q&A: BigBlueButton conference room Etherpad: https://pad.emacsconf.org/2025-reader
Etherpad: https://pad.emacsconf.org/2025-reader
Status: TO_REVIEW_QA
Talk
Duration: 34:37 minutes00:00.720 An introduction to the Emacs reader 00:44.760 Yet another document viewer in Emacs? 02:05.760 Architecture of Emacs Reader 06:00.280 A word on dynamic modules 07:39.560 Features of Emacs Reader 07:56.760 Memory efficiency 11:18.720 Performance and speed 14:23.680 Scanned PDFs 17:08.960 System-level multi-threading 23:44.240 Native Emacs integrations 25:10.340 (Naive) dark mode 26:01.140 Challenges and further improvements 29:14.272 What Emacs can learn? 32:32.300 Contributing to the development 33:35.520 Acknowledgements
Q&A
Description
https://codeberg.org/divyaranjan/emacs-reader
This talk will introduce a new document reader that I have been building for Emacs since the last few months. I will showcase the basic features of the document reader, how well it integrates with Emacs and the performance and other improvements that it provides in comparision to the existing document viewing options such as DocView, PDF Tools and others.
I will also describe the core architectural decisions that were made, specficially the fact that it is a dynamic module and the pains and pleasures of interfacing Emacs with C and vice-versa.
I will give a high-level tour of the codebase, which is pretty small as of now (<3K LOC), so that if a fellow Emacs developer wishes to contribute, they know where and how to get started.
In conclusion, I'll summarize the current features we're in the process of developing, what challenges we're facing in diong so, and what we wish to work on for the upcoming versions of the package.
About the speaker:
I’m Divyá from India. My background has been as a mathematics teacher and now I'm a programmer. I’ve been hacking on free software as a hobby and, for the past three to four years, living inside Emacs. I loved reading PDFs in Emacs via pdf-tools, but poor hardware and maintenance gaps pushed me to build a faster reader. I learned MuPDF and Emacs Dynamic Modules and wrote The Emacs Reader: a dynamic-module-based, high-performance, resource-friendly document viewer for Emacs that supports PDFs and other formats (EPUB, CBZ) while integrating natively with Emacs.
Discussion / notes
- Q: Is there scope for integrating the C library into Emacs itself
with muPDF becoming an optional dependency?
- A: That will entail having a pdf engine integrated into Emacs source-tree, not sure if that\'s a good idea.
- Q: The dynamic modules sound great, and it\'s amazing they\'re there
since 2017. Why is it so slow to take off, do you think? Is there
prior art with them?
- A: Mostly because Elisp is so nice to use for almost everything you need to do in Emacs. It\'s only in very specific cases that you require to care about real-time latency and memory efficiency. And packages like libvterm and others do use it for such purposes.
- Q: How is pdf-tools difficult to install? I install it using the built in package manager. Looking at the emacs-reader installation instructions, I don\'t see how install it that easily. I don\'t use use-package or straight. Question answered in presentation.
- A: Just the list of dependencies required to build epdfinfo itself makes it difficult, and when you install pdf-tools it does a huge autotools build as well. Emacs Reader only (and will always) depends on MuPDF (and Emacs too.).
- Q: What tool(s) did you use to measure the memory usage between the
three packages?
- A: Valgrind\'s massif + massif-visualizer
- I've been using perf and then visualizing with hotspot when debugging FFI in Common Lisp... it's felt successful
- (I've never had success with valgrind, but I've not dug deep with it)
- I discovered perf only recently when I had a deep need for low-level optimisation (which is not something I often need) - it's a really nice workflow!
- Q: How is the conversion between ELisp and the foreign language type
system done? For example when interfacing with a C++ library that
makes heavy use of C++ object system and templates?
- A: Basically, dynamic modules make you write Emacs Lisp in your language. Consult the blogpost above for a more elaborate and complete explanation.
- Q: pdf-tools renders high quality images. Does emacs-reader do that?
- A: Yes! We can render high-quality images just fine!
- Q: Can one look at pdf metadata with emacs-reader? Can annotations
be added? Does it understand forms? Can it handle encrypted pdfs?
- A: Support for all of this is planned.
- Q: I installed emacs-reader already. It is as promised
Great job!
How can I associate odt files to open with emacs-reader?
- A: It should just work with the find-file command.
- Q: If a pdf file is open in emacs-reader and I regenerate the pdf
with some changes, does emacs-reader actually refresh the pdf on its
own or do I have to reload the pdf?
- A: Yes if it\'s a complete file with the same filename, but no if it\'s still being created with LaTeX - we need SyncTeX for that
- Q: What are the challenges with integrating with SyncTeX and AucTeX?
This would be great to see as pdf-tools handles this well.
- A: Planned, no major obstacles anticipated. The only reason we haven\'t done it yet is more important highlighting and text selection features planned.
- Q: Loved that presentation! Will you be giving another talk on the
architecture you went over? A deep-dive there would be awesome.
- A: Not at EmacsConf, but check out my streaming sessions at https://tv.dyne.org/c/phimulambda and I can talk about it there.
- Q: Is there search functionality? Something like isearch and occur?
- A: Not as such yet. But it is HIGH PRIORITY.
- Q: Does dynamic module prevent customization that Elisp usually
provide? (Advices, Hooks, etc).
- A: No, you can do everything on the Elisp side that you want. On the dynamic side, it\'s a bit more tricky, not much support there right now.
- Q: Follow-up on dynamic module: Do you usually create an Elisp shim
from the FFI and then use them with Elisp code?
- A: Yes, we usually wrap dynamic module functions in Elisp to make sure the foreign function gets called when it\'s needed.
- Q: Is searching on the roadmap? Or is it already available as a
feature? Thanks!
- A: YES! HIGH PRIORITY \<3
- Q: Will there be occur like searching?
- A: YES! Basically everything in PDF Tools is planned!
- Q: What is your timing expectation for it to appear on ELPA?
- A: By next major release, which will be in 1-2 months.
- Q: is this essentially FFI?
- A: Yup
- Q: interesting.. is that how webkit integration works?
- (audience): not really.
- Q: thank you. Are there other packages that use dynamic modules?
- (audience): Yes, vterm also uses a C module
- Q: Has any work been done to make org-noter work with emacs reader?
- (audience): not yet. It is in the plans, though.
- (audience): Nice. That would allow me to switch, because I use org-noter quite a bit.
- Q: Are any of you doing simple editing of PDFs in Emacs? I'm thinking about form-filling, adding signatures, that sort of thing
- A: that's something I'd also like to integrate once we have other basic features ready
- (audience): not yet. We do want to add annotation support though. Not sure if that's the same thing.
- I don't believe it is, but I could be mistaken
- A: slightly, but not exactly, mupdf does support forms and signatures so we shouldn't have much issues except making it work with emacs.
- I'm not fond of annotations, because it mutates the original PDF.
- Q: From the example when calling page 56, is there another thread immediately fetching the next 5 pages for cache?
- A: yeah indeed I'll talk about it later in the slides, you'll have to build mupdf from scratch in that case.
- A: there are multiple threads competing to fill the cache window, depending upon how long it takes to render each slice.
- Q: here is a question that I am a bit embarassed to ask... is there an easy way to install emacs-reader with package-vc without use-package?
- yes!
- I am asking just because I've been postponing learning use-package for ages
- you can use just package-vc totally. use-package uses package-vc under the hood anyway
- I tried this - (package-vc-install "https://codeberg.org/divyaranjan/emacs-reader")
- you need to do a build step. you can just go and do it manually
- you can use just package-vc totally. use-package uses package-vc under the hood anyway
- Q: how does the dark mode compare to midnight mode in pdf-tools?
- it is simply inverting the colors
- Q: so it does not support setting the foreground and background colours?
- It does not.
- pdf-tools has pdf-view-themed-minor-mode that tries to match a PDF with the current theme. It's kinda nice. I'm glad Emacs Reader is aiming to have something similar in the near future.
- dark mode intergration with the dark themes would be cool
- Q: that is a question that I've had for ages - how do we handle that PDFs that (La)TeX generates one page at a time, and that will be broken until the last page is generated...
- using synctex
- Q: I will try to attend one of your streamings... where can I find info about them?
- A: https://tv.dyne.org/c/phimulambda
- we also have an IRC at #phi-mu-lambda you're also welcomed there edrx
Q: Oh, emacs reader can open epubs? I use nov.el for that, and it has trouble sometimes with complex epubs.
- yup it can

- it comes for free with mupdf
- I mean if mupdf supports it, emacs reader will to
- the only thing we don't support is djvu, but i have plans of making it supported in upstream mupdf
- Oh cool, I didn't know about the other formats!
- yup it can
https://codeberg.org/divyaranjan/emacs-reader
- https://mupdf.com/
- https://www.phimulambda.org/blog/emacs-dynamic-module.html \<-- that\'s a nice blog post.
- Love this arch diagram step through
- The linked blog for dynamic modules: https://www.phimulambda.org/blog/emacs-dynamic-module.html
You can set the maximum ram usage in Okular settings. If it is configured to load the entire document scrolling is instant even in large documents [not the author: this is only relevant to hugely beefy machines, surely? And it sounds like the Reader does it naturally, if you will]
16GB of RAM goes a long way even for huge documents like technical datasheets or photo pdfs. Just be careful not to open too many of them while also having a lot of browser tabs.
- Looks like Reader simply displays the old page until the new one is ready. While better than showing a white page it\'s not instant like Okular
- A: Emacs reader doesn\'t require 16GB RAM to do that same, because it doesn\'t need to cache everything at once, unlike Okular. The talk shows a video demonstration of it getting stuck when not configured to use maximum ram (in which it caches the pages.).
- I didn't realize pdf-tools was using so much RAM.
- I definitely noticed, lol
- The memory graphs are already a very compelling point for emacs reader. I will definitely give this a try.
- If you are dealing with large PDFs you really feel the difference
- For doc-view yes. For pdf-tools I have noticed it, but very rarely.
- But yeah, it is interesting how much memory it's taking
- I will definitely try this
- pdf tool caches the pages. once you are moving too fast, it is almost as slow as doc view, because it doesn't have it cached anymore
- This look promising! Dealing with PDFs is an important part of the things I do with Emacs (academic work). Certainly that Pdf-tools was already a much needed improvement to Doc-View - for example, not being able to select text was quite an issue. So when you get text selection and annotations working, I will be certainly looking forward your library.
- Great talk about emacs-reader. Looking forward to using it.
- Thank you for making this!

- Really tasteful typography on your slides divya
- A: Thank you it's all in Org

- A: Thank you it's all in Org
- I like pdf-tools, but I'm open to trying something new.
- pdf-tools mostly works well, but these points are very much valid
- also have been fairly satisfied with pdf-tools and avoided installation pain because the package manager of choice makes it easy, intrigued by reader and curious to try regardless though
- I've been using emacs-reader for some time - I have packaged it for nix, although I haven't submitted it to nixpkgs in the hope that emacs-reader will one day end up in ELPA/MELPA. https://git.sr.ht/~johnhamelink/nix/tree/master/item/home/modules/emacs/src/epkgs/reader.nix
- Love this arch diagram step through
- Org-noter integration would be very good
- I am also a big org-noter user
- A: I used pdf-tools for several years, indeed I love org-noter as well. certainly a priority integration for us.
- I like the use of diagrams in this talk. It makes it easier to understand.
- I just realized the thread pool has a bunch of "threads" in it!
- That's what those were! I was thinking, "What does 'S' stand for?"
- very impressive work, I'll have to try this later
- Very nice. I'm definitely giving this a try.
- On my OS: MuPDF version 1.19.0 too old. Require ≥ 1.26.0.
- yueah that is a major problem
- Already looks very promising and the upcoming features are likely to make me switch completely from pdf-tools.
- Exciting project!
- very cool!
- Playing with mupdf standalone, epubs look very nice!
- very nice talk.
- great talk divya! great talk indeed!
- Great talk, thank you!
- I'm sold on Emacs Reader. (looking forward to org-noter support)
- fantastic talk! many claps! =)
Super cool, emacs-reader on the list to try, we'll see if I can get it installed before the ELPA release
I'm super excited about this 😊
- great presentation 👏
- Great talk about emacs-reader. Looking forward to using it.
Transcript
Captioner: jay_bird
Q&A transcript (unedited)
The first question, and I'm reading from the etherpad here, is there a scope for integrating the C library to Emacs itself with MuPDF becoming an optional dependency? Right, so integrating the C library into Emacs itself is like having MuPDF inside Emacs source tree. I don't think Emacs devs would be inclined to do that, and I don't think we really need it. Um, I think as it is, uh, Emacs with doc view needs new tool, which is something you need to install from new PDF anyways. So, um, I think it is almost expected that you install new PDF from system package manager. Um, and I think that as it is, is better because we don't really need to have a whole PDF engine inside Emacs. Um, Next question also from the pad, the dynamic module some great, and it's amazing that they've been there since 2017. Why do you think they've been slowly so slow to get adopted? Is there a prior art with them? Right? That's a good question. Actually, I think 1 of the reasons is that. Most of the time, I think people love Emacs because they can do so much with Elisp. I think certainly there is a bias towards trying to do things with Elisp. I think there's only a sort of specific class of problems that you can solve with dynamic modules, such as this, where you want to use a native library to do something in a faster, better way. I use that quite a lot. There's of course libvterm, which uses a dynamic module and it does it really well. And I think there's another one, a plotting library or package in Emacs that was using something from Python. So, dynamic modules are good, but I think they don't really come to the surface level packages, your day-to-day packages, because most of the day-to-day packages that we use in Emacs can be done with Elisp. So, unless you really need something system-level efficient, Most of the time, you don't want to write C or C++ or something. But there is actually a really nice Rust crate for native modules, and there's a really nice Haskell package. So there's actually really good support for multiple languages. So it's there, it's just not used as much. Yeah. So what you're saying is if Elisp weren't so simple to learn and easy to use and so fully featured, we'd get a lot more mileage out of this super cool dynamic module feature. Yeah. Cool I'll take I'll bring in the next question. How how? How difficult is our PDF tools to install? The questioner is installing it using the built-in package manager looking at the Emacs reader installation instructions It doesn't necessarily cover how how to install that easily person is not using use package or straight and Okay. Oh, and they say that you didn't catch much of this in the presentation. Okay, so you want me to skip that or should I answer? It's your choice. If you would like to say more. Yeah, I think just as a thing, the reason I said PDF tools is difficult is PDF tools has a huge list of dependencies. The only thing Emacs Vita depends on is new PDF, nothing else. There's a single dependency. PDF tools depends on a lot of things and they have their own server, which is packaged as a system package, which you don't really find everywhere. And there's like systems, the new Linux systems where the package is very difficult to build because of so many dependencies. So my goal was to sort of reduce the number of dependencies. And then right now it's very, it's sort of a key to install Emacs Reader. Once we go to GNU Elpa, it's just going to be Emacs package install, just that. Right now you have to do package VC a bit. Boy, we get spoiled as Emacs users. Everything just gets so easy for us. It's like an IDE for our whole machine. What tools did you use to measure the memory usage between the three packages? Yeah, that's a good question. So during my development, I used mostly for debugging purposes Valgrind. So Valgrind is a a set of suite of debugging tools. And one of the tools that it has is Massive. It's a heap analyzer, heap profiler. So Valgrind plus Massive, and then there's a KDE package called Massive Visualizer. So I first get the Massive output using Valgrind, and then put that output into Massive Visualizer. That gives me the grasp. Are there Emacs integrations for those components at all? Does Valgrind have them? I don't think so. I don't think so. There's, yeah, there's I think a few packages which do something with Massive, but I don't think like they're maintained. Yeah. Gotcha. Cool. Awesome opportunity there for someone spunky. How is conversion between Elisp and foreign language types? For example, when interfacing with the C++ library that makes heavy use of the C++ object system and templates. Yeah, that's a good question. So the go-to answer is the blog post that I wrote, which is an extensive explanation on how the internals of dynamic modules work. The short answer is that basically what happens is anything that is compatible with C-ABI When you compile that language code, so when I compile C++ code, I would have a particular API. So we have a dynamic module API, which is the emacs-module.h, the file that I showed. You have to put that into your C++ package program and then link it to... So emacs-module.h is basically going to... like use things in your Emacs installation to interact with this C++ language. So it's basically FFI. And what this gives you is that you can have things in C++. So let's say you want to do multi-threading the way I did system level multi-threading. You can have C++ be responsible for the multi-threading. but you want the output of the multithreading to go into Emacs. So then you write like a piece of C++ function, which is going to be a dynamic module function. A dynamic module function is written in the language that you target, that is C++ or C or Rust. And then that is going to be compiled into a share library like SO. shared object, and then that shared object is going to be loaded into Emacs system using require. So when I do require render core in one of the slides that I showed, I'm basically loading that shared object, and that shared object already has the compiled dynamic module functions and so on. But my blog will explain that better. Gotcha. I thought that was pretty clear. I'm looking forward to seeing that blog post and understanding what I glossed over trying to understand from that explanation. That was great. Can one look at PDF metadata with Emacs Reader? Can you do annotations? Does it understand forms? Can it handle encrypted PDFs? In other words, I think reading between the lines, wow, this is awesome. Is there anything I can't do? You're right. So Emacs Reader will be able to do all of those things. It can do annotations. It will be able to do forms. And we have an issue open for interpret PDFs. The thing is, right now we are struggling with making Emacs Reader be very efficient in terms of highlighting and text selection because of the challenges that I mentioned in the slides, so it will be able to do all that. Once we tackle the basic features down in an efficient manner. Gotcha. Um. Comment or questioner says, I installed Emacs Reader already as promised. Great job. How can I associate ODT files to open with Emacs Reader? You don't really need to do anything. You should be just able to do find file, Control X, Control F, and open. And it should open with Emacs Reader because we have an auto mode list, a list that takes an ODT file and opens it with reader mode. So you should just be able to do find file. If you're not able to do that, you should open Embug report. And I'll just mention we've got about 10 minutes left of our live Q&A, but if you're watching the stream, it's possible that we'll just keep going. The questions just keep coming, which I just love that. So feel free to join the BBB link that should have shown in the IRC chat. Jump in and we can take questions as long as Divya has steam for that. If a PDF file is open in Emacs Reader and I reintegrate the PDF with some changes, does the Emacs Reader refresh the PDF on its own or do I reload it? Right, that's also a really good question. So one answer is that it depends on how you change the PDF. So for example, if I just replaced the PDF with something else of the same name, Emacs will update it immediately. If you have auto revert mode on, it'll just revert the buffer and it'll reload the PDF really nicely. But if you're doing it something like LaTeX, where you're writing something in LaTeX and LaTeX is continuously producing the PDF, that needs SyncTeX integration. Because LaTeX, while it's producing the PDF, it does a lot of funky things. It does not provide a sort of renderable PDF all the time. So Emacs will sort of crash trying to basically render a PDF that is not ready yet. So we need SyncTex to sync with LaTeX to do that really nice. Okay, so we have to do some care and feeding of the exact timing if we have more of a continuous behind the curtains, so to speak. That makes a lot of sense to me. What are the challenges with integrating synctex and AucTex? This would be great to see as PDF handles as well, or PDF tools handles as well. Yeah, yeah. So, we have Synctex and Auctex planned. I don't really see any major obstacles for doing that, to be very honest. I think we can do it in a much simpler way than PDF Tools does. The only reason we haven't done it yet is because, again, we have more important highlighting and text selection and those features planned, but it's anticipated. Yeah. All right. This next question I love your presentation. Will you be giving another talk on the architecture you went over a deep dive on? That would be awesome. I'm not sure if an EmacsConf talk will be appropriate for this, but I do stream bi-weekly. So you're always welcome to come on my stream and ask, and I would be very happy to go deep into this. I'm looking forward to catching that myself. Thank you for the shout. Is there search functionality, something like isearch and occur? Yeah, we don't really have it, but this is the most immediate feature after we have text selection. So once we have text selection, once we're able to select the text, then we can have iSearch so that it can highlight the text. Yeah. Um, all right. And then, um, there's, I'm just gonna, I'll read out this question and then I have to do a little bookkeeping on the pad. Um, does the dynamic module, uh, prevent customization that Emacs usually provides advice, hooks, et cetera, or does everything just kind of No, if you have a dynamic module, it doesn't limit you into doing anything. You can do everything on the Elisp side that you want, and you only take care of certain things on the dynamic module side. If you're asking whether you can do advices, hooks, and all of that on the dynamic module itself, from the dynamic module itself, that's a bit tricky because something like Calling a macro or doing macros and dynamic modules is not really that nice You have to pretty much manually expand the macro yourself in the dynamic module so if you want to do it from the dynamic module, there's not much support right now, but you can do everything on the elisp side without touching the dynamic module. Got it So those are the questions that I see. I'm just going to take a quick peek, but let me invite you if you want to. We've got just about 5 minutes left and I will get carried away sometimes and fail to make this invitation before we cut away live, especially if we do keep going a bit. that you have live onto the stream. Of course, you don't have to do that. You said a lot in your presentation. No, I think mostly that's fine. I'm just really happy that people are interested in the package, and I would be glad to have contributors and viewers or anything. That would be nice. Awesome. So here comes one more question, or actually a couple more questions coming in. Following up on dynamic modules, do you usually create an Elisp shim from foreign function interface and then use them with Elisp? Yeah, so basically how you do is you write, let's say I have a C function that I've written in the dynamic module. It's a dynamic module function. And then when I'm trying to call the dynamic module function, most of the time, I don't call it like that. I wrap it inside a proper Elisp function and then call that Elisp function. So that's how I think it's better to do that because You can take care of certain cases on when you want the dynamic module function to be called. Maybe sometimes you don't want the dynamic module function to be called immediately. So it's better to wrap it. Yeah. Okay. So timing issues. Yeah. For the purposes of managing timing issues, that elisp shim is preferred. Yeah. Makes sense. Um. Uh, so question question here is searching for the person is searching for a roadmap. Is that already available as a feature? Searching is on the roadmap. It is not available yet as a feature, but it's on priority. I think you may have may have touched on that. Sorry. All right. Those are the questions that I see. We've got just a couple of minutes. I'm not sure if you have more you wanted to say, but I have to say how much I appreciate your talk, especially you jumping in live with us and just taking everything on the fly. I think this is a big part of what adds the energy, you in particular, just really dynamic speaker. Thank you. Thank you. Thank you. I enjoyed it as well. A person is, and I think this may have been touched on already, but let's maybe get into it more specifically. We've said that search is kind of a next up type of feature as things, as the current iteration stabilizes. Question was, you know, occur like, how would you? Totally. There will be occur searches. There will be isearch enabled, isearch. used to with PDF tools, we would be like parity with the features, all the features that you're used to with PDF tools. Um, so, uh, certainly occur anything that is important in Emacs with text and that can be done with PDFs. We really want to do that because, um, I want the package to be as knitted into Emacs ecosystem as possible. Okay. We'll see if we can get in this last question here. Do you have a timing expectation for ELPA? Uh, yeah, next major release essentially. So next major release is most likely going to be within a month or two. So once we have the next major release, we're going to be. Uh, timing couldn't be more perfect. Maybe this is a good, good point to break. We'll be cutting away to the next talk in just a couple of minutes. So let me say one more time how much on behalf of all the attendees and all the volunteers and all everybody, um, how much we appreciate your talks and, uh, your awesome contribution to the Emacs world. Thanks, Corwin.Questions or comments? Please e-mail divya@subvertising.org
