Modern Emacs

New tools that make Emacs better and faster

noshadow

Marie-Hélène Burle

March 5, 2024


Faster Emacs

Lexical binding

Introduced in version 24
Lexical binding can be used instead of dynamic binding for Emacs Lisp code
Set as a file local variable

Dynamic binding

Name resolution depends on program state (runtime context), determined at run time
Global environment for all variables

Makes modifying behaviour easy

Lexical binding

Name resolution depends on lexical context (static context), determined at compile time
Local environments of functions and let, defconst, defvar, etc. expressions

Makes compiler optimization much easier → faster Elisp code = faster Emacs

JIT native compilation

Introduced in version 28
Requires libgccjit
Build Emacs --with-native-compilation
Packages can also be compiled natively (automatic with straight)

Lazy loading

Built-in since version 29
Fine-tuned loading of packages with use-package
Integrates nicely with straight

  • Faster startup time
  • More organized init file
  • Easier to reload configurations for single package

Perfect parsing

Accurate syntax tree

Built-in since version 29
Tree-sitter for Emacs
Code is parsed accurately instead of using regexp

  • Perfect syntax highlighting, indentation, and navigation
  • Faster

Simplest setup with treesit-auto:

(use-package treesit-auto
  :config
  (treesit-auto-add-to-auto-mode-alist 'all))

More efficient completions

History of code completion in Emacs: IDO

History of code completion in Emacs: IDO vertical

From oremacs

History of code completion in Emacs: HELM