Professional Emacs environment for R package development on macOS
A complete, integrated development environment for R package development within Emacs:
- π ESS Integration - Full Emacs Speaks Statistics support with R console and code evaluation
- β Flycheck + Linters - Real-time syntax checking with lintr and custom styler integration
- π LSP Mode - Language Server Protocol for intelligent code navigation and refactoring
- π‘ Smart Completion - Company mode with context-aware autocompletion
- π Roxygen2 Automation - Automatic documentation skeleton generation with parameter detection
- π¨ Auto-Formatting - Styler integration for automatic code formatting on save
- π· S7 Support - Built-in snippets and helpers for R's new S7 OOP system
- π¦ Usethis Integration - Quick commands for creating R files, tests, and documentation
- π Git Integration - Magit for visual Git operations
- π Quarto/LaTeX - Full support for Quarto documents and LaTeX writing
- macOS 12.0+ (tested on macOS 12+)
- Emacs 27.1+ (emacs-plus recommended)
- R 4.0+
- Homebrew (recommended)
# Clone the repository
git clone https://github.com/Data-Wise/emacs-r-devkit.git
cd emacs-r-devkit
# Run installer
./install-init.sh
# Install required R packages
Rscript -e 'install.packages(c("devtools", "usethis", "roxygen2", "testthat", "lintr", "styler", "languageserver"))'
# Verify installation
./check-dependencies.sh# Start Emacs (first launch takes 10-15 minutes for package installation)
emacs
# Or use GUI
open -a EmacsNote: The first launch downloads and compiles packages from MELPA. Subsequent launches are fast (<5 seconds).
Comprehensive documentation is available at data-wise.github.io/emacs-r-devkit
- Getting Started - Installation and setup guide
- Features - Detailed feature documentation
- Keybindings - Complete keybinding reference for macOS
- Configuration - Customization options
- Troubleshooting - Common issues and solutions
- Testing - Verification guide
| Key | Action | Description |
|---|---|---|
| β g | Cancel | Escape/cancel (use when stuck!) |
| β x β f | Find file | Open file |
| β x β s | Save | Save file |
| β₯ x | Execute | Run command |
| β c r | R prefix | emacs-r-devkit commands |
| β c r r | Roxygen | Insert documentation |
| β β | Send to R | Execute line/region |
| β₯ . | Go to def | Jump to definition |
| β c ! l | List errors | Show Flycheck errors |
Note: β₯ = Option key (Meta), β = Control, β§ = Shift, β = Command
See the complete keybinding reference for more.
- Package Management - Automatic package installation via MELPA
- ESS (R Mode) - Full R integration with console and evaluation
- Flycheck - Syntax checking with lintr and custom styler checker
- LSP Mode - Language Server Protocol with R languageserver
- Company - Smart code completion
- Vertico/Consult - Modern completion framework
- Magit - Visual Git interface
- Projectile - Project management
- Which-Key - Keybinding discovery
- Yasnippet - Code snippets
- Quarto/Polymode - Quarto document support
- AUCTeX - LaTeX integration
- Org Mode - Enhanced org-mode
- Citar - Citation management
r-styler-check.R- External Flycheck checker for stylerexport-gui-path.sh- PATH exporter for macOS GUI Emacs
guides/TUTORIAL.md- Complete user guideguides/CHEAT-SHEET.md- Quick keybinding referenceguides/TROUBLESHOOTING.md- Problem solving guidetests/TEST-CHECKLIST.md- Verification checklist
tests/test-features.R- Interactive feature testingtests/test-roxygen.R- Roxygen generation testing
emacs-r-devkit integrates seamlessly with:
- Terminal Workflow - Use with
rtest,rdoc,rcheckaliases - Claude Code - AI-powered development assistance
- zsh-environment - Modern shell with development tools
- r-package-development - Complete R workflow automation
# 1. Open R package
cd ~/R-packages/active/mypackage
emacs .
# 2. Edit code in Emacs
# - Auto-completion
# - Real-time error checking
# - Roxygen documentation
# - Auto-formatting on save
# 3. Test interactively in R console
# M-x R
# C-RET to send code
# 4. Validate in terminal
rtest # Run tests
rdoc # Build documentation
rcheck # R CMD checkContributions are welcome! Please see CONTRIBUTING.md for guidelines.
- π Report bugs via GitHub Issues
- π‘ Suggest features or improvements
- π Improve documentation
- π§ Submit pull requests
- macOS 12.0+ (Monterey or later)
- Emacs 27.1+ (30.0+ recommended)
- R 4.0+
- Git 2.0+
install.packages(c(
"devtools",
"usethis",
"roxygen2",
"testthat",
"lintr",
"styler"
))install.packages(c(
"languageserver", # LSP support
"s7", # S7 OOP system
"covr", # Test coverage
"pkgdown", # Package websites
"remotes" # Remote packages
))After installation, verify everything works:
# Run automated checks
./check-dependencies.sh
# Open test file in Emacs
emacs tests/test-features.R
# Follow tests/TEST-CHECKLIST.md for comprehensive testingHaving issues? Check:
- Troubleshooting Guide - Common problems and solutions
- GitHub Issues - Known issues and discussions
- Dependency Checker - Run
./check-dependencies.sh - Messages Buffer - In Emacs: β h e
MIT License - see LICENSE for details.
Built with:
- GNU Emacs - The extensible text editor
- ESS - Emacs Speaks Statistics
- Material for MkDocs - Documentation theme
- R Project - Statistical computing
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Website: data-wise.github.io/emacs-r-devkit
Made with β€οΈ for the R development community
β Star this repo if you find it useful!