From 48d7ef686cf8d4663c24350ded5b6833ce171f14 Mon Sep 17 00:00:00 2001 From: James Cherti <60946298+jamescherti@users.noreply.github.com> Date: Tue, 15 Jul 2025 15:05:33 -0400 Subject: [PATCH] Update README.md --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 8e56168..b19ff9b 100644 --- a/README.md +++ b/README.md @@ -947,6 +947,21 @@ To configure **markdown-mode**, add the following to `~/.emacs.d/post-init.el`: This configuration sets up `markdown-mode` with deferred loading to improve startup performance. The `:commands` and `:mode` keywords ensure that the mode is loaded only when needed—for example, when opening `.md`, `.markdown`, or `README.md` files. Files named `README.md` are specifically associated with `gfm-mode`, which is for GitHub Flavored Markdown syntax. The `markdown-command` variable is set to `"multimarkdown"` to specify the Markdown processor used for previews and exports. Additionally, a keybinding (`C-c C-e`) is defined in `markdown-mode-map` to invoke `markdown-do`, which can be customized to perform common Markdown-related actions. +**Table of contents:** To automatically generate a table of contents when editing Markdown files, add the following to your `~/.emacs.d/post-init.el`: +```elisp +;; Automatically generate a table of contents when editing Markdown files +(use-package markdown-toc + :ensure t + :commands (markdown-toc-generate-toc + markdown-toc-generate-or-refresh-toc + markdown-toc-delete-toc + markdown-toc--toc-already-present-p) + :custom + (markdown-toc-header-toc-title "**Table of Contents**")) +``` + +The author also recommends reading the following article: [Emacs: Automating Table of Contents Update for Markdown Documents (e.g., README.md)](https://www.jamescherti.com/emacs-markdown-table-of-contents-update-before-save/). + ### Tree-sitter Integration (Better Syntax Highlighting) Tree-sitter is an incremental parsing system introduced in Emacs 29 that provides precise, high-performance syntax analysis and highlighting by constructing concrete syntax trees from source code. It supports a broad set of programming languages, including Bash, C, C++, C#, CMake, CSS, Dockerfile, Go, Java, JavaScript, JSON, Python, Rust, TOML, TypeScript, YAML, Elisp, Lua, Markdown, and many others. Unlike traditional font-lock, which relies on regular expressions, Tree-sitter uses formal grammar definitions to build real-time parse trees, enabling accurate syntax highlighting, structural navigation, code folding, and foundational support for advanced editing features like refactoring.